Moved setting for main windows geometry and toolbar state to RiuMainWindowBase

This commit is contained in:
Magne Sjaastad 2016-06-24 15:53:04 +02:00
parent aef466087d
commit e92624a862
8 changed files with 145 additions and 133 deletions

View File

@ -710,10 +710,15 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty)
void RiaApplication::onProjectOpenedOrClosed() void RiaApplication::onProjectOpenedOrClosed()
{ {
RiuMainWindow* mainWnd = RiuMainWindow::instance(); RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (!mainWnd) return; if (mainWnd)
{
mainWnd->initializeGuiNewProjectLoaded(); mainWnd->initializeGuiNewProjectLoaded();
//mainWnd->redrawAllViews(); }
RiuMainPlotWindow* mainPlotWnd = RiuMainPlotWindow::instance();
if (mainPlotWnd)
{
mainPlotWnd->initializeGuiNewProjectLoaded();
}
setWindowCaptionFromAppState(); setWindowCaptionFromAppState();
} }

View File

@ -111,6 +111,8 @@ set( USER_INTERFACE_FILES
UserInterface/RiuToolTipMenu.cpp UserInterface/RiuToolTipMenu.cpp
UserInterface/RiuMdiSubWindow.h UserInterface/RiuMdiSubWindow.h
UserInterface/RiuMdiSubWindow.cpp UserInterface/RiuMdiSubWindow.cpp
UserInterface/RiuMainWindowBase.h
UserInterface/RiuMainWindowBase.cpp
) )
set( SOCKET_INTERFACE_FILES set( SOCKET_INTERFACE_FILES
@ -206,6 +208,7 @@ set ( QT_MOC_HEADERS
ProjectDataModel/RimMimeData.h ProjectDataModel/RimMimeData.h
UserInterface/RiuMainWindowBase.h
UserInterface/RiuMainWindow.h UserInterface/RiuMainWindow.h
UserInterface/RiuMainPlotWindow.h UserInterface/RiuMainPlotWindow.h
UserInterface/RiuResultInfoPanel.h UserInterface/RiuResultInfoPanel.h

View File

@ -143,10 +143,8 @@ RiuMainPlotWindow::RiuMainPlotWindow()
// When enableUndoCommandSystem is set false, all commands are executed and deleted immediately // When enableUndoCommandSystem is set false, all commands are executed and deleted immediately
//caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true); //caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true);
// if (sm_mainWindowInstance->isVisible())
{ {
QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)"; setWindowTitle("Summary Plots for ResInsight");
setWindowTitle("ResInsight " + platform);
setDefaultWindowSize(); setDefaultWindowSize();
loadWinGeoAndDockToolBarLayout(); loadWinGeoAndDockToolBarLayout();
showWindow(); showWindow();
@ -649,64 +647,6 @@ void RiuMainPlotWindow::createDockPanels()
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::saveWinGeoAndDockToolBarLayout()
{
// Company and appname set through QCoreApplication
QSettings settings;
QByteArray winGeo = saveGeometry();
settings.setValue("winGeometry", winGeo);
QByteArray layout = saveState(0);
settings.setValue("dockAndToolBarLayout", layout);
settings.setValue("isMaximized", isMaximized());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::loadWinGeoAndDockToolBarLayout()
{
// Company and appname set through QCoreApplication
QSettings settings;
QVariant winGeo = settings.value("winGeometry");
QVariant layout = settings.value("dockAndToolBarLayout");
if (winGeo.isValid())
{
if (restoreGeometry(winGeo.toByteArray()))
{
if (layout.isValid())
{
restoreState(layout.toByteArray(), 0);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::showWindow()
{
// Company and appname set through QCoreApplication
QSettings settings;
showNormal();
QVariant isMax = settings.value("isMaximized", false);
if (isMax.toBool())
{
showMaximized();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -18,8 +18,9 @@
#pragma once #pragma once
#include "RiuMainWindowBase.h"
#include <QEvent> #include <QEvent>
#include <QMainWindow>
#include <QPointer> #include <QPointer>
#include <QMdiArea> #include <QMdiArea>
@ -65,7 +66,7 @@ namespace ssihub
// //
// //
//================================================================================================== //==================================================================================================
class RiuMainPlotWindow : public QMainWindow class RiuMainPlotWindow : public RiuMainWindowBase
{ {
Q_OBJECT Q_OBJECT
@ -73,6 +74,8 @@ public:
RiuMainPlotWindow(); RiuMainPlotWindow();
static RiuMainPlotWindow* instance(); static RiuMainPlotWindow* instance();
virtual QString mainWindowName() { return "RiuMainPlotWindow"; }
void initializeGuiNewProjectLoaded(); void initializeGuiNewProjectLoaded();
void cleanupGuiBeforeProjectClose(); void cleanupGuiBeforeProjectClose();
@ -89,8 +92,6 @@ public:
RiuProcessMonitor* processMonitor(); RiuProcessMonitor* processMonitor();
void hideAllDockWindows(); void hideAllDockWindows();
void loadWinGeoAndDockToolBarLayout();
void showWindow();
void selectAsCurrentItem(caf::PdmObject* object); void selectAsCurrentItem(caf::PdmObject* object);
@ -123,7 +124,6 @@ private:
void createMenus(); void createMenus();
void createToolBars(); void createToolBars();
void createDockPanels(); void createDockPanels();
void saveWinGeoAndDockToolBarLayout();
bool checkForDocumentModifications(); bool checkForDocumentModifications();

View File

@ -646,64 +646,6 @@ void RiuMainWindow::createDockPanels()
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::saveWinGeoAndDockToolBarLayout()
{
// Company and appname set through QCoreApplication
QSettings settings;
QByteArray winGeo = saveGeometry();
settings.setValue("winGeometry", winGeo);
QByteArray layout = saveState(0);
settings.setValue("dockAndToolBarLayout", layout);
settings.setValue("isMaximized", isMaximized());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::loadWinGeoAndDockToolBarLayout()
{
// Company and appname set through QCoreApplication
QSettings settings;
QVariant winGeo = settings.value("winGeometry");
QVariant layout = settings.value("dockAndToolBarLayout");
if (winGeo.isValid())
{
if (restoreGeometry(winGeo.toByteArray()))
{
if (layout.isValid())
{
restoreState(layout.toByteArray(), 0);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::showWindow()
{
// Company and appname set through QCoreApplication
QSettings settings;
showNormal();
QVariant isMax = settings.value("isMaximized", false);
if (isMax.toBool())
{
showMaximized();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -20,8 +20,9 @@
#pragma once #pragma once
#include "RiuMainWindowBase.h"
#include <QEvent> #include <QEvent>
#include <QMainWindow>
#include <QPointer> #include <QPointer>
#include <QMdiArea> #include <QMdiArea>
@ -67,13 +68,15 @@ namespace ssihub
// //
// //
//================================================================================================== //==================================================================================================
class RiuMainWindow : public QMainWindow class RiuMainWindow : public RiuMainWindowBase
{ {
Q_OBJECT Q_OBJECT
public: public:
RiuMainWindow(); RiuMainWindow();
static RiuMainWindow* instance(); static RiuMainWindow* instance();
virtual QString mainWindowName() { return "RiuMainWindow"; }
void initializeGuiNewProjectLoaded(); void initializeGuiNewProjectLoaded();
void cleanupGuiBeforeProjectClose(); void cleanupGuiBeforeProjectClose();
@ -91,8 +94,6 @@ public:
RiuProcessMonitor* processMonitor(); RiuProcessMonitor* processMonitor();
void hideAllDockWindows(); void hideAllDockWindows();
void loadWinGeoAndDockToolBarLayout();
void showWindow();
void selectAsCurrentItem(caf::PdmObject* object); void selectAsCurrentItem(caf::PdmObject* object);
@ -125,7 +126,6 @@ private:
void createMenus(); void createMenus();
void createToolBars(); void createToolBars();
void createDockPanels(); void createDockPanels();
void saveWinGeoAndDockToolBarLayout();
bool checkForDocumentModifications(); bool checkForDocumentModifications();

View File

@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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 "RiuMainWindowBase.h"
#include "QSettings"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainWindowBase::RiuMainWindowBase()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::loadWinGeoAndDockToolBarLayout()
{
// Company and appname set through QCoreApplication
QSettings settings;
QVariant winGeo = settings.value(QString("%1/winGeometry").arg(mainWindowName()));
QVariant layout = settings.value(QString("%1/dockAndToolBarLayout").arg(mainWindowName()));
if (winGeo.isValid())
{
if (restoreGeometry(winGeo.toByteArray()))
{
if (layout.isValid())
{
restoreState(layout.toByteArray(), 0);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::saveWinGeoAndDockToolBarLayout()
{
// Company and appname set through QCoreApplication
QSettings settings;
QByteArray winGeo = saveGeometry();
settings.setValue(QString("%1/winGeometry").arg(mainWindowName()), winGeo);
QByteArray layout = saveState(0);
settings.setValue(QString("%1/dockAndToolBarLayout").arg(mainWindowName()), layout);
settings.setValue(QString("%1/isMaximized").arg(mainWindowName()), isMaximized());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::showWindow()
{
// Company and appname set through QCoreApplication
QSettings settings;
showNormal();
QVariant isMax = settings.value(QString("%1/isMaximized").arg(mainWindowName()), false);
if (isMax.toBool())
{
showMaximized();
}
}

View File

@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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 <QMainWindow>
class RiuMainWindowBase : public QMainWindow
{
Q_OBJECT
public:
RiuMainWindowBase();
virtual QString mainWindowName() = 0;
void loadWinGeoAndDockToolBarLayout();
void saveWinGeoAndDockToolBarLayout();
void showWindow();
};