mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4890 Window tiling
This commit is contained in:
@@ -1209,6 +1209,9 @@ void RiaGuiApplication::onProjectBeingOpened()
|
||||
{
|
||||
// When importing a project, do not maximize the first MDI window to be created
|
||||
m_maximizeWindowGuard = std::make_unique<RiuMdiMaximizeWindowGuard>();
|
||||
|
||||
m_mainWindow->setBlockSubWindowActivatedSignal( true );
|
||||
if ( mainPlotWindow() ) mainPlotWindow()->setBlockSubWindowActivatedSignal( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1269,6 +1272,9 @@ void RiaGuiApplication::onProjectOpened()
|
||||
|
||||
processEvents();
|
||||
|
||||
m_mainWindow->setBlockSubWindowActivatedSignal( false );
|
||||
if ( mainPlotWindow() ) mainPlotWindow()->setBlockSubWindowActivatedSignal( false );
|
||||
|
||||
// Make sure to process events before this function to avoid strange Qt crash
|
||||
RiuPlotMainWindowTools::refreshToolbars();
|
||||
}
|
||||
|
@@ -76,6 +76,17 @@ void caf::AppEnum<RiaDefines::Orientation>::setUp()
|
||||
setDefault( RiaDefines::Orientation::VERTICAL );
|
||||
}
|
||||
|
||||
template <>
|
||||
void caf::AppEnum<RiaDefines::WindowTileMode>::setUp()
|
||||
{
|
||||
addItem( RiaDefines::WindowTileMode::DEFAULT, "DEFAULT", "Default" );
|
||||
addItem( RiaDefines::WindowTileMode::VERTICAL, "VERTICAL", "Vertical" );
|
||||
addItem( RiaDefines::WindowTileMode::HORIZONTAL, "HORIZONTAL", "Horizontal" );
|
||||
addItem( RiaDefines::WindowTileMode::UNDEFINED, "UNDEFINED", "Undefined" );
|
||||
|
||||
setDefault( RiaDefines::WindowTileMode::UNDEFINED );
|
||||
}
|
||||
|
||||
}; // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -73,6 +73,14 @@ enum class ObjectNamingMethod
|
||||
TEMPLATE
|
||||
};
|
||||
|
||||
enum class WindowTileMode
|
||||
{
|
||||
DEFAULT,
|
||||
VERTICAL,
|
||||
HORIZONTAL,
|
||||
UNDEFINED,
|
||||
};
|
||||
|
||||
// Defines relate to curve and plot template names
|
||||
QString namingVariableCase();
|
||||
QString namingVariableWell();
|
||||
|
@@ -20,7 +20,11 @@
|
||||
#include "RicTileWindowsFeature.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuMdiArea.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include <QAction>
|
||||
@@ -28,12 +32,31 @@
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTileWindowsFeature, "RicTileWindowsFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTileWindowsFeature::applyTiling( RiuMainWindowBase* mainWindow, RiaDefines::WindowTileMode requestedTileMode )
|
||||
{
|
||||
auto mode = requestedTileMode;
|
||||
|
||||
// If requested mode is set, reset tiling mode to undefined
|
||||
if ( RimProject::current()->subWindowsTileMode3DWindow() == requestedTileMode )
|
||||
mode = RiaDefines::WindowTileMode::UNDEFINED;
|
||||
|
||||
RimProject::current()->setSubWindowsTileMode3DWindow( mode );
|
||||
|
||||
if ( mainWindow )
|
||||
{
|
||||
mainWindow->mdiArea()->applyTiling();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsFeature::isCommandEnabled()
|
||||
{
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
auto* mainWindow = RiuMainWindow::instance();
|
||||
if ( mainWindow )
|
||||
{
|
||||
return mainWindow->isAnyMdiSubWindowVisible();
|
||||
@@ -49,18 +72,8 @@ void RicTileWindowsFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
if ( mainWindow )
|
||||
{
|
||||
if ( !mainWindow->subWindowsAreTiled() )
|
||||
{
|
||||
mainWindow->tileSubWindows();
|
||||
}
|
||||
else
|
||||
{
|
||||
mainWindow->clearWindowTiling();
|
||||
}
|
||||
}
|
||||
auto* mainWindow = RiuMainWindow::instance();
|
||||
applyTiling( mainWindow, RiaDefines::WindowTileMode::DEFAULT );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -78,11 +91,7 @@ void RicTileWindowsFeature::setupActionLook( QAction* actionToSetup )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsFeature::isCommandChecked()
|
||||
{
|
||||
if ( RiaGuiApplication::instance()->mainWindow() )
|
||||
{
|
||||
return RiaGuiApplication::instance()->mainWindow()->subWindowsAreTiled();
|
||||
}
|
||||
return false;
|
||||
return RimProject::current()->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature" );
|
||||
@@ -106,18 +115,10 @@ bool RicTilePlotWindowsFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTilePlotWindowsFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
if ( mainPlotWindow )
|
||||
{
|
||||
if ( !mainPlotWindow->subWindowsAreTiled() )
|
||||
{
|
||||
mainPlotWindow->tileSubWindows();
|
||||
}
|
||||
else
|
||||
{
|
||||
mainPlotWindow->clearWindowTiling();
|
||||
}
|
||||
}
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
auto* mainWindow = RiuPlotMainWindow::instance();
|
||||
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::DEFAULT );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -135,9 +136,187 @@ void RicTilePlotWindowsFeature::setupActionLook( QAction* actionToSetup )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsFeature::isCommandChecked()
|
||||
{
|
||||
if ( RiaGuiApplication::instance()->mainPlotWindow() )
|
||||
return RimProject::current()->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTileWindowsVerticallyFeature, "RicTileWindowsVerticallyFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsVerticallyFeature::isCommandEnabled()
|
||||
{
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
if ( mainWindow )
|
||||
{
|
||||
return RiaGuiApplication::instance()->mainPlotWindow()->subWindowsAreTiled();
|
||||
return mainWindow->isAnyMdiSubWindowVisible();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTileWindowsVerticallyFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
auto* mainWindow = RiuMainWindow::instance();
|
||||
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::VERTICAL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTileWindowsVerticallyFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Tile Windows Vertically" );
|
||||
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsVerticallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::VERTICAL;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTileWindowsHorizontallyFeature, "RicTileWindowsHorizontallyFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsHorizontallyFeature::isCommandEnabled()
|
||||
{
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
if ( mainWindow )
|
||||
{
|
||||
return mainWindow->isAnyMdiSubWindowVisible();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTileWindowsHorizontallyFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
auto* mainWindow = RiuMainWindow::instance();
|
||||
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::HORIZONTAL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTileWindowsHorizontallyFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Tile Windows Horizontally" );
|
||||
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsHorizontallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// Main Plot window features
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsVerticallyFeature, "RicTilePlotWindowsVerticallyFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsVerticallyFeature::isCommandEnabled()
|
||||
{
|
||||
auto* mainWindow = RiuPlotMainWindow::instance();
|
||||
if ( mainWindow )
|
||||
{
|
||||
return mainWindow->isAnyMdiSubWindowVisible();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTilePlotWindowsVerticallyFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
auto* mainWindow = RiuPlotMainWindow::instance();
|
||||
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::VERTICAL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTilePlotWindowsVerticallyFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Tile Windows Vertically" );
|
||||
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsVerticallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::VERTICAL;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsHorizontallyFeature, "RicTilePlotWindowsHorizontallyFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsHorizontallyFeature::isCommandEnabled()
|
||||
{
|
||||
auto* mainWindow = RiuPlotMainWindow::instance();
|
||||
if ( mainWindow )
|
||||
{
|
||||
return mainWindow->isAnyMdiSubWindowVisible();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTilePlotWindowsHorizontallyFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
auto* mainWindow = RiuPlotMainWindow::instance();
|
||||
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::HORIZONTAL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTilePlotWindowsHorizontallyFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Tile Windows Horizontally" );
|
||||
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsHorizontallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
}
|
||||
|
@@ -19,8 +19,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RiuMainWindowBase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
@@ -28,6 +32,37 @@ class RicTileWindowsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void applyTiling( RiuMainWindowBase* mainWindow, RiaDefines::WindowTileMode requestedTileMode );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
bool isCommandChecked() override;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicTileWindowsVerticallyFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
bool isCommandChecked() override;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicTileWindowsHorizontallyFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
@@ -48,3 +83,31 @@ protected:
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
bool isCommandChecked() override;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicTilePlotWindowsVerticallyFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
bool isCommandChecked() override;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicTilePlotWindowsHorizontallyFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
bool isCommandChecked() override;
|
||||
};
|
||||
|
@@ -225,8 +225,6 @@ void RicPlotProductionRateFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
mainPlotWindow->selectAsCurrentItem( summaryPlotToSelect );
|
||||
mainPlotWindow->setExpanded( summaryPlotToSelect );
|
||||
|
||||
mainPlotWindow->tileSubWindows();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -187,11 +187,11 @@ RimProject::RimProject( void )
|
||||
CAF_PDM_InitField( &m_showPlotWindow, "showPlotWindow", false, "Show Plot Window" );
|
||||
m_showPlotWindow.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_subWindowsTiled3DWindow, "tiled3DWindow", false, "Tile 3D Window" );
|
||||
m_subWindowsTiled3DWindow.uiCapability()->setUiHidden( true );
|
||||
CAF_PDM_InitField( &m_subWindowsTiled3DWindow_OBSOLETE, "tiled3DWindow", false, "Tile 3D Window" );
|
||||
m_subWindowsTiled3DWindow_OBSOLETE.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_subWindowsTiledPlotWindow, "tiledPlotWindow", false, "Tile Plot Window" );
|
||||
m_subWindowsTiledPlotWindow.uiCapability()->setUiHidden( true );
|
||||
CAF_PDM_InitField( &m_subWindowsTiledPlotWindow_OBSOLETE, "tiledPlotWindow", false, "Tile Plot Window" );
|
||||
m_subWindowsTiledPlotWindow_OBSOLETE.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_dialogData, "DialogData", "DialogData" );
|
||||
m_dialogData = new RimDialogData();
|
||||
@@ -205,6 +205,11 @@ RimProject::RimProject( void )
|
||||
CAF_PDM_InitFieldNoDefault( &caseGroupsObsolete, "CaseGroups", "" );
|
||||
RiaFieldHandleTools::disableWriteAndSetFieldHidden( &caseGroupsObsolete );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_subWindowsTileMode3DWindow, "TileMode3DWindow", "TileMode3DWindow" );
|
||||
m_subWindowsTileMode3DWindow.uiCapability()->setUiHidden( true );
|
||||
CAF_PDM_InitFieldNoDefault( &m_subWindowsTileModePlotWindow, "TileModePlotWindow", "TileModePlotWindow" );
|
||||
m_subWindowsTileModePlotWindow.uiCapability()->setUiHidden( true );
|
||||
|
||||
// Initialization
|
||||
|
||||
scriptCollection = new RimScriptCollection();
|
||||
@@ -340,6 +345,9 @@ void RimProject::initAfterRead()
|
||||
RimOilField* oilField = oilFields[oilFieldIdx];
|
||||
if ( oilField == nullptr || oilField->wellPathCollection == nullptr ) continue;
|
||||
}
|
||||
|
||||
if ( m_subWindowsTiled3DWindow_OBSOLETE ) m_subWindowsTileMode3DWindow = RiaDefines::WindowTileMode::DEFAULT;
|
||||
if ( m_subWindowsTiledPlotWindow_OBSOLETE ) m_subWindowsTileModePlotWindow = RiaDefines::WindowTileMode::DEFAULT;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -969,33 +977,33 @@ bool RimProject::showPlotWindow() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimProject::subWindowsTiled3DWindow() const
|
||||
RiaDefines::WindowTileMode RimProject::subWindowsTileMode3DWindow() const
|
||||
{
|
||||
return m_subWindowsTiled3DWindow;
|
||||
return m_subWindowsTileMode3DWindow();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimProject::subWindowsTiledPlotWindow() const
|
||||
RiaDefines::WindowTileMode RimProject::subWindowsTileModePlotWindow() const
|
||||
{
|
||||
return m_subWindowsTiledPlotWindow;
|
||||
return m_subWindowsTileModePlotWindow();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::setSubWindowsTiledIn3DWindow( bool tiled )
|
||||
void RimProject::setSubWindowsTileMode3DWindow( RiaDefines::WindowTileMode tileMode )
|
||||
{
|
||||
m_subWindowsTiled3DWindow = tiled;
|
||||
m_subWindowsTileMode3DWindow = tileMode;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::setSubWindowsTiledInPlotWindow( bool tiled )
|
||||
void RimProject::setSubWindowsTileModePlotWindow( RiaDefines::WindowTileMode tileMode )
|
||||
{
|
||||
m_subWindowsTiledPlotWindow = tiled;
|
||||
m_subWindowsTileModePlotWindow = tileMode;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
@@ -155,11 +156,10 @@ public:
|
||||
bool show3DWindow() const;
|
||||
bool showPlotWindow() const;
|
||||
|
||||
bool subWindowsTiled3DWindow() const;
|
||||
bool subWindowsTiledPlotWindow() const;
|
||||
|
||||
void setSubWindowsTiledIn3DWindow( bool tiled );
|
||||
void setSubWindowsTiledInPlotWindow( bool tiled );
|
||||
RiaDefines::WindowTileMode subWindowsTileMode3DWindow() const;
|
||||
RiaDefines::WindowTileMode subWindowsTileModePlotWindow() const;
|
||||
void setSubWindowsTileMode3DWindow( RiaDefines::WindowTileMode tileMode );
|
||||
void setSubWindowsTileModePlotWindow( RiaDefines::WindowTileMode tileMode );
|
||||
|
||||
void reloadCompletionTypeResultsInAllViews();
|
||||
void reloadCompletionTypeResultsForEclipseCase( RimEclipseCase* eclipseCase );
|
||||
@@ -220,8 +220,11 @@ private:
|
||||
caf::PdmField<bool> m_show3DWindow;
|
||||
caf::PdmField<bool> m_showPlotWindow;
|
||||
|
||||
caf::PdmField<bool> m_subWindowsTiled3DWindow;
|
||||
caf::PdmField<bool> m_subWindowsTiledPlotWindow;
|
||||
caf::PdmField<bool> m_subWindowsTiled3DWindow_OBSOLETE;
|
||||
caf::PdmField<bool> m_subWindowsTiledPlotWindow_OBSOLETE;
|
||||
|
||||
caf::PdmField<caf::AppEnum<RiaDefines::WindowTileMode>> m_subWindowsTileMode3DWindow;
|
||||
caf::PdmField<caf::AppEnum<RiaDefines::WindowTileMode>> m_subWindowsTileModePlotWindow;
|
||||
|
||||
int m_nextValidCaseId;
|
||||
int m_nextValidCaseGroupId;
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "RiuDockWidgetTools.h"
|
||||
#include "RiuMdiArea.h"
|
||||
#include "RiuMdiSubWindow.h"
|
||||
#include "RiuMessagePanel.h"
|
||||
#include "RiuMohrsCirclePlot.h"
|
||||
@@ -215,10 +216,7 @@ void RiuMainWindow::initializeGuiNewProjectLoaded()
|
||||
setPdmRoot( RimProject::current() );
|
||||
restoreTreeViewState();
|
||||
|
||||
if ( subWindowsAreTiled() )
|
||||
{
|
||||
tileSubWindows();
|
||||
}
|
||||
m_mdiArea->applyTiling();
|
||||
|
||||
slotRefreshFileActions();
|
||||
slotRefreshUndoRedoActions();
|
||||
@@ -1410,8 +1408,6 @@ void RiuMainWindow::slotBuildWindowActions()
|
||||
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
|
||||
m_windowMenu->addAction( cmdFeatureMgr->action( "RicShowPlotWindowFeature" ) );
|
||||
m_windowMenu->addSeparator();
|
||||
|
||||
m_windowMenu->addSeparator();
|
||||
}
|
||||
|
||||
addDefaultEntriesToWindowsMenu();
|
||||
@@ -1953,95 +1949,6 @@ void RiuMainWindow::customMenuRequested( const QPoint& pos )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::tileSubWindows()
|
||||
{
|
||||
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
|
||||
|
||||
// Tile Windows so the one with the leftmost left edge gets sorted first.
|
||||
std::list<QMdiSubWindow*> windowList;
|
||||
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
|
||||
{
|
||||
windowList.push_back( subWindow );
|
||||
}
|
||||
|
||||
// Perform stable sort of list so we first sort by window position but retain activation order
|
||||
// for windows with the same position.
|
||||
windowList.sort( [this]( QMdiSubWindow* lhs, QMdiSubWindow* rhs ) {
|
||||
if ( lhs->frameGeometry().topLeft().ry() == rhs->frameGeometry().topLeft().ry() )
|
||||
{
|
||||
return lhs->frameGeometry().topLeft().rx() < rhs->frameGeometry().topLeft().rx();
|
||||
}
|
||||
return lhs->frameGeometry().topLeft().ry() < rhs->frameGeometry().topLeft().ry();
|
||||
} );
|
||||
|
||||
// Based on workaround described here
|
||||
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
|
||||
|
||||
bool prevActivationBlock = isBlockingSubWindowActivatedSignal();
|
||||
|
||||
QMdiSubWindow* activeWindow = m_mdiArea->activeSubWindow();
|
||||
|
||||
// Force activation order so they end up in the order of the loop.
|
||||
m_mdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
|
||||
|
||||
setBlockSubWindowActivatedSignal( true );
|
||||
|
||||
// Activate in reverse order
|
||||
for ( auto it = windowList.rbegin(); it != windowList.rend(); ++it )
|
||||
{
|
||||
m_mdiArea->setActiveSubWindow( *it );
|
||||
}
|
||||
|
||||
m_mdiArea->tileSubWindows();
|
||||
// Set back the original activation order to avoid messing with the standard ordering
|
||||
m_mdiArea->setActivationOrder( currentActivationOrder );
|
||||
m_mdiArea->setActiveSubWindow( activeWindow );
|
||||
setBlockSubWindowActivatedSignal( prevActivationBlock );
|
||||
|
||||
storeSubWindowTiling( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::storeSubWindowTiling( bool tiled )
|
||||
{
|
||||
RimProject::current()->setSubWindowsTiledIn3DWindow( tiled );
|
||||
refreshViewActions();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::clearWindowTiling()
|
||||
{
|
||||
setBlockSubWindowActivatedSignal( true );
|
||||
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
|
||||
|
||||
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
|
||||
{
|
||||
subWindow->hide();
|
||||
subWindow->showNormal();
|
||||
}
|
||||
storeSubWindowTiling( false );
|
||||
setBlockSubWindowActivatedSignal( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuMainWindow::subWindowsAreTiled() const
|
||||
{
|
||||
if ( RimProject::current() )
|
||||
{
|
||||
return RimProject::current()->subWindowsTiled3DWindow();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2077,7 +1984,7 @@ QStringList RiuMainWindow::defaultDockStateNames()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* RiuMainWindow::tileSubWindowsAction()
|
||||
QStringList RiuMainWindow::windowsMenuFeatureNames()
|
||||
{
|
||||
return caf::CmdFeatureManager::instance()->action( "RicTileWindowsFeature" );
|
||||
return { "RicTileWindowsFeature", "RicTileWindowsVerticallyFeature", "RicTileWindowsHorizontallyFeature" };
|
||||
}
|
||||
|
@@ -21,12 +21,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "RiuMainWindowBase.h"
|
||||
#include "RiuMdiArea.h"
|
||||
|
||||
#include "cafPdmObjectHandle.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QLabel>
|
||||
#include <QMdiArea>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
@@ -51,6 +51,7 @@ class RiuResultQwtPlot;
|
||||
class RiuRelativePermeabilityPlotPanel;
|
||||
class RiuPvtPlotPanel;
|
||||
class RiuMohrsCirclePlot;
|
||||
class RiuMdiArea;
|
||||
|
||||
class RicGridCalculatorDialog;
|
||||
|
||||
@@ -115,11 +116,6 @@ public:
|
||||
|
||||
void refreshDrawStyleActions();
|
||||
|
||||
void tileSubWindows() override;
|
||||
void storeSubWindowTiling( bool tiled ) override;
|
||||
void clearWindowTiling() override;
|
||||
|
||||
bool subWindowsAreTiled() const override;
|
||||
bool isAnyMdiSubWindowVisible();
|
||||
QMdiSubWindow* findMdiSubWindow( QWidget* viewer ) override;
|
||||
RimViewWindow* findViewWindowFromSubWindow( QMdiSubWindow* lhs );
|
||||
@@ -140,7 +136,7 @@ public:
|
||||
protected:
|
||||
void closeEvent( QCloseEvent* event ) override;
|
||||
QStringList defaultDockStateNames() override;
|
||||
QAction* tileSubWindowsAction() override;
|
||||
QStringList windowsMenuFeatureNames() override;
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
|
@@ -58,7 +58,7 @@
|
||||
RiuMainWindowBase::RiuMainWindowBase()
|
||||
: m_allowActiveViewChangeFromSelection( true )
|
||||
, m_showFirstVisibleWindowMaximized( true )
|
||||
, m_blockSubWindowActivation( false )
|
||||
, m_blockSubWindowActivation( true )
|
||||
, m_blockSubWindowProjectTreeSelection( false )
|
||||
, m_windowMenu( nullptr )
|
||||
, m_mdiArea( nullptr )
|
||||
@@ -104,6 +104,14 @@ ads::CDockManager* RiuMainWindowBase::dockManager() const
|
||||
return m_dockManager;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMdiArea* RiuMainWindowBase::mdiArea()
|
||||
{
|
||||
return m_mdiArea;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -325,7 +333,7 @@ bool RiuMainWindowBase::isBlockingViewSelectionOnSubWindowActivated() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindowBase::removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* viewer )
|
||||
void RiuMainWindowBase::removeViewerFromMdiArea( RiuMdiArea* mdiArea, QWidget* viewer )
|
||||
{
|
||||
bool removedSubWindowWasActive = false;
|
||||
|
||||
@@ -362,10 +370,8 @@ void RiuMainWindowBase::removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* vie
|
||||
{
|
||||
mdiArea->currentSubWindow()->showMaximized();
|
||||
}
|
||||
else if ( subWindowsAreTiled() )
|
||||
{
|
||||
tileSubWindows();
|
||||
}
|
||||
|
||||
mdiArea->applyTiling();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,13 +406,14 @@ void RiuMainWindowBase::slotDockWidgetToggleViewActionTriggered()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindowBase::initializeSubWindow( QMdiArea* mdiArea,
|
||||
void RiuMainWindowBase::initializeSubWindow( RiuMdiArea* mdiArea,
|
||||
QMdiSubWindow* mdiSubWindow,
|
||||
const QPoint& subWindowPos,
|
||||
const QSize& subWindowSize )
|
||||
{
|
||||
bool initialStateTiled = subWindowsAreTiled();
|
||||
bool initialStateMaximized = false;
|
||||
bool initialStateMaximized = false;
|
||||
auto initialState3dWindow = RimProject::current()->subWindowsTileMode3DWindow();
|
||||
auto initialStatePlotWindow = RimProject::current()->subWindowsTileModePlotWindow();
|
||||
|
||||
if ( m_showFirstVisibleWindowMaximized && mdiArea->subWindowList().empty() )
|
||||
{
|
||||
@@ -434,10 +441,14 @@ void RiuMainWindowBase::initializeSubWindow( QMdiArea* mdiArea,
|
||||
else
|
||||
{
|
||||
mdiSubWindow->showNormal();
|
||||
if ( initialStateTiled )
|
||||
|
||||
if ( !isBlockingSubWindowActivatedSignal() )
|
||||
{
|
||||
tileSubWindows();
|
||||
RimProject::current()->setSubWindowsTileMode3DWindow( initialState3dWindow );
|
||||
RimProject::current()->setSubWindowsTileModePlotWindow( initialStatePlotWindow );
|
||||
}
|
||||
|
||||
mdiArea->applyTiling();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,7 +764,14 @@ void RiuMainWindowBase::addDefaultEntriesToWindowsMenu()
|
||||
QAction* closeAllSubWindowsAction = new QAction( "Close All Windows", this );
|
||||
connect( closeAllSubWindowsAction, SIGNAL( triggered() ), m_mdiArea, SLOT( closeAllSubWindows() ) );
|
||||
|
||||
m_windowMenu->addAction( tileSubWindowsAction() );
|
||||
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
|
||||
|
||||
auto featureNames = windowsMenuFeatureNames();
|
||||
for ( const auto& name : featureNames )
|
||||
{
|
||||
m_windowMenu->addAction( cmdFeatureMgr->action( name ) );
|
||||
}
|
||||
|
||||
m_windowMenu->addAction( cascadeWindowsAction );
|
||||
m_windowMenu->addAction( closeAllSubWindowsAction );
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class QMdiArea;
|
||||
class RiuMdiArea;
|
||||
struct RimMdiWindowGeometry;
|
||||
|
||||
class RiuMdiArea;
|
||||
@@ -83,11 +83,6 @@ public:
|
||||
|
||||
void enableShowFirstVisibleMdiWindowMaximized( bool enable );
|
||||
|
||||
virtual void tileSubWindows() = 0;
|
||||
virtual void storeSubWindowTiling( bool tiled ) = 0;
|
||||
virtual void clearWindowTiling() = 0;
|
||||
virtual bool subWindowsAreTiled() const = 0;
|
||||
|
||||
void setBlockSubWindowActivatedSignal( bool block );
|
||||
bool isBlockingSubWindowActivatedSignal() const;
|
||||
|
||||
@@ -96,10 +91,12 @@ public:
|
||||
|
||||
ads::CDockManager* dockManager() const;
|
||||
|
||||
RiuMdiArea* mdiArea();
|
||||
|
||||
protected:
|
||||
void createTreeViews( int numberOfTrees );
|
||||
void removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* viewer );
|
||||
void initializeSubWindow( QMdiArea* mdiArea,
|
||||
void removeViewerFromMdiArea( RiuMdiArea* mdiArea, QWidget* viewer );
|
||||
void initializeSubWindow( RiuMdiArea* mdiArea,
|
||||
QMdiSubWindow* mdiSubWindow,
|
||||
const QPoint& subWindowPos,
|
||||
const QSize& subWindowSize );
|
||||
@@ -114,7 +111,7 @@ protected:
|
||||
|
||||
virtual QStringList defaultDockStateNames() = 0;
|
||||
|
||||
virtual QAction* tileSubWindowsAction() = 0;
|
||||
virtual QStringList windowsMenuFeatureNames() = 0;
|
||||
|
||||
protected slots:
|
||||
void slotDockWidgetToggleViewActionTriggered();
|
||||
|
@@ -15,8 +15,11 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuMdiArea.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuMdiSubWindow.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
@@ -36,6 +39,20 @@ RiuMdiArea::~RiuMdiArea()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaDefines::WindowTileMode RiuMdiArea::tileMode() const
|
||||
{
|
||||
auto* mainWindow = dynamic_cast<RiuMainWindow*>( window() );
|
||||
if ( mainWindow ) return RimProject::current()->subWindowsTileMode3DWindow();
|
||||
|
||||
auto* plotMainWindow = dynamic_cast<RiuPlotMainWindow*>( window() );
|
||||
if ( plotMainWindow ) return RimProject::current()->subWindowsTileModePlotWindow();
|
||||
|
||||
return RiaDefines::WindowTileMode::UNDEFINED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -63,55 +80,134 @@ std::list<QMdiSubWindow*> RiuMdiArea::subWindowListSortedByPosition()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMdiArea::resizeEvent( QResizeEvent* resizeEvent )
|
||||
std::list<QMdiSubWindow*> RiuMdiArea::subWindowListSortedByVerticalPosition()
|
||||
{
|
||||
if ( subWindowsAreTiled() )
|
||||
std::list<QMdiSubWindow*> windowList;
|
||||
for ( QMdiSubWindow* subWindow : subWindowList( QMdiArea::CreationOrder ) )
|
||||
{
|
||||
for ( auto subWindow : subWindowList() )
|
||||
{
|
||||
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
|
||||
riuWindow->blockTilingChanges( true );
|
||||
}
|
||||
|
||||
RiuMainWindowBase* mainWindow = dynamic_cast<RiuMainWindowBase*>( window() );
|
||||
mainWindow->setBlockSubWindowActivatedSignal( true );
|
||||
|
||||
// Workaround for Qt bug #51761: https://bugreports.qt.io/browse/QTBUG-51761
|
||||
// Set the first window to be the active window then perform resize event and set back.
|
||||
auto a = activeSubWindow();
|
||||
setActiveSubWindow( subWindowListSortedByPosition().front() );
|
||||
|
||||
QMdiArea::resizeEvent( resizeEvent );
|
||||
tileSubWindows();
|
||||
|
||||
setActiveSubWindow( a );
|
||||
|
||||
mainWindow->setBlockSubWindowActivatedSignal( false );
|
||||
|
||||
for ( auto subWindow : subWindowList() )
|
||||
{
|
||||
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
|
||||
riuWindow->blockTilingChanges( false );
|
||||
}
|
||||
windowList.push_back( subWindow );
|
||||
}
|
||||
else
|
||||
|
||||
windowList.sort( [this]( QMdiSubWindow* lhs, QMdiSubWindow* rhs ) {
|
||||
if ( lhs->frameGeometry().topLeft().ry() == rhs->frameGeometry().topLeft().ry() )
|
||||
{
|
||||
return lhs->frameGeometry().topLeft().rx() < rhs->frameGeometry().topLeft().rx();
|
||||
}
|
||||
return lhs->frameGeometry().topLeft().ry() < rhs->frameGeometry().topLeft().ry();
|
||||
} );
|
||||
|
||||
return windowList;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMdiArea::tileWindowsHorizontally()
|
||||
{
|
||||
QPoint position( 0, 0 );
|
||||
|
||||
for ( auto* window : subWindowListSortedByPosition() )
|
||||
{
|
||||
QMdiArea::resizeEvent( resizeEvent );
|
||||
QRect rect( 0, 0, width() / static_cast<int>( subWindowListSortedByPosition().size() ), height() );
|
||||
|
||||
window->setGeometry( rect );
|
||||
window->move( position );
|
||||
position.setX( position.x() + window->width() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMdiArea::moveEvent( QMoveEvent* event )
|
||||
void RiuMdiArea::tileWindowsVertically()
|
||||
{
|
||||
auto windowList = subWindowListSortedByVerticalPosition();
|
||||
|
||||
QPoint position( 0, 0 );
|
||||
for ( auto* window : windowList )
|
||||
{
|
||||
QRect rect( 0, 0, width(), height() / static_cast<int>( windowList.size() ) );
|
||||
|
||||
window->setGeometry( rect );
|
||||
window->move( position );
|
||||
position.setY( position.y() + window->height() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMdiArea::tileWindowsDefault()
|
||||
{
|
||||
// Workaround for Qt bug #51761: https://bugreports.qt.io/browse/QTBUG-51761
|
||||
// Set the first window to be the active window then perform resize event and set back.
|
||||
auto a = activeSubWindow();
|
||||
setActiveSubWindow( subWindowListSortedByPosition().front() );
|
||||
|
||||
// QMdiArea::resizeEvent( resizeEvent );
|
||||
tileSubWindows();
|
||||
|
||||
setActiveSubWindow( a );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMdiArea::resizeEvent( QResizeEvent* resizeEvent )
|
||||
{
|
||||
applyTiling();
|
||||
|
||||
QMdiArea::resizeEvent( resizeEvent );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMdiArea::applyTiling()
|
||||
{
|
||||
QMdiArea::WindowOrder currentActivationOrder = activationOrder();
|
||||
|
||||
for ( auto subWindow : subWindowList() )
|
||||
{
|
||||
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
|
||||
riuWindow->blockTilingChanges( true );
|
||||
}
|
||||
|
||||
QMdiArea::moveEvent( event );
|
||||
auto windowList = subWindowListSortedByPosition();
|
||||
|
||||
QMdiSubWindow* activeWindow = activeSubWindow();
|
||||
|
||||
// Force activation order so they end up in the order of the loop.
|
||||
setActivationOrder( QMdiArea::ActivationHistoryOrder );
|
||||
|
||||
// setBlockSubWindowActivatedSignal( true );
|
||||
|
||||
// Activate in reverse order
|
||||
for ( auto it = windowList.rbegin(); it != windowList.rend(); ++it )
|
||||
{
|
||||
setActiveSubWindow( *it );
|
||||
}
|
||||
|
||||
switch ( tileMode() )
|
||||
{
|
||||
case RiaDefines::WindowTileMode::UNDEFINED:
|
||||
break;
|
||||
case RiaDefines::WindowTileMode::DEFAULT:
|
||||
tileWindowsDefault();
|
||||
break;
|
||||
case RiaDefines::WindowTileMode::VERTICAL:
|
||||
tileWindowsVertically();
|
||||
break;
|
||||
case RiaDefines::WindowTileMode::HORIZONTAL:
|
||||
tileWindowsHorizontally();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Set back the original activation order to avoid messing with the standard ordering
|
||||
setActivationOrder( currentActivationOrder );
|
||||
setActiveSubWindow( activeWindow );
|
||||
|
||||
for ( auto subWindow : subWindowList() )
|
||||
{
|
||||
@@ -119,26 +215,3 @@ void RiuMdiArea::moveEvent( QMoveEvent* event )
|
||||
riuWindow->blockTilingChanges( false );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuMdiArea::subWindowsAreTiled() const
|
||||
{
|
||||
RiuMainWindow* mainWindow = dynamic_cast<RiuMainWindow*>( window() );
|
||||
|
||||
if ( mainWindow )
|
||||
{
|
||||
return mainWindow->subWindowsAreTiled() && subWindowList().size() > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindow* plotWindow = dynamic_cast<RiuPlotMainWindow*>( window() );
|
||||
if ( plotWindow )
|
||||
{
|
||||
return plotWindow->subWindowsAreTiled() && subWindowList().size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -18,8 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMdiArea>
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include <QMdiArea>
|
||||
#include <list>
|
||||
|
||||
class QMdiSubWindow;
|
||||
@@ -32,11 +33,16 @@ public:
|
||||
RiuMdiArea( QWidget* parent = nullptr );
|
||||
~RiuMdiArea() override;
|
||||
|
||||
std::list<QMdiSubWindow*> subWindowListSortedByPosition();
|
||||
RiaDefines::WindowTileMode tileMode() const;
|
||||
void applyTiling();
|
||||
|
||||
protected:
|
||||
private:
|
||||
void resizeEvent( QResizeEvent* resizeEvent ) override;
|
||||
void moveEvent( QMoveEvent* event ) override;
|
||||
|
||||
bool subWindowsAreTiled() const;
|
||||
std::list<QMdiSubWindow*> subWindowListSortedByPosition();
|
||||
std::list<QMdiSubWindow*> subWindowListSortedByVerticalPosition();
|
||||
|
||||
void tileWindowsHorizontally();
|
||||
void tileWindowsVertically();
|
||||
void tileWindowsDefault();
|
||||
};
|
||||
|
@@ -19,8 +19,10 @@
|
||||
#include "RiuMdiSubWindow.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
@@ -30,8 +32,6 @@
|
||||
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -128,17 +128,7 @@ void RiuMdiSubWindow::resizeEvent( QResizeEvent* resizeEvent )
|
||||
m_normalWindowGeometry = frameGeometry();
|
||||
}
|
||||
|
||||
if ( !m_blockTilingChanges )
|
||||
{
|
||||
if ( window() == RiaGuiApplication::instance()->mainWindow() )
|
||||
{
|
||||
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling( false );
|
||||
}
|
||||
else if ( window() == RiaGuiApplication::instance()->mainPlotWindow() )
|
||||
{
|
||||
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling( false );
|
||||
}
|
||||
}
|
||||
checkAndResetTilingState();
|
||||
|
||||
QMdiSubWindow::resizeEvent( resizeEvent );
|
||||
}
|
||||
@@ -153,17 +143,26 @@ void RiuMdiSubWindow::moveEvent( QMoveEvent* moveEvent )
|
||||
m_normalWindowGeometry = frameGeometry();
|
||||
}
|
||||
|
||||
if ( !m_blockTilingChanges )
|
||||
{
|
||||
if ( window() == RiaGuiApplication::instance()->mainWindow() )
|
||||
{
|
||||
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling( false );
|
||||
}
|
||||
else if ( window() == RiaGuiApplication::instance()->mainPlotWindow() )
|
||||
{
|
||||
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling( false );
|
||||
}
|
||||
}
|
||||
checkAndResetTilingState();
|
||||
|
||||
QMdiSubWindow::moveEvent( moveEvent );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMdiSubWindow::checkAndResetTilingState()
|
||||
{
|
||||
if ( m_blockTilingChanges ) return;
|
||||
|
||||
if ( window() == RiaGuiApplication::instance()->mainWindow() &&
|
||||
!RiaGuiApplication::instance()->mainWindow()->isBlockingSubWindowActivatedSignal() )
|
||||
{
|
||||
RimProject::current()->setSubWindowsTileMode3DWindow( RiaDefines::WindowTileMode::UNDEFINED );
|
||||
}
|
||||
else if ( window() == RiaGuiApplication::instance()->mainPlotWindow() &&
|
||||
!RiaGuiApplication::instance()->mainPlotWindow()->isBlockingSubWindowActivatedSignal() )
|
||||
{
|
||||
RimProject::current()->setSubWindowsTileModePlotWindow( RiaDefines::WindowTileMode::UNDEFINED );
|
||||
}
|
||||
}
|
||||
|
@@ -33,11 +33,13 @@ public:
|
||||
|
||||
void blockTilingChanges( bool block );
|
||||
|
||||
protected:
|
||||
private:
|
||||
void closeEvent( QCloseEvent* event ) override;
|
||||
void resizeEvent( QResizeEvent* resizeEvent ) override;
|
||||
void moveEvent( QMoveEvent* moveEvent ) override;
|
||||
|
||||
void checkAndResetTilingState();
|
||||
|
||||
private:
|
||||
QRect m_normalWindowGeometry;
|
||||
bool m_blockTilingChanges;
|
||||
|
@@ -50,6 +50,7 @@
|
||||
|
||||
#include "RiuDockWidgetTools.h"
|
||||
#include "RiuDragDrop.h"
|
||||
#include "RiuMdiArea.h"
|
||||
#include "RiuMdiSubWindow.h"
|
||||
#include "RiuMessagePanel.h"
|
||||
#include "RiuMultiPlotPage.h"
|
||||
@@ -198,10 +199,7 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded()
|
||||
}
|
||||
}
|
||||
|
||||
if ( subWindowsAreTiled() )
|
||||
{
|
||||
tileSubWindows();
|
||||
}
|
||||
m_mdiArea->applyTiling();
|
||||
|
||||
if ( m_activePlotViewWindow && m_activePlotViewWindow->viewWidget() &&
|
||||
!RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
|
||||
@@ -1061,91 +1059,6 @@ void RiuPlotMainWindow::customMenuRequested( const QPoint& pos )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindow::tileSubWindows()
|
||||
{
|
||||
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
|
||||
|
||||
std::list<QMdiSubWindow*> windowList;
|
||||
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
|
||||
{
|
||||
windowList.push_back( subWindow );
|
||||
}
|
||||
|
||||
// Perform stable sort of list so we first sort by window position but retain activation order
|
||||
// for windows with the same position.
|
||||
windowList.sort( []( const QMdiSubWindow* lhs, const QMdiSubWindow* rhs ) {
|
||||
if ( lhs->frameGeometry().topLeft().ry() == rhs->frameGeometry().topLeft().ry() )
|
||||
{
|
||||
return lhs->frameGeometry().topLeft().rx() < rhs->frameGeometry().topLeft().rx();
|
||||
}
|
||||
return lhs->frameGeometry().topLeft().ry() < rhs->frameGeometry().topLeft().ry();
|
||||
} );
|
||||
|
||||
// Based on workaround described here
|
||||
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
|
||||
|
||||
bool prevActivationBlock = isBlockingSubWindowActivatedSignal();
|
||||
// Force activation order so they end up in the order of the loop.
|
||||
m_mdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
|
||||
QMdiSubWindow* a = m_mdiArea->activeSubWindow();
|
||||
|
||||
setBlockSubWindowActivatedSignal( true );
|
||||
// Activate in reverse order
|
||||
for ( auto it = windowList.rbegin(); it != windowList.rend(); ++it )
|
||||
{
|
||||
m_mdiArea->setActiveSubWindow( *it );
|
||||
}
|
||||
|
||||
m_mdiArea->tileSubWindows();
|
||||
// Set back the original activation order to avoid messing with the standard ordering
|
||||
m_mdiArea->setActivationOrder( currentActivationOrder );
|
||||
m_mdiArea->setActiveSubWindow( a );
|
||||
setBlockSubWindowActivatedSignal( prevActivationBlock );
|
||||
|
||||
storeSubWindowTiling( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindow::storeSubWindowTiling( bool tiled )
|
||||
{
|
||||
RimProject::current()->setSubWindowsTiledInPlotWindow( tiled );
|
||||
refreshToolbars();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindow::clearWindowTiling()
|
||||
{
|
||||
setBlockSubWindowActivatedSignal( true );
|
||||
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
|
||||
|
||||
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
|
||||
{
|
||||
subWindow->hide();
|
||||
subWindow->showNormal();
|
||||
}
|
||||
storeSubWindowTiling( false );
|
||||
setBlockSubWindowActivatedSignal( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuPlotMainWindow::subWindowsAreTiled() const
|
||||
{
|
||||
if ( RimProject::current() )
|
||||
{
|
||||
return RimProject::current()->subWindowsTiledPlotWindow();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1187,6 +1100,14 @@ QStringList RiuPlotMainWindow::defaultDockStateNames()
|
||||
return retList;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RiuPlotMainWindow::windowsMenuFeatureNames()
|
||||
{
|
||||
return { "RicTilePlotWindowsFeature", "RicTilePlotWindowsVerticallyFeature", "RicTilePlotWindowsHorizontallyFeature" };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1210,11 +1131,3 @@ void RiuPlotMainWindow::slotToggleSelectionLink()
|
||||
{
|
||||
m_selection3DLinkEnabled = !m_selection3DLinkEnabled;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QAction* RiuPlotMainWindow::tileSubWindowsAction()
|
||||
{
|
||||
return caf::CmdFeatureManager::instance()->action( "RicTilePlotWindowsFeature" );
|
||||
}
|
||||
|
@@ -19,10 +19,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "RiuMainWindowBase.h"
|
||||
#include "RiuMdiArea.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <QMdiArea>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
@@ -76,11 +76,6 @@ public:
|
||||
void enable3DSelectionLink( bool enable );
|
||||
bool selection3DLinkEnabled();
|
||||
|
||||
void tileSubWindows() override;
|
||||
void storeSubWindowTiling( bool tiled ) override;
|
||||
void clearWindowTiling() override;
|
||||
bool subWindowsAreTiled() const override;
|
||||
|
||||
bool isAnyMdiSubWindowVisible();
|
||||
QMdiSubWindow* findMdiSubWindow( QWidget* viewer ) override;
|
||||
RimViewWindow* findViewWindowFromSubWindow( QMdiSubWindow* subWindow );
|
||||
@@ -106,7 +101,7 @@ protected:
|
||||
void dropEvent( QDropEvent* event ) override;
|
||||
|
||||
QStringList defaultDockStateNames() override;
|
||||
QAction* tileSubWindowsAction() override;
|
||||
QStringList windowsMenuFeatureNames() override;
|
||||
|
||||
private:
|
||||
void setPdmRoot( caf::PdmObject* pdmRoot );
|
||||
|
Reference in New Issue
Block a user