Improved state handling of toolbar actions

This commit is contained in:
Magne Sjaastad 2015-09-17 08:25:10 +02:00
parent 4c9b25a85d
commit f1233e485a
3 changed files with 22 additions and 10 deletions

View File

@ -30,7 +30,7 @@ CAF_CMD_SOURCE_INIT(RicTileWindowsFeature, "RicTileWindowsFeature");
//--------------------------------------------------------------------------------------------------
bool RicTileWindowsFeature::isCommandEnabled()
{
return true;
return RiuMainWindow::instance()->isAnyMdiSubWindowVisible();
}
//--------------------------------------------------------------------------------------------------

View File

@ -121,13 +121,9 @@ RiuMainWindow::RiuMainWindow()
sm_mainWindowInstance = this;
slotRefreshFileActions();
slotRefreshEditActions();
m_dragDrop = new RiuDragDrop;
// Set pdm root so scripts are displayed
setPdmRoot(RiaApplication::instance()->project());
initializeGuiNewProjectLoaded();
// Enabling the line below will activate the undo stack
// When enableUndoCommandSystem is set false, all commands are executed and deleted immediately
@ -553,8 +549,6 @@ void RiuMainWindow::createToolBars()
refreshAnimationActions();
refreshDrawStyleActions();
cmdFeatureMgr->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
}
@ -766,6 +760,8 @@ void RiuMainWindow::slotRefreshViewActions()
m_viewFromBelow->setEnabled(enabled);
updateScaleValue();
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature");
}
//--------------------------------------------------------------------------------------------------
@ -1165,7 +1161,7 @@ void RiuMainWindow::removeViewer(QWidget* viewer)
{
m_mdiArea->removeSubWindow( findMdiSubWindow(viewer));
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
slotRefreshViewActions();
}
@ -1178,6 +1174,11 @@ public:
{
}
~RiuMdiSubWindow()
{
RiuMainWindow::instance()->slotRefreshViewActions();
}
protected:
virtual void closeEvent(QCloseEvent* event)
{
@ -1242,7 +1243,7 @@ void RiuMainWindow::addViewer(QWidget* viewer, const std::vector<int>& windowsGe
}
}
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
slotRefreshViewActions();
}
//--------------------------------------------------------------------------------------------------
@ -2240,3 +2241,11 @@ void RiuMainWindow::tileWindows()
m_mdiArea->tileSubWindows();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMainWindow::isAnyMdiSubWindowVisible()
{
return m_mdiArea->subWindowList().size() > 0;
}

View File

@ -113,6 +113,7 @@ public:
std::vector<int> windowGeometryForWidget(QWidget* widget);
void tileWindows();
bool isAnyMdiSubWindowVisible();
protected:
virtual void closeEvent(QCloseEvent* event);
@ -208,6 +209,8 @@ private:
// Menu and action slots
private slots:
friend class RiuMdiSubWindow;
// File slots
void slotImportGeoMechModel();
void slotOpenProject();