Fix tiling issues for plot window

* Fix tiling for plot windows

Remove activation history restore related to a bug that was fixed in 5.12
https://bugreports.qt.io/browse/QTBUG-51761
This commit is contained in:
Magne Sjaastad 2022-11-14 18:50:07 +01:00 committed by GitHub
parent 647e248e04
commit 3b67719972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 35 deletions

View File

@ -35,7 +35,7 @@ CAF_CMD_SOURCE_INIT( RicTileWindowsFeature, "RicTileWindowsFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTileWindowsFeature::applyTiling( RiuMainWindowBase* mainWindow, RiaDefines::WindowTileMode requestedTileMode )
void RicTileWindowsFeature::applyTiling( RiuMainWindow* mainWindow, RiaDefines::WindowTileMode requestedTileMode )
{
auto mode = requestedTileMode;
@ -96,6 +96,25 @@ bool RicTileWindowsFeature::isCommandChecked()
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTilePlotWindowsFeature::applyTiling( RiuPlotMainWindow* mainWindow, RiaDefines::WindowTileMode requestedTileMode )
{
auto mode = requestedTileMode;
// If requested mode is set, reset tiling mode to undefined
if ( RimProject::current()->subWindowsTileModePlotWindow() == requestedTileMode )
mode = RiaDefines::WindowTileMode::UNDEFINED;
RimProject::current()->setSubWindowsTileModePlotWindow( mode );
if ( mainWindow )
{
mainWindow->mdiArea()->applyTiling();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -118,7 +137,7 @@ void RicTilePlotWindowsFeature::onActionTriggered( bool isChecked )
this->disableModelChangeContribution();
auto* mainWindow = RiuPlotMainWindow::instance();
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::DEFAULT );
RicTilePlotWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::DEFAULT );
}
//--------------------------------------------------------------------------------------------------
@ -257,7 +276,7 @@ void RicTilePlotWindowsVerticallyFeature::onActionTriggered( bool isChecked )
this->disableModelChangeContribution();
auto* mainWindow = RiuPlotMainWindow::instance();
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::VERTICAL );
RicTilePlotWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::VERTICAL );
}
//--------------------------------------------------------------------------------------------------
@ -301,7 +320,7 @@ void RicTilePlotWindowsHorizontallyFeature::onActionTriggered( bool isChecked )
this->disableModelChangeContribution();
auto* mainWindow = RiuPlotMainWindow::instance();
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::HORIZONTAL );
RicTilePlotWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::HORIZONTAL );
}
//--------------------------------------------------------------------------------------------------

View File

@ -23,7 +23,8 @@
#include "cafCmdFeature.h"
class RiuMainWindowBase;
class RiuMainWindow;
class RiuPlotMainWindow;
//==================================================================================================
///
@ -33,7 +34,7 @@ class RicTileWindowsFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
public:
static void applyTiling( RiuMainWindowBase* mainWindow, RiaDefines::WindowTileMode requestedTileMode );
static void applyTiling( RiuMainWindow* mainWindow, RiaDefines::WindowTileMode requestedTileMode );
protected:
bool isCommandEnabled() override;
@ -77,6 +78,9 @@ class RicTilePlotWindowsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void applyTiling( RiuPlotMainWindow* mainWindow, RiaDefines::WindowTileMode requestedTileMode );
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;

View File

@ -139,15 +139,7 @@ void RiuMdiArea::tileWindowsVertically()
//--------------------------------------------------------------------------------------------------
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 );
}
//--------------------------------------------------------------------------------------------------
@ -165,29 +157,12 @@ void RiuMdiArea::resizeEvent( QResizeEvent* resizeEvent )
//--------------------------------------------------------------------------------------------------
void RiuMdiArea::applyTiling()
{
QMdiArea::WindowOrder currentActivationOrder = activationOrder();
for ( auto subWindow : subWindowList() )
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
riuWindow->blockTilingChanges( true );
}
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:
@ -205,10 +180,6 @@ void RiuMdiArea::applyTiling()
break;
}
// Set back the original activation order to avoid messing with the standard ordering
setActivationOrder( currentActivationOrder );
setActiveSubWindow( activeWindow );
for ( auto subWindow : subWindowList() )
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );