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:
@@ -83,7 +83,10 @@ void RimMdiWindowController::handleViewerDeletion()
|
||||
{
|
||||
viewPdmObject()->m_showWindow = false;
|
||||
viewPdmObject()->updateConnectedEditors();
|
||||
viewPdmObject()->updateUiIconFromToggleField();
|
||||
uiCapability()->updateUiIconFromToggleField();
|
||||
removeWindowFromMDI();
|
||||
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
|
||||
@@ -106,10 +106,6 @@ void RiuFlowCharacteristicsPlot::addWindowZoom(QwtPlot* plot)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuFlowCharacteristicsPlot::~RiuFlowCharacteristicsPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1114,21 +1114,7 @@ RiuMessagePanel* RiuMainWindow::messagePanel()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::removeViewer(QWidget* viewer)
|
||||
{
|
||||
bool wasMaximized = viewer && viewer->isMaximized();
|
||||
|
||||
setBlockSlotSubWindowActivated(true);
|
||||
m_mdiArea->removeSubWindow(findMdiSubWindow(viewer));
|
||||
setBlockSlotSubWindowActivated(false);
|
||||
|
||||
if (wasMaximized && m_mdiArea->currentSubWindow())
|
||||
{
|
||||
m_mdiArea->currentSubWindow()->showMaximized();
|
||||
}
|
||||
else if (subWindowsAreTiled())
|
||||
{
|
||||
tileSubWindows();
|
||||
}
|
||||
|
||||
removeViewerFromMdiArea(m_mdiArea, viewer);
|
||||
slotRefreshViewActions();
|
||||
}
|
||||
|
||||
@@ -1360,12 +1346,8 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::setActiveViewer(QWidget* viewer)
|
||||
{
|
||||
setBlockSlotSubWindowActivated(true);
|
||||
|
||||
QMdiSubWindow* swin = findMdiSubWindow(viewer);
|
||||
if (swin) m_mdiArea->setActiveSubWindow(swin);
|
||||
|
||||
setBlockSlotSubWindowActivated(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace caf
|
||||
}
|
||||
|
||||
|
||||
class QMdiArea;
|
||||
class QMdiSubWindow;
|
||||
|
||||
|
||||
@@ -72,6 +73,9 @@ public:
|
||||
void setBlockSlotSubWindowActivated(bool block);
|
||||
bool blockSlotSubWindowActivated() const;
|
||||
|
||||
protected:
|
||||
void removeViewerFromMdiArea(QMdiArea* mdiArea, QWidget* viewer);
|
||||
|
||||
protected slots:
|
||||
void slotDockWidgetToggleViewActionTriggered();
|
||||
void addViewerToMdiArea(QMdiArea* mdiArea, QWidget* viewer, const QPoint& subWindowPos, const QSize& subWindowSize);
|
||||
|
||||
@@ -98,41 +98,25 @@ void RiuMdiSubWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
QWidget* mainWidget = widget();
|
||||
|
||||
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(mainWidget);
|
||||
if (viewWindow)
|
||||
{
|
||||
viewWindow->setMdiWindowGeometry(windowGeometry());
|
||||
}
|
||||
else
|
||||
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(mainWidget);
|
||||
if (!viewWindow)
|
||||
{
|
||||
RiuViewer* viewer = mainWidget->findChild<RiuViewer*>();
|
||||
if (viewer)
|
||||
{
|
||||
viewer->ownerReservoirView()->setMdiWindowGeometry(windowGeometry());
|
||||
viewWindow = viewer->ownerViewWindow();
|
||||
}
|
||||
}
|
||||
|
||||
RiuMainWindowBase* windowToTile = nullptr;
|
||||
if (window() == RiaApplication::instance()->mainWindow())
|
||||
if (viewWindow)
|
||||
{
|
||||
if (RiaApplication::instance()->mainWindow()->subWindowsAreTiled())
|
||||
{
|
||||
windowToTile = RiaApplication::instance()->mainWindow();
|
||||
}
|
||||
viewWindow->setMdiWindowGeometry(windowGeometry());
|
||||
viewWindow->handleMdiWindowClosed();
|
||||
event->accept();
|
||||
}
|
||||
else if (window() == RiaApplication::instance()->mainPlotWindow())
|
||||
else
|
||||
{
|
||||
if (RiaApplication::instance()->mainPlotWindow()->subWindowsAreTiled())
|
||||
{
|
||||
windowToTile = RiaApplication::instance()->mainPlotWindow();
|
||||
}
|
||||
}
|
||||
|
||||
QMdiSubWindow::closeEvent(event);
|
||||
|
||||
if(windowToTile)
|
||||
{
|
||||
windowToTile->tileSubWindows();
|
||||
QMdiSubWindow::closeEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -586,22 +586,7 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar(bool forceUpdateUi)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindow::removeViewer(QWidget* viewer)
|
||||
{
|
||||
bool wasMaximized = viewer && viewer->isMaximized();
|
||||
|
||||
setBlockSlotSubWindowActivated(true);
|
||||
m_mdiArea->removeSubWindow(findMdiSubWindow(viewer));
|
||||
setBlockSlotSubWindowActivated(false);
|
||||
|
||||
if (wasMaximized && m_mdiArea->currentSubWindow())
|
||||
{
|
||||
m_mdiArea->currentSubWindow()->showMaximized();
|
||||
}
|
||||
else if (subWindowsAreTiled())
|
||||
{
|
||||
tileSubWindows();
|
||||
}
|
||||
|
||||
|
||||
removeViewerFromMdiArea(m_mdiArea, viewer);
|
||||
refreshToolbars();
|
||||
}
|
||||
|
||||
@@ -653,6 +638,7 @@ void RiuPlotMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
|
||||
void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
|
||||
{
|
||||
if (!subWindow) return;
|
||||
if (blockSlotSubWindowActivated()) return;
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (!proj) return;
|
||||
@@ -663,11 +649,7 @@ void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
|
||||
|
||||
if (viewWindow && viewWindow != m_activePlotViewWindow)
|
||||
{
|
||||
if (!blockSlotSubWindowActivated())
|
||||
{
|
||||
selectAsCurrentItem(viewWindow);
|
||||
}
|
||||
|
||||
selectAsCurrentItem(viewWindow);
|
||||
m_activePlotViewWindow = viewWindow;
|
||||
}
|
||||
|
||||
@@ -680,12 +662,8 @@ void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindow::setActiveViewer(QWidget* viewer)
|
||||
{
|
||||
setBlockSlotSubWindowActivated(true);
|
||||
|
||||
QMdiSubWindow* swin = findMdiSubWindow(viewer);
|
||||
if (swin) m_mdiArea->setActiveSubWindow(swin);
|
||||
|
||||
setBlockSlotSubWindowActivated(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -92,11 +92,7 @@ RiuQwtPlot::~RiuQwtPlot()
|
||||
if (ownerPlotDefinition())
|
||||
{
|
||||
ownerPlotDefinition()->detachAllCurves();
|
||||
}
|
||||
if (ownerViewWindow())
|
||||
{
|
||||
ownerViewWindow()->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -89,11 +89,6 @@ RiuTofAccumulatedPhaseFractionsPlot::RiuTofAccumulatedPhaseFractionsPlot(RimTofA
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuTofAccumulatedPhaseFractionsPlot::~RiuTofAccumulatedPhaseFractionsPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
|
||||
if (m_watCurve)
|
||||
{
|
||||
m_watCurve->detach();
|
||||
|
||||
@@ -185,8 +185,6 @@ RiuViewer::~RiuViewer()
|
||||
{
|
||||
if (m_rimView)
|
||||
{
|
||||
m_rimView->handleMdiWindowClosed();
|
||||
|
||||
m_rimView->setCameraPosition(m_mainCamera->viewMatrix());
|
||||
m_rimView->setCameraPointOfInterest(pointOfInterest());
|
||||
}
|
||||
|
||||
@@ -104,10 +104,6 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellAllocationPlot::~RiuWellAllocationPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -85,7 +85,6 @@ RiuWellLogPlot::~RiuWellLogPlot()
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->detachAllCurves();
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +87,6 @@ RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellPltPlot::~RiuWellPltPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -87,10 +87,6 @@ RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellRftPlot::~RiuWellRftPlot()
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->handleMdiWindowClosed();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user