mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4312 Move handleMdiWindowClosed call from widget destructors to MdiSubWindow closeEvent
* This way the mdi window still exists at the time of removal and we can handle the removal orderly
This commit is contained in:
@@ -163,6 +163,44 @@ bool RiuMainWindowBase::blockSlotSubWindowActivated() const
|
||||
return m_blockSlotSubWindowActivated;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindowBase::removeViewerFromMdiArea(QMdiArea* mdiArea, QWidget* viewer)
|
||||
{
|
||||
bool wasMaximized = viewer && viewer->isMaximized();
|
||||
|
||||
QMdiSubWindow* subWindowBeingClosed = findMdiSubWindow(viewer);
|
||||
bool removedSubWindowWasActive = false;
|
||||
if (subWindowBeingClosed->isActiveWindow())
|
||||
{
|
||||
// If we are removing the active window, we will need a new active window
|
||||
// Start by making the window inactive so Qt doesn't pick the active window itself
|
||||
mdiArea->setActiveSubWindow(nullptr);
|
||||
removedSubWindowWasActive = true;
|
||||
}
|
||||
mdiArea->removeSubWindow(subWindowBeingClosed);
|
||||
|
||||
QList<QMdiSubWindow*> subWindowList = mdiArea->subWindowList(QMdiArea::ActivationHistoryOrder);
|
||||
if (!subWindowList.empty())
|
||||
{
|
||||
if (removedSubWindowWasActive)
|
||||
{
|
||||
mdiArea->setActiveSubWindow(nullptr);
|
||||
// Make the last activated window the current activated one
|
||||
mdiArea->setActiveSubWindow(subWindowList.back());
|
||||
}
|
||||
if (wasMaximized && mdiArea->currentSubWindow())
|
||||
{
|
||||
mdiArea->currentSubWindow()->showMaximized();
|
||||
}
|
||||
else if (subWindowsAreTiled())
|
||||
{
|
||||
tileSubWindows();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user