mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-11 16:06:04 -06:00
Disable Zoom All if there's no active view.
* Makes it consistent with the other view actions.
This commit is contained in:
parent
ef15a98e3a
commit
80fe9f9fd5
@ -32,12 +32,32 @@
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicViewZoomAllFeature, "RicViewZoomAllFeature" );
|
||||
|
||||
RimViewWindow* activeViewWindow()
|
||||
{
|
||||
QWidget* topLevelWidget = RiaGuiApplication::activeWindow();
|
||||
|
||||
if ( dynamic_cast<RiuMainWindow*>( topLevelWidget ) )
|
||||
{
|
||||
return RiaGuiApplication::instance()->activeReservoirView();
|
||||
}
|
||||
else if ( dynamic_cast<RiuPlotMainWindow*>( topLevelWidget ) )
|
||||
{
|
||||
RiuPlotMainWindow* mainPlotWindow = dynamic_cast<RiuPlotMainWindow*>( topLevelWidget );
|
||||
QList<QMdiSubWindow*> subwindows = mainPlotWindow->subWindowList( QMdiArea::StackingOrder );
|
||||
if ( !subwindows.empty() )
|
||||
{
|
||||
return RiuInterfaceToViewWindow::viewWindowFromWidget( subwindows.back()->widget() );
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicViewZoomAllFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
return activeViewWindow() != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -47,29 +67,10 @@ void RicViewZoomAllFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
QWidget* topLevelWidget = RiaGuiApplication::activeWindow();
|
||||
|
||||
if ( dynamic_cast<RiuMainWindow*>( topLevelWidget ) )
|
||||
RimViewWindow* viewWindow = activeViewWindow();
|
||||
if ( viewWindow )
|
||||
{
|
||||
RimViewWindow* viewWindow = RiaGuiApplication::instance()->activeReservoirView();
|
||||
if ( viewWindow )
|
||||
{
|
||||
viewWindow->zoomAll();
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<RiuPlotMainWindow*>( topLevelWidget ) )
|
||||
{
|
||||
RiuPlotMainWindow* mainPlotWindow = dynamic_cast<RiuPlotMainWindow*>( topLevelWidget );
|
||||
QList<QMdiSubWindow*> subwindows = mainPlotWindow->subWindowList( QMdiArea::StackingOrder );
|
||||
if ( !subwindows.empty() )
|
||||
{
|
||||
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( subwindows.back()->widget() );
|
||||
|
||||
if ( viewWindow )
|
||||
{
|
||||
viewWindow->zoomAll();
|
||||
}
|
||||
}
|
||||
viewWindow->zoomAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user