mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#475) Make sure MDI window pos and size is restored
This commit is contained in:
parent
9a2ec02bcc
commit
66333e0367
@ -401,8 +401,6 @@ void RimWellLogPlot::handleViewerDeletion()
|
|||||||
|
|
||||||
if (m_viewer)
|
if (m_viewer)
|
||||||
{
|
{
|
||||||
windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer);
|
|
||||||
|
|
||||||
detachAllCurves();
|
detachAllCurves();
|
||||||
m_viewer = NULL;
|
m_viewer = NULL;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,9 @@ public:
|
|||||||
|
|
||||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||||
|
|
||||||
|
caf::PdmField< std::vector<int> > windowGeometry;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Overridden PDM methods
|
// Overridden PDM methods
|
||||||
@ -97,7 +100,6 @@ private:
|
|||||||
QPointer<RiuWellLogPlot> m_viewer;
|
QPointer<RiuWellLogPlot> m_viewer;
|
||||||
|
|
||||||
caf::PdmField<bool> m_showWindow;
|
caf::PdmField<bool> m_showWindow;
|
||||||
caf::PdmField< std::vector<int> > windowGeometry;
|
|
||||||
|
|
||||||
caf::PdmChildArrayField<RimWellLogPlotTrace*> traces;
|
caf::PdmChildArrayField<RimWellLogPlotTrace*> traces;
|
||||||
|
|
||||||
|
@ -104,15 +104,9 @@ RiuMainWindow::RiuMainWindow()
|
|||||||
{
|
{
|
||||||
CVF_ASSERT(sm_mainWindowInstance == NULL);
|
CVF_ASSERT(sm_mainWindowInstance == NULL);
|
||||||
|
|
||||||
#if 0
|
|
||||||
m_CentralFrame = new QFrame;
|
|
||||||
QHBoxLayout* frameLayout = new QHBoxLayout(m_CentralFrame);
|
|
||||||
setCentralWidget(m_CentralFrame);
|
|
||||||
#else
|
|
||||||
m_mdiArea = new QMdiArea;
|
m_mdiArea = new QMdiArea;
|
||||||
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
|
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
|
||||||
setCentralWidget(m_mdiArea);
|
setCentralWidget(m_mdiArea);
|
||||||
#endif
|
|
||||||
|
|
||||||
//m_mainViewer = createViewer();
|
//m_mainViewer = createViewer();
|
||||||
|
|
||||||
@ -1168,29 +1162,55 @@ QMdiSubWindow* RiuMainWindow::findMdiSubWindow(QWidget* viewer)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuMainWindow::removeViewer(QWidget* viewer)
|
void RiuMainWindow::removeViewer(QWidget* viewer)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
m_CentralFrame->layout()->removeWidget(viewer->layoutWidget());
|
|
||||||
#else
|
|
||||||
m_mdiArea->removeSubWindow( findMdiSubWindow(viewer));
|
m_mdiArea->removeSubWindow( findMdiSubWindow(viewer));
|
||||||
#endif
|
|
||||||
|
|
||||||
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
|
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Helper class used to trap the close event of an QMdiSubWindow
|
||||||
|
class RiuMdiSubWindow : public QMdiSubWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RiuMdiSubWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0)
|
||||||
|
: QMdiSubWindow(parent, flags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
QWidget* mainWidget = widget();
|
||||||
|
|
||||||
|
RiuWellLogPlot* wellLogPlot = dynamic_cast<RiuWellLogPlot*>(mainWidget);
|
||||||
|
if (wellLogPlot)
|
||||||
|
{
|
||||||
|
wellLogPlot->ownerPlotDefinition()->windowGeometry = RiuMainWindow::instance()->windowGeometryForWidget(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RiuViewer* viewer = mainWidget->findChild<RiuViewer*>();
|
||||||
|
if (viewer)
|
||||||
|
{
|
||||||
|
viewer->ownerReservoirView()->windowGeometry = RiuMainWindow::instance()->windowGeometryForWidget(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMdiSubWindow::closeEvent(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuMainWindow::addViewer(QWidget* viewer, const std::vector<int>& windowsGeometry)
|
void RiuMainWindow::addViewer(QWidget* viewer, const std::vector<int>& windowsGeometry)
|
||||||
{
|
{
|
||||||
#if 0
|
RiuMdiSubWindow* subWin = new RiuMdiSubWindow(m_mdiArea);
|
||||||
m_CentralFrame->layout()->addWidget(viewer->layoutWidget());
|
subWin->setAttribute(Qt::WA_DeleteOnClose); // Make sure the contained widget is destroyed when the MDI window is closed
|
||||||
#else
|
subWin->setWidget(viewer);
|
||||||
QMdiSubWindow * subWin = m_mdiArea->addSubWindow(viewer);
|
|
||||||
|
|
||||||
if (windowsGeometry.size() == 5)
|
if (windowsGeometry.size() == 5)
|
||||||
{
|
{
|
||||||
subWin->move(QPoint(windowsGeometry[0], windowsGeometry[1]));
|
|
||||||
subWin->resize(QSize(windowsGeometry[2], windowsGeometry[3]));
|
|
||||||
if (windowsGeometry[4] > 0)
|
if (windowsGeometry[4] > 0)
|
||||||
{
|
{
|
||||||
subWin->showMaximized();
|
subWin->showMaximized();
|
||||||
@ -1199,6 +1219,12 @@ void RiuMainWindow::addViewer(QWidget* viewer, const std::vector<int>& windowsGe
|
|||||||
{
|
{
|
||||||
subWin->show();
|
subWin->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move and resize must be done after window is visible
|
||||||
|
// If not, the position and size of the window is different to specification (Windows 7)
|
||||||
|
// Might be a Qt bug, must be tested on Linux
|
||||||
|
subWin->move(QPoint(windowsGeometry[0], windowsGeometry[1]));
|
||||||
|
subWin->resize(QSize(windowsGeometry[2], windowsGeometry[3]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1214,14 +1240,10 @@ void RiuMainWindow::addViewer(QWidget* viewer, const std::vector<int>& windowsGe
|
|||||||
subWin->show();
|
subWin->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
|
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -2183,16 +2205,30 @@ void RiuMainWindow::customMenuRequested(const QPoint& pos)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::vector<int> RiuMainWindow::windowGeometryForViewer(QWidget* viewer)
|
std::vector<int> RiuMainWindow::windowGeometryForViewer(QWidget* viewer)
|
||||||
{
|
{
|
||||||
std::vector<int> geo;
|
|
||||||
|
|
||||||
QMdiSubWindow* mdiWindow = findMdiSubWindow(viewer);
|
QMdiSubWindow* mdiWindow = findMdiSubWindow(viewer);
|
||||||
if (mdiWindow)
|
if (mdiWindow)
|
||||||
{
|
{
|
||||||
geo.push_back(mdiWindow->pos().x());
|
return windowGeometryForWidget(mdiWindow);
|
||||||
geo.push_back(mdiWindow->pos().y());
|
}
|
||||||
geo.push_back(mdiWindow->size().width());
|
|
||||||
geo.push_back(mdiWindow->size().height());
|
std::vector<int> geo;
|
||||||
geo.push_back(mdiWindow->isMaximized());
|
return geo;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<int> RiuMainWindow::windowGeometryForWidget(QWidget* widget)
|
||||||
|
{
|
||||||
|
std::vector<int> geo;
|
||||||
|
|
||||||
|
if (widget)
|
||||||
|
{
|
||||||
|
geo.push_back(widget->pos().x());
|
||||||
|
geo.push_back(widget->pos().y());
|
||||||
|
geo.push_back(widget->size().width());
|
||||||
|
geo.push_back(widget->size().height());
|
||||||
|
geo.push_back(widget->isMaximized());
|
||||||
}
|
}
|
||||||
|
|
||||||
return geo;
|
return geo;
|
||||||
|
@ -110,6 +110,7 @@ public:
|
|||||||
void removeRecentFiles(const QString& file);
|
void removeRecentFiles(const QString& file);
|
||||||
|
|
||||||
std::vector<int> windowGeometryForViewer(QWidget* viewer);
|
std::vector<int> windowGeometryForViewer(QWidget* viewer);
|
||||||
|
std::vector<int> windowGeometryForWidget(QWidget* widget);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent* event);
|
virtual void closeEvent(QCloseEvent* event);
|
||||||
@ -194,11 +195,10 @@ private:
|
|||||||
QToolBar* m_snapshotToolbar;
|
QToolBar* m_snapshotToolbar;
|
||||||
|
|
||||||
|
|
||||||
QFrame* m_CentralFrame;
|
|
||||||
QMdiArea* m_mdiArea;
|
QMdiArea* m_mdiArea;
|
||||||
RiuViewer* m_mainViewer;
|
RiuViewer* m_mainViewer;
|
||||||
RiuResultInfoPanel* m_resultInfoPanel;
|
RiuResultInfoPanel* m_resultInfoPanel;
|
||||||
RiuProcessMonitor* m_processMonitor;
|
RiuProcessMonitor* m_processMonitor;
|
||||||
|
|
||||||
QMenu* m_windowMenu;
|
QMenu* m_windowMenu;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user