#4283 Improve window tiling during resize

This commit is contained in:
Gaute Lindkvist
2019-04-02 19:18:00 +02:00
parent 038d7a7676
commit 000b6713b1
16 changed files with 457 additions and 23 deletions

View File

@@ -52,7 +52,14 @@ void RicTileWindowsFeature::onActionTriggered(bool isChecked)
RiuMainWindow* mainWindow = RiuMainWindow::instance(); RiuMainWindow* mainWindow = RiuMainWindow::instance();
if (mainWindow) if (mainWindow)
{ {
mainWindow->tileWindows(); if (!mainWindow->subWindowsAreTiled())
{
mainWindow->tileSubWindows();
}
else
{
mainWindow->clearWindowTiling();
}
} }
} }
@@ -63,10 +70,23 @@ void RicTileWindowsFeature::setupActionLook(QAction* actionToSetup)
{ {
actionToSetup->setText("Tile Windows"); actionToSetup->setText("Tile Windows");
actionToSetup->setIcon(QIcon(":/TileWindows24x24.png")); actionToSetup->setIcon(QIcon(":/TileWindows24x24.png"));
actionToSetup->setCheckable(true);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicTileWindowsFeature::isCommandChecked()
{
if (RiaApplication::instance()->mainWindow())
{
return RiaApplication::instance()->mainWindow()->subWindowsAreTiled();
}
return false;
}
CAF_CMD_SOURCE_INIT(RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature"); CAF_CMD_SOURCE_INIT(RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -91,7 +111,14 @@ void RicTilePlotWindowsFeature::onActionTriggered(bool isChecked)
RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
if (mainPlotWindow) if (mainPlotWindow)
{ {
mainPlotWindow->tileWindows(); if (!mainPlotWindow->subWindowsAreTiled())
{
mainPlotWindow->tileSubWindows();
}
else
{
mainPlotWindow->clearWindowTiling();
}
} }
} }
@@ -102,4 +129,17 @@ void RicTilePlotWindowsFeature::setupActionLook(QAction* actionToSetup)
{ {
actionToSetup->setText("Tile Windows"); actionToSetup->setText("Tile Windows");
actionToSetup->setIcon(QIcon(":/TileWindows24x24.png")); actionToSetup->setIcon(QIcon(":/TileWindows24x24.png"));
actionToSetup->setCheckable(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicTilePlotWindowsFeature::isCommandChecked()
{
if (RiaApplication::instance()->mainPlotWindow())
{
return RiaApplication::instance()->mainPlotWindow()->subWindowsAreTiled();
}
return false;
} }

View File

@@ -34,6 +34,8 @@ protected:
bool isCommandEnabled() override; bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override; void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override; void setupActionLook( QAction* actionToSetup ) override;
bool isCommandChecked() override;
}; };
//================================================================================================== //==================================================================================================
@@ -48,5 +50,6 @@ protected:
bool isCommandEnabled() override; bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override; void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override; void setupActionLook(QAction* actionToSetup) override;
bool isCommandChecked() override;
}; };

View File

@@ -190,7 +190,7 @@ void RicPlotProductionRateFeature::onActionTriggered(bool isChecked)
mainPlotWindow->selectAsCurrentItem(summaryPlotToSelect); mainPlotWindow->selectAsCurrentItem(summaryPlotToSelect);
mainPlotWindow->setExpanded(summaryPlotToSelect); mainPlotWindow->setExpanded(summaryPlotToSelect);
mainPlotWindow->tileWindows(); mainPlotWindow->tileSubWindows();
} }
} }
} }

View File

@@ -149,6 +149,12 @@ RimProject::RimProject(void)
CAF_PDM_InitField(&m_showPlotWindow, "showPlotWindow", false, "Show Plot Window", "", "", ""); CAF_PDM_InitField(&m_showPlotWindow, "showPlotWindow", false, "Show Plot Window", "", "", "");
m_showPlotWindow.uiCapability()->setUiHidden(true); m_showPlotWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_subWindowsTiled3DWindow, "tiled3DWindow", false, "Tile 3D Window", "", "", "");
m_subWindowsTiled3DWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_subWindowsTiledPlotWindow, "tiledPlotWindow", false, "Tile Plot Window", "", "", "");
m_subWindowsTiledPlotWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_dialogData, "DialogData", "DialogData", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_dialogData, "DialogData", "DialogData", "", "", "");
m_dialogData = new RimDialogData(); m_dialogData = new RimDialogData();
m_dialogData.uiCapability()->setUiHidden(true); m_dialogData.uiCapability()->setUiHidden(true);
@@ -851,6 +857,38 @@ bool RimProject::showPlotWindow() const
return m_showPlotWindow; return m_showPlotWindow;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::subWindowsTiled3DWindow() const
{
return m_subWindowsTiled3DWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::subWindowsTiledPlotWindow() const
{
return m_subWindowsTiledPlotWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::setSubWindowsTiledIn3DWindow(bool tiled)
{
m_subWindowsTiled3DWindow = tiled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::setSubWindowsTiledInPlotWindow(bool tiled)
{
m_subWindowsTiledPlotWindow = tiled;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -137,6 +137,12 @@ public:
bool show3DWindow() const; bool show3DWindow() const;
bool showPlotWindow() const; bool showPlotWindow() const;
bool subWindowsTiled3DWindow() const;
bool subWindowsTiledPlotWindow() const;
void setSubWindowsTiledIn3DWindow(bool tiled);
void setSubWindowsTiledInPlotWindow(bool tiled);
void reloadCompletionTypeResultsInAllViews(); void reloadCompletionTypeResultsInAllViews();
void reloadCompletionTypeResultsForEclipseCase(RimEclipseCase* eclipseCase); void reloadCompletionTypeResultsForEclipseCase(RimEclipseCase* eclipseCase);
@@ -186,6 +192,9 @@ private:
caf::PdmField<bool> m_show3DWindow; caf::PdmField<bool> m_show3DWindow;
caf::PdmField<bool> m_showPlotWindow; caf::PdmField<bool> m_showPlotWindow;
caf::PdmField<bool> m_subWindowsTiled3DWindow;
caf::PdmField<bool> m_subWindowsTiledPlotWindow;
caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts
caf::PdmField<int> nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts caf::PdmField<int> nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts

View File

@@ -12,6 +12,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h
${CMAKE_CURRENT_LIST_DIR}/RiuMdiArea.h
${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.h
${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.h ${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.h
@@ -96,6 +97,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMdiArea.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.cpp
@@ -175,6 +177,8 @@ list(APPEND QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMdiArea.h
${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h ${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h
${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h ${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h
${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.h ${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.h

View File

@@ -119,7 +119,7 @@ RiuMainWindow::RiuMainWindow()
, m_blockSlotSubWindowActivated(false) , m_blockSlotSubWindowActivated(false)
, m_holoLensToolBar(nullptr) , m_holoLensToolBar(nullptr)
{ {
m_mdiArea = new QMdiArea; m_mdiArea = new RiuMdiArea;
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*))); connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
setCentralWidget(m_mdiArea); setCentralWidget(m_mdiArea);
@@ -178,6 +178,12 @@ void RiuMainWindow::initializeGuiNewProjectLoaded()
{ {
setPdmRoot(RiaApplication::instance()->project()); setPdmRoot(RiaApplication::instance()->project());
restoreTreeViewState(); restoreTreeViewState();
if (subWindowsAreTiled())
{
tileSubWindows();
}
slotRefreshFileActions(); slotRefreshFileActions();
slotRefreshEditActions(); slotRefreshEditActions();
slotRefreshViewActions(); slotRefreshViewActions();
@@ -864,7 +870,6 @@ void RiuMainWindow::slotRefreshFileActions()
CVF_ASSERT(cmdFeatureMgr); CVF_ASSERT(cmdFeatureMgr);
cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")->setEnabled(projectFileExists); cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")->setEnabled(projectFileExists);
QStringList commandIdList; QStringList commandIdList;
commandIdList << "RicExportEclipseInputGridFeature"; commandIdList << "RicExportEclipseInputGridFeature";
commandIdList << "RicSaveEclipseInputVisibleCellsFeature"; commandIdList << "RicSaveEclipseInputVisibleCellsFeature";
@@ -872,6 +877,7 @@ void RiuMainWindow::slotRefreshFileActions()
commandIdList << "RicExportCompletionsForVisibleWellPathsFeature"; commandIdList << "RicExportCompletionsForVisibleWellPathsFeature";
commandIdList << "RicExportVisibleWellPathsFeature"; commandIdList << "RicExportVisibleWellPathsFeature";
cmdFeatureMgr->refreshStates(commandIdList); cmdFeatureMgr->refreshStates(commandIdList);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -912,6 +918,7 @@ void RiuMainWindow::slotRefreshViewActions()
{ {
QStringList commandIds; QStringList commandIds;
commandIds << "RicTileWindowsFeature";
commandIds << "RicToggleMeasurementModeFeature"; commandIds << "RicToggleMeasurementModeFeature";
commandIds << "RicTogglePolyMeasurementModeFeature"; commandIds << "RicTogglePolyMeasurementModeFeature";
@@ -1111,7 +1118,10 @@ void RiuMainWindow::removeViewer(QWidget* viewer)
m_blockSlotSubWindowActivated = true; m_blockSlotSubWindowActivated = true;
m_mdiArea->removeSubWindow(findMdiSubWindow(viewer)); m_mdiArea->removeSubWindow(findMdiSubWindow(viewer));
m_blockSlotSubWindowActivated = false; m_blockSlotSubWindowActivated = false;
if (subWindowsAreTiled())
{
tileSubWindows();
}
slotRefreshViewActions(); slotRefreshViewActions();
} }
@@ -1985,7 +1995,7 @@ void RiuMainWindow::customMenuRequested(const QPoint& pos)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMainWindow::tileWindows() void RiuMainWindow::tileSubWindows()
{ {
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder(); QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
@@ -2039,9 +2049,49 @@ void RiuMainWindow::tileWindows()
} }
m_mdiArea->tileSubWindows(); m_mdiArea->tileSubWindows();
// Set back the original activation order to avoid messing with the standard ordering // Set back the original activation order to avoid messing with the standard ordering
m_mdiArea->setActivationOrder(currentActivationOrder); m_mdiArea->setActivationOrder(currentActivationOrder);
m_mdiArea->setActiveSubWindow(a); m_mdiArea->setActiveSubWindow(a);
storeSubWindowTiling(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::storeSubWindowTiling(bool tiled)
{
RiaApplication::instance()->project()->setSubWindowsTiledIn3DWindow(tiled);
refreshViewActions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::clearWindowTiling()
{
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
std::list<QMdiSubWindow*> windowList;
for (QMdiSubWindow* subWindow : m_mdiArea->subWindowList(currentActivationOrder))
{
subWindow->hide();
subWindow->showNormal();
}
storeSubWindowTiling(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMainWindow::subWindowsAreTiled() const
{
if (RiaApplication::instance()->project())
{
return RiaApplication::instance()->project()->subWindowsTiled3DWindow();
}
return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -21,13 +21,13 @@
#pragma once #pragma once
#include "RiuMainWindowBase.h" #include "RiuMainWindowBase.h"
#include "RiuMdiArea.h"
#include "cafPdmUiDragDropInterface.h" #include "cafPdmUiDragDropInterface.h"
#include "cafPdmObjectHandle.h" #include "cafPdmObjectHandle.h"
#include <QEvent> #include <QEvent>
#include <QLabel> #include <QLabel>
#include <QMdiArea>
#include <QPointer> #include <QPointer>
#include <memory> #include <memory>
@@ -110,7 +110,11 @@ public:
void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
void tileWindows(); void tileSubWindows() override;
void storeSubWindowTiling(bool tiled) override;
void clearWindowTiling() override;
bool subWindowsAreTiled() const override;
bool isAnyMdiSubWindowVisible(); bool isAnyMdiSubWindowVisible();
QMdiSubWindow* findMdiSubWindow(QWidget* viewer) override; QMdiSubWindow* findMdiSubWindow(QWidget* viewer) override;
RimViewWindow* findViewWindowFromSubWindow(QMdiSubWindow* lhs); RimViewWindow* findViewWindowFromSubWindow(QMdiSubWindow* lhs);
@@ -167,7 +171,7 @@ private:
caf::AnimationToolBar* m_animationToolBar; caf::AnimationToolBar* m_animationToolBar;
QMdiArea* m_mdiArea; RiuMdiArea* m_mdiArea;
RiuResultInfoPanel* m_resultInfoPanel; RiuResultInfoPanel* m_resultInfoPanel;
RiuProcessMonitor* m_processMonitor; RiuProcessMonitor* m_processMonitor;
QPointer<RiuMessagePanel> m_messagePanel; QPointer<RiuMessagePanel> m_messagePanel;

View File

@@ -18,16 +18,21 @@
#include "RiuMainWindowBase.h" #include "RiuMainWindowBase.h"
#include "RiaApplication.h"
#include "RiaVersionInfo.h" #include "RiaVersionInfo.h"
#include "RiuDockWidgetTools.h" #include "RiuDockWidgetTools.h"
#include "RiuMdiSubWindow.h" #include "RiuMdiSubWindow.h"
#include "RimViewWindow.h"
#include "RimProject.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "cafPdmUiTreeView.h" #include "cafPdmUiTreeView.h"
#include <QDockWidget> #include <QDockWidget>
#include <QMdiArea> #include <QMdiArea>
#include <QMdiSubWindow>
#include <QSettings> #include <QSettings>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -182,6 +187,7 @@ void RiuMainWindowBase::addViewerToMdiArea(QMdiArea* mdiArea,
subWin->setAttribute(Qt::WA_DeleteOnClose); // Make sure the contained widget is destroyed when the MDI window is closed subWin->setAttribute(Qt::WA_DeleteOnClose); // Make sure the contained widget is destroyed when the MDI window is closed
subWin->setWidget(viewer); subWin->setWidget(viewer);
bool initialStateTiled = subWindowsAreTiled();
bool initialStateMaximized = false; bool initialStateMaximized = false;
if (m_showFirstVisibleWindowMaximized && mdiArea->subWindowList().empty()) if (m_showFirstVisibleWindowMaximized && mdiArea->subWindowList().empty())
@@ -210,5 +216,9 @@ void RiuMainWindowBase::addViewerToMdiArea(QMdiArea* mdiArea,
else else
{ {
subWin->showNormal(); subWin->showNormal();
if (initialStateTiled)
{
tileSubWindows();
}
} }
} }

View File

@@ -20,6 +20,7 @@
#include <QMainWindow> #include <QMainWindow>
class QMdiArea;
struct RimMdiWindowGeometry; struct RimMdiWindowGeometry;
namespace caf namespace caf
@@ -29,7 +30,7 @@ namespace caf
class PdmUiItem; class PdmUiItem;
} }
class QMdiArea;
class QMdiSubWindow; class QMdiSubWindow;
@@ -62,6 +63,11 @@ public:
void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true);
void enableShowFirstVisibleMdiWindowMaximized(bool enable); void enableShowFirstVisibleMdiWindowMaximized(bool enable);
virtual void tileSubWindows() = 0;
virtual void storeSubWindowTiling(bool tiled) = 0;
virtual void clearWindowTiling() = 0;
virtual bool subWindowsAreTiled() const = 0;
protected slots: protected slots:
void slotDockWidgetToggleViewActionTriggered(); void slotDockWidgetToggleViewActionTriggered();
@@ -71,8 +77,6 @@ protected:
caf::PdmUiTreeView* m_projectTreeView; caf::PdmUiTreeView* m_projectTreeView;
bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control
// whether to select the corresponding active view or not // whether to select the corresponding active view or not
private: private:
QString registryFolderName(); QString registryFolderName();

View File

@@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuMdiArea.h"
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
#include "RiuMdiSubWindow.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::list<QMdiSubWindow*> RiuMdiArea::subWindowListSortedByPosition()
{
// Tile Windows so the one with the leftmost left edge gets sorted first.
std::list<QMdiSubWindow*> windowList;
for (QMdiSubWindow* subWindow : subWindowList(QMdiArea::CreationOrder))
{
windowList.push_back(subWindow);
}
// 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().rx() == rhs->frameGeometry().topLeft().rx())
{
return lhs->frameGeometry().topLeft().ry() < rhs->frameGeometry().topLeft().ry();
}
return lhs->frameGeometry().topLeft().rx() < rhs->frameGeometry().topLeft().rx();
});
return windowList;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiArea::resizeEvent(QResizeEvent* resizeEvent)
{
if (subWindowsAreTiled())
{
for (auto subWindow : subWindowList())
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
riuWindow->blockTilingChanges(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);
for (auto subWindow : subWindowList())
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
riuWindow->blockTilingChanges(false);
}
}
else
{
QMdiArea::resizeEvent(resizeEvent);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiArea::moveEvent(QMoveEvent* event)
{
for (auto subWindow : subWindowList())
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
riuWindow->blockTilingChanges(true);
}
QMdiArea::moveEvent(event);
for (auto subWindow : subWindowList())
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
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;
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QMdiArea>
#include <list>
class QMdiSubWindow;
class RiuMdiArea : public QMdiArea
{
Q_OBJECT
public:
std::list<QMdiSubWindow*> subWindowListSortedByPosition();
protected:
void resizeEvent(QResizeEvent *resizeEvent) override;
void moveEvent(QMoveEvent *event) override;
bool subWindowsAreTiled() const;
};

View File

@@ -39,6 +39,7 @@
RiuMdiSubWindow::RiuMdiSubWindow(QWidget* parent /*= 0*/, Qt::WindowFlags flags /*= 0*/) RiuMdiSubWindow::RiuMdiSubWindow(QWidget* parent /*= 0*/, Qt::WindowFlags flags /*= 0*/)
: QMdiSubWindow(parent, flags) : QMdiSubWindow(parent, flags)
, m_normalWindowGeometry(QRect()) , m_normalWindowGeometry(QRect())
, m_blockTilingChanges(false)
{ {
} }
@@ -82,6 +83,14 @@ RimMdiWindowGeometry RiuMdiSubWindow::windowGeometry() const
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiSubWindow::blockTilingChanges(bool block)
{
m_blockTilingChanges = block;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -102,7 +111,29 @@ void RiuMdiSubWindow::closeEvent(QCloseEvent* event)
viewer->ownerReservoirView()->setMdiWindowGeometry(windowGeometry()); viewer->ownerReservoirView()->setMdiWindowGeometry(windowGeometry());
} }
} }
RiuMainWindowBase* windowToTile = nullptr;
if (window() == RiaApplication::instance()->mainWindow())
{
if (RiaApplication::instance()->mainWindow()->subWindowsAreTiled())
{
windowToTile = RiaApplication::instance()->mainWindow();
}
}
else if (window() == RiaApplication::instance()->mainPlotWindow())
{
if (RiaApplication::instance()->mainPlotWindow()->subWindowsAreTiled())
{
windowToTile = RiaApplication::instance()->mainPlotWindow();
}
}
QMdiSubWindow::closeEvent(event); QMdiSubWindow::closeEvent(event);
if(windowToTile)
{
windowToTile->tileSubWindows();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -114,6 +145,19 @@ void RiuMdiSubWindow::resizeEvent(QResizeEvent* resizeEvent)
{ {
m_normalWindowGeometry = frameGeometry(); m_normalWindowGeometry = frameGeometry();
} }
if (!m_blockTilingChanges)
{
if (window() == RiaApplication::instance()->mainWindow())
{
RiaApplication::instance()->mainWindow()->storeSubWindowTiling(false);
}
else if (window() == RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->storeSubWindowTiling(false);
}
}
QMdiSubWindow::resizeEvent(resizeEvent); QMdiSubWindow::resizeEvent(resizeEvent);
} }
@@ -126,5 +170,18 @@ void RiuMdiSubWindow::moveEvent(QMoveEvent* moveEvent)
{ {
m_normalWindowGeometry = frameGeometry(); m_normalWindowGeometry = frameGeometry();
} }
if (!m_blockTilingChanges)
{
if (window() == RiaApplication::instance()->mainWindow())
{
RiaApplication::instance()->mainWindow()->storeSubWindowTiling(false);
}
else if (window() == RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->storeSubWindowTiling(false);
}
}
QMdiSubWindow::moveEvent(moveEvent); QMdiSubWindow::moveEvent(moveEvent);
} }

View File

@@ -21,9 +21,9 @@
#include <QMdiSubWindow> #include <QMdiSubWindow>
#include "RimViewWindow.h" #include "RimViewWindow.h"
class RiuMdiSubWindow : public QMdiSubWindow class RiuMdiSubWindow : public QMdiSubWindow
{ {
Q_OBJECT
public: public:
RiuMdiSubWindow(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr); RiuMdiSubWindow(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr);
@@ -31,12 +31,14 @@ public:
RimMdiWindowGeometry windowGeometry() const; RimMdiWindowGeometry windowGeometry() const;
void blockTilingChanges(bool block);
protected: protected:
void closeEvent(QCloseEvent* event) override; void closeEvent(QCloseEvent* event) override;
void resizeEvent(QResizeEvent* resizeEvent) override; void resizeEvent(QResizeEvent* resizeEvent) override;
void moveEvent(QMoveEvent *moveEvent) override; void moveEvent(QMoveEvent *moveEvent) override;
private: private:
QRect m_normalWindowGeometry; QRect m_normalWindowGeometry;
bool m_blockTilingChanges;
}; };

View File

@@ -65,7 +65,7 @@ RiuPlotMainWindow::RiuPlotMainWindow()
, m_windowMenu(nullptr) , m_windowMenu(nullptr)
, m_blockSlotSubWindowActivated(false) , m_blockSlotSubWindowActivated(false)
{ {
m_mdiArea = new QMdiArea; m_mdiArea = new RiuMdiArea;
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*))); connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
setCentralWidget(m_mdiArea); setCentralWidget(m_mdiArea);
@@ -120,6 +120,11 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded()
} }
} }
if (subWindowsAreTiled())
{
tileSubWindows();
}
if (m_activePlotViewWindow && m_activePlotViewWindow->viewWidget()) if (m_activePlotViewWindow && m_activePlotViewWindow->viewWidget())
{ {
if (m_activePlotViewWindow->mdiWindowGeometry().isMaximized) if (m_activePlotViewWindow->mdiWindowGeometry().isMaximized)
@@ -369,6 +374,7 @@ void RiuPlotMainWindow::refreshToolbars()
QStringList allToolbarCommandNames = toolbarCommandIds(); QStringList allToolbarCommandNames = toolbarCommandIds();
caf::CmdFeatureManager::instance()->refreshEnabledState(allToolbarCommandNames); caf::CmdFeatureManager::instance()->refreshEnabledState(allToolbarCommandNames);
caf::CmdFeatureManager::instance()->refreshCheckedState(allToolbarCommandNames);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -584,7 +590,10 @@ void RiuPlotMainWindow::removeViewer(QWidget* viewer)
m_blockSlotSubWindowActivated = true; m_blockSlotSubWindowActivated = true;
m_mdiArea->removeSubWindow(findMdiSubWindow(viewer)); m_mdiArea->removeSubWindow(findMdiSubWindow(viewer));
m_blockSlotSubWindowActivated = false; m_blockSlotSubWindowActivated = false;
if (subWindowsAreTiled())
{
tileSubWindows();
}
refreshToolbars(); refreshToolbars();
} }
@@ -840,7 +849,7 @@ void RiuPlotMainWindow::customMenuRequested(const QPoint& pos)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::tileWindows() void RiuPlotMainWindow::tileSubWindows()
{ {
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder(); QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
@@ -871,6 +880,45 @@ void RiuPlotMainWindow::tileWindows()
// Set back the original activation order to avoid messing with the standard ordering // Set back the original activation order to avoid messing with the standard ordering
m_mdiArea->setActivationOrder(currentActivationOrder); m_mdiArea->setActivationOrder(currentActivationOrder);
m_mdiArea->setActiveSubWindow(a); m_mdiArea->setActiveSubWindow(a);
storeSubWindowTiling(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::storeSubWindowTiling(bool tiled)
{
RiaApplication::instance()->project()->setSubWindowsTiledInPlotWindow(tiled);
refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::clearWindowTiling()
{
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
std::list<QMdiSubWindow*> windowList;
for (QMdiSubWindow* subWindow : m_mdiArea->subWindowList(currentActivationOrder))
{
subWindow->hide();
subWindow->showNormal();
}
storeSubWindowTiling(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuPlotMainWindow::subWindowsAreTiled() const
{
if (RiaApplication::instance()->project())
{
return RiaApplication::instance()->project()->subWindowsTiledPlotWindow();
}
return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -19,12 +19,11 @@
#pragma once #pragma once
#include "RiuMainWindowBase.h" #include "RiuMainWindowBase.h"
#include "RiuMdiArea.h"
#include "cafPdmUiDragDropInterface.h" #include "cafPdmUiDragDropInterface.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
#include <QMdiArea>
#include <memory> #include <memory>
class QMdiSubWindow; class QMdiSubWindow;
@@ -69,7 +68,11 @@ public:
void setDefaultWindowSize(); void setDefaultWindowSize();
void tileWindows(); void tileSubWindows() override;
void storeSubWindowTiling(bool tiled) override;
void clearWindowTiling() override;
bool subWindowsAreTiled() const override;
bool isAnyMdiSubWindowVisible(); bool isAnyMdiSubWindowVisible();
QMdiSubWindow* findMdiSubWindow(QWidget* viewer) override; QMdiSubWindow* findMdiSubWindow(QWidget* viewer) override;
QList<QMdiSubWindow*> subWindowList(QMdiArea::WindowOrder order); QList<QMdiSubWindow*> subWindowList(QMdiArea::WindowOrder order);
@@ -110,7 +113,7 @@ private slots:
private: private:
QByteArray m_initialDockAndToolbarLayout; // Initial dock window and toolbar layout, used to reset GUI QByteArray m_initialDockAndToolbarLayout; // Initial dock window and toolbar layout, used to reset GUI
QMdiArea* m_mdiArea; RiuMdiArea* m_mdiArea;
caf::PdmPointer<RimViewWindow> m_activePlotViewWindow; caf::PdmPointer<RimViewWindow> m_activePlotViewWindow;
QMenu* m_windowMenu; QMenu* m_windowMenu;