Commits

stealth977 committed 44eb57a

- Cosmetic changes to Resources Panel
* Toolbar icons are now toggleable
* Resources Window's title changes according to current displayed widget
refs #900

  • Participants
  • Parent commits 980b0f9

Comments (0)

Files changed (3)

qtOgitor/include/mainwindow.hxx

     QAction*  actEditCopyToTemplate;
     QAction*  actEditCopyToTemplateWithChildren;
 
+    QActionGroup* mResourcesStackedActions; 
+
     QMenu*    menuCompactMenuBar;
     QMenu*    menuFile;
     QMenu*    menuImport;
     void onPlayerRunPause();
     void onPlayerStop();
     void onFocusOnObject();
+    void onSwitchStackedResources(int index);
 
 private:
     SceneViewWidget                 *mSceneViewWidget;
     std::vector<ScriptActionData>   mScriptActions;
     QSignalMapper*                  mScriptActionMap;
     QTimer                          *mAutoBackupTimer;
-    int                             mNextResToolbarMapIndex;
 
     void createScriptActionsToolbar();
     void closeEvent(QCloseEvent *event);

qtOgitor/src/mainwindow.cpp

     hideSubWindows();
 #endif
 
+    onSwitchStackedResources(0);
+
     EventManager::getSingletonPtr()->connectEvent(EventManager::MODIFIED_STATE_CHANGE,      this, true, 0, true, 0, EVENT_CALLBACK(MainWindow, onSceneModifiedChange));
     EventManager::getSingletonPtr()->connectEvent(EventManager::UNDOMANAGER_NOTIFICATION,   this, true, 0, true, 0, EVENT_CALLBACK(MainWindow, onUndoManagerNotification));
     EventManager::getSingletonPtr()->connectEvent(EventManager::RUN_STATE_CHANGE,           this, true, 0, true, 0, EVENT_CALLBACK(MainWindow, onSceneRunStateChange));
     mResourcesStackedToolBar->setIconSize(QSize(16, 16));
     mResourcesStackedToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
 
-    QToolButton* objectsButton = new QToolButton(this);
-    QToolButton* entitiesButton = new QToolButton(this);
-    QToolButton* templatesButton = new QToolButton(this);
-    objectsButton->setIcon(QIcon(":/icons/objects.svg"));
-    entitiesButton->setIcon(QIcon(":/icons/entity.svg"));
-    templatesButton->setIcon(QIcon(":/icons/template.svg"));
-    objectsButton->setToolTip(tr("Object"));
-    entitiesButton->setToolTip(tr("Meshes"));
-    templatesButton->setToolTip(tr("Templates"));
-    objectsButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
-    entitiesButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
-    templatesButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
-    mResourcesStackedToolBar->addWidget(objectsButton);
-    mResourcesStackedToolBar->addWidget(entitiesButton);
-    mResourcesStackedToolBar->addWidget(templatesButton);      
+    QAction *stackedAction;
+    mResourcesStackedMapper = new QSignalMapper(parent);
+    mResourcesStackedActions = new QActionGroup(this);
+    stackedAction = mResourcesStackedActions->addAction(QIcon(":/icons/objects.svg"), tr("Objects"));
+    stackedAction->setCheckable(true);
+    stackedAction->setChecked(true);
+    connect(stackedAction,  SIGNAL(triggered()), mResourcesStackedMapper, SLOT(map()));
+    mResourcesStackedMapper->setMapping(stackedAction,  0);
+    stackedAction = mResourcesStackedActions->addAction(QIcon(":/icons/entity.svg"), tr("Meshes"));
+    stackedAction->setCheckable(true);
+    connect(stackedAction,  SIGNAL(triggered()), mResourcesStackedMapper, SLOT(map()));
+    mResourcesStackedMapper->setMapping(stackedAction,  1);
+    stackedAction = mResourcesStackedActions->addAction(QIcon(":/icons/template.svg"), tr("Templates"));
+    stackedAction->setCheckable(true);
+    connect(stackedAction,  SIGNAL(triggered()), mResourcesStackedMapper, SLOT(map()));
+    mResourcesStackedMapper->setMapping(stackedAction,  2);
 
-    mResourcesStackedMapper = new QSignalMapper(parent);
-    connect(objectsButton,  SIGNAL(clicked()), mResourcesStackedMapper, SLOT(map()));
-    connect(entitiesButton, SIGNAL(clicked()), mResourcesStackedMapper, SLOT(map()));
-    connect(templatesButton, SIGNAL(clicked()), mResourcesStackedMapper, SLOT(map()));
-    mResourcesStackedMapper->setMapping(objectsButton,  0);
-    mResourcesStackedMapper->setMapping(entitiesButton, 1);
-    mResourcesStackedMapper->setMapping(templatesButton, 2);
-    mNextResToolbarMapIndex = 3;
-    connect(mResourcesStackedMapper, SIGNAL(mapped(int)), mResourcesStackedWidget, SLOT(setCurrentIndex(int)));
+    connect(mResourcesStackedMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchStackedResources(int)));
+
+    mResourcesStackedToolBar->addActions(mResourcesStackedActions->actions());
 
     stackedWidgetInnerDummy->addToolBar(Qt::BottomToolBarArea, mResourcesStackedToolBar);
     stackedWidgetInnerDummy->setCentralWidget(mResourcesStackedWidget);
                     }
                     else if(stackedWidget)
                     {
-                        QToolButton* button = new QToolButton(stackedWidget);
-                        button->setIcon(QIcon(dockwidgets[i].mIcon.c_str()));
-                        button->setToolTip(QString(dockwidgets[i].mCaption.c_str()));
-                        button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
-                        mResourcesStackedToolBar->addWidget(button);
+                        QAction* button = mResourcesStackedActions->addAction(QIcon(dockwidgets[i].mIcon.c_str()), QString(dockwidgets[i].mCaption.c_str()));
+                        button->setCheckable(true);
 
-                        connect(button, SIGNAL(clicked()), mResourcesStackedMapper, SLOT(map()));
-                        mResourcesStackedMapper->setMapping(button, mNextResToolbarMapIndex);
-                        mNextResToolbarMapIndex += 1;
+                        connect(button, SIGNAL(triggered()), mResourcesStackedMapper, SLOT(map()));
+                        mResourcesStackedMapper->setMapping(button, mResourcesStackedActions->actions().size() - 1);
+
+                        mResourcesStackedToolBar->addAction(button);
 
                         stackedWidget->addWidget(widget);
                     }                    

qtOgitor/src/mainwindowactions.cpp

     OgitorsRoot::getSingletonPtr()->SetRunState(RS_STOPPED);
 }
 //------------------------------------------------------------------------------
+void MainWindow::onSwitchStackedResources(int index)
+{
+    mResourcesStackedWidget->setCurrentIndex( index );
+
+    QString newTitle = tr("Resources") + QString(" - ") + mResourcesStackedActions->checkedAction()->text();
+    mResourcesDockWidget->setWindowTitle( newTitle );
+}
+//------------------------------------------------------------------------------
 QAction *separatorAction;
 
 void MainWindow::hideMenuBar()