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:
@@ -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" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user