mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#946 Fixed enabled state for tile window toolbar button
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include "RiaApplication.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicTileWindowsFeature, "RicTileWindowsFeature");
|
||||
|
||||
@@ -32,18 +33,11 @@ CAF_CMD_SOURCE_INIT(RicTileWindowsFeature, "RicTileWindowsFeature");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsFeature::isCommandEnabled()
|
||||
{
|
||||
QWidget* topLevelWidget = QApplication::activeWindow();
|
||||
|
||||
RiuMainWindow* mainWindow = dynamic_cast<RiuMainWindow*>(topLevelWidget);
|
||||
RiuMainPlotWindow* mainPlotWindow = dynamic_cast<RiuMainPlotWindow*>(topLevelWidget);
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
if (mainWindow)
|
||||
{
|
||||
return mainWindow->isAnyMdiSubWindowVisible();
|
||||
}
|
||||
else if (mainPlotWindow)
|
||||
{
|
||||
return mainPlotWindow->isAnyMdiSubWindowVisible();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -53,18 +47,11 @@ bool RicTileWindowsFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTileWindowsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
QWidget* topLevelWidget = QApplication::activeWindow();
|
||||
|
||||
RiuMainWindow* mainWindow = dynamic_cast<RiuMainWindow*>(topLevelWidget);
|
||||
RiuMainPlotWindow* mainPlotWindow = dynamic_cast<RiuMainPlotWindow*>(topLevelWidget);
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
if (mainWindow)
|
||||
{
|
||||
mainWindow->tileWindows();
|
||||
}
|
||||
else if (mainPlotWindow)
|
||||
{
|
||||
mainPlotWindow->tileWindows();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -75,3 +62,42 @@ void RicTileWindowsFeature::setupActionLook(QAction* actionToSetup)
|
||||
actionToSetup->setText("Tile Windows");
|
||||
actionToSetup->setIcon(QIcon(":/TileWindows24x24.png"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsFeature::isCommandEnabled()
|
||||
{
|
||||
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
|
||||
if (mainPlotWindow)
|
||||
{
|
||||
return mainPlotWindow->isAnyMdiSubWindowVisible();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTilePlotWindowsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
|
||||
if (mainPlotWindow)
|
||||
{
|
||||
mainPlotWindow->tileWindows();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTilePlotWindowsFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Tile Windows");
|
||||
actionToSetup->setIcon(QIcon(":/TileWindows24x24.png"));
|
||||
}
|
||||
|
||||
@@ -36,4 +36,17 @@ protected:
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicTilePlotWindowsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered(bool isChecked);
|
||||
virtual void setupActionLook(QAction* actionToSetup);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user