#4312 Force new current sub window in MDI area to be maximized if closing a sub-window that was maximized

This commit is contained in:
Gaute Lindkvist 2019-04-15 15:29:49 +02:00
parent edf46496b7
commit e41f8ec149
3 changed files with 24 additions and 10 deletions

View File

@ -1114,13 +1114,21 @@ RiuMessagePanel* RiuMainWindow::messagePanel()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMainWindow::removeViewer(QWidget* viewer) void RiuMainWindow::removeViewer(QWidget* viewer)
{ {
bool wasMaximized = viewer && viewer->isMaximized();
setBlockSlotSubWindowActivated(true); setBlockSlotSubWindowActivated(true);
m_mdiArea->removeSubWindow(findMdiSubWindow(viewer)); m_mdiArea->removeSubWindow(findMdiSubWindow(viewer));
setBlockSlotSubWindowActivated(false); setBlockSlotSubWindowActivated(false);
if (subWindowsAreTiled())
if (wasMaximized && m_mdiArea->currentSubWindow())
{
m_mdiArea->currentSubWindow()->showMaximized();
}
else if (subWindowsAreTiled())
{ {
tileSubWindows(); tileSubWindows();
} }
slotRefreshViewActions(); slotRefreshViewActions();
} }

View File

@ -63,7 +63,6 @@
RiuPlotMainWindow::RiuPlotMainWindow() RiuPlotMainWindow::RiuPlotMainWindow()
: m_activePlotViewWindow(nullptr) : m_activePlotViewWindow(nullptr)
, m_windowMenu(nullptr) , m_windowMenu(nullptr)
, m_blockSlotSubWindowActivated(false)
{ {
m_mdiArea = new RiuMdiArea; m_mdiArea = new RiuMdiArea;
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*))); connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
@ -587,13 +586,22 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar(bool forceUpdateUi)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::removeViewer(QWidget* viewer) void RiuPlotMainWindow::removeViewer(QWidget* viewer)
{ {
m_blockSlotSubWindowActivated = true; bool wasMaximized = viewer && viewer->isMaximized();
setBlockSlotSubWindowActivated(true);
m_mdiArea->removeSubWindow(findMdiSubWindow(viewer)); m_mdiArea->removeSubWindow(findMdiSubWindow(viewer));
m_blockSlotSubWindowActivated = false; setBlockSlotSubWindowActivated(false);
if (subWindowsAreTiled())
if (wasMaximized && m_mdiArea->currentSubWindow())
{
m_mdiArea->currentSubWindow()->showMaximized();
}
else if (subWindowsAreTiled())
{ {
tileSubWindows(); tileSubWindows();
} }
refreshToolbars(); refreshToolbars();
} }
@ -655,7 +663,7 @@ void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
if (viewWindow && viewWindow != m_activePlotViewWindow) if (viewWindow && viewWindow != m_activePlotViewWindow)
{ {
if (!m_blockSlotSubWindowActivated) if (!blockSlotSubWindowActivated())
{ {
selectAsCurrentItem(viewWindow); selectAsCurrentItem(viewWindow);
} }
@ -672,12 +680,12 @@ void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::setActiveViewer(QWidget* viewer) void RiuPlotMainWindow::setActiveViewer(QWidget* viewer)
{ {
m_blockSlotSubWindowActivated = true; setBlockSlotSubWindowActivated(true);
QMdiSubWindow* swin = findMdiSubWindow(viewer); QMdiSubWindow* swin = findMdiSubWindow(viewer);
if (swin) m_mdiArea->setActiveSubWindow(swin); if (swin) m_mdiArea->setActiveSubWindow(swin);
m_blockSlotSubWindowActivated = false; setBlockSlotSubWindowActivated(false);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -124,7 +124,5 @@ private:
caf::PdmUiPropertyView* m_pdmUiPropertyView; caf::PdmUiPropertyView* m_pdmUiPropertyView;
bool m_blockSlotSubWindowActivated;
std::vector<QWidget*> m_temporaryWidgets; std::vector<QWidget*> m_temporaryWidgets;
}; };