Commit fca870db authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - settings are now a singleton in WQt4Gui for easy access

parent b2bbba2a
......@@ -82,7 +82,6 @@
WMainWindow::WMainWindow():
QMainWindow(),
m_settings( "OpenWalnut.org", "OpenWalnut" ),
m_currentCompatiblesToolbar( NULL ),
m_iconManager(),
m_navSlicesAlreadyLoaded( false )
......@@ -188,7 +187,7 @@ void WMainWindow::setupGUI()
m_menuBar = new QMenuBar( this );
// hide menu?
bool hideMenu = m_settings.value( "qt4gui/hideMenu", false ).toBool();
bool hideMenu = WQt4Gui::getSettings().value( "qt4gui/hideMenu", false ).toBool();
m_menuBar->setVisible( !hideMenu );
QMenu* fileMenu = m_menuBar->addMenu( "File" );
......@@ -282,7 +281,7 @@ void WMainWindow::setupGUI()
// initially 3 navigation views
{
bool hideNavWidget = m_settings.value( "qt4gui/hideNavigationWidgets", false ).toBool();
bool hideNavWidget = WQt4Gui::getSettings().value( "qt4gui/hideNavigationWidgets", false ).toBool();
if( !hideNavWidget )
{
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Axial View", "Axial View", this, "Axial Slice",
......@@ -379,7 +378,7 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
// load certain modules for datasets and so on.
// The Data Modules also play an special role. To have modules being activated when certain data got loaded, we need to hook it up here.
bool useAutoDisplay = m_settings.value( "qt4gui/useAutoDisplay", true ).toBool();
bool useAutoDisplay = WQt4Gui::getSettings().value( "qt4gui/useAutoDisplay", true ).toBool();
if( useAutoDisplay && module->getType() == MODULE_DATA )
{
WLogger::getLogger()->addLogMessage( "Auto Display active and Data module added. The proper module will be added.",
......@@ -981,11 +980,11 @@ void WMainWindow::restoreSavedState()
{
wlog::info( "MainWindow" ) << "Restoring window state.";
restoreGeometry( m_settings.value( "MainWindowGeometry", "" ).toByteArray() );
restoreState( m_settings.value( "MainWindowState", "" ).toByteArray() );
restoreGeometry( WQt4Gui::getSettings().value( "MainWindowGeometry", "" ).toByteArray() );
restoreState( WQt4Gui::getSettings().value( "MainWindowState", "" ).toByteArray() );
m_glDock->restoreGeometry( m_settings.value( "GLDockWindowGeometry", "" ).toByteArray() );
m_glDock->restoreState( m_settings.value( "GLDockWindowState", "" ).toByteArray() );
m_glDock->restoreGeometry( WQt4Gui::getSettings().value( "GLDockWindowGeometry", "" ).toByteArray() );
m_glDock->restoreState( WQt4Gui::getSettings().value( "GLDockWindowState", "" ).toByteArray() );
}
void WMainWindow::saveWindowState()
......@@ -993,16 +992,16 @@ void WMainWindow::saveWindowState()
wlog::info( "MainWindow" ) << "Saving window state.";
// this saves the window state to some common location on the target OS in user scope.
m_settings.setValue( "MainWindowState", saveState() );
m_settings.setValue( "GLDockWindowState", m_glDock->saveState() );
WQt4Gui::getSettings().setValue( "MainWindowState", saveState() );
WQt4Gui::getSettings().setValue( "GLDockWindowState", m_glDock->saveState() );
// NOTE: Qt Doc says that saveState also saves geometry. But this somehow is wrong (at least for 4.6.3)
m_settings.setValue( "MainWindowGeometry", saveGeometry() );
m_settings.setValue( "GLDockWindowGeometry", m_glDock->saveGeometry() );
WQt4Gui::getSettings().setValue( "MainWindowGeometry", saveGeometry() );
WQt4Gui::getSettings().setValue( "GLDockWindowGeometry", m_glDock->saveGeometry() );
}
QSettings& WMainWindow::getSettings()
{
return WQt4Gui::getMainWindow()->m_settings;
return WQt4Gui::getSettings();
}
......@@ -273,11 +273,6 @@ public slots:
void projectSaveModuleOnly();
private:
/**
* Object storing certain persistent application settings.
*/
QSettings m_settings;
/**
* The currently set compatibles toolbar
*/
......
......@@ -37,6 +37,8 @@
#include <QtGui/QApplication>
#include <QtGui/QFileDialog>
#include <QtCore/QSettings>
#include "WMainWindow.h" // this has to be included before any other includes
#include "core/common/WConditionOneShot.h"
......@@ -66,13 +68,17 @@
WMainWindow* WQt4Gui::m_mainWindow = NULL;
QSettings* WQt4Gui::m_settings = NULL;
WQt4Gui::WQt4Gui( int argc, char** argv )
: WGUI( argc, argv )
{
m_settings = new QSettings( "OpenWalnut.org", "OpenWalnut" );
}
WQt4Gui::~WQt4Gui()
{
delete m_settings;
}
bool WQt4Gui::parseOptions()
......@@ -375,3 +381,9 @@ void WQt4Gui::closeCustomWidget( std::string title )
{
m_mainWindow->closeCustomDockWidget( title );
}
QSettings& WQt4Gui::getSettings()
{
return *m_settings;
}
......@@ -30,6 +30,8 @@
#include <boost/program_options.hpp>
#include <QtCore/QSettings>
#include "core/graphicsEngine/WROI.h"
#include "core/graphicsEngine/WGraphicsEngine.h"
......@@ -162,6 +164,13 @@ public:
*/
static WMainWindow* getMainWindow();
/**
* Returns the settings object.
*
* \return settings object.
*/
static QSettings& getSettings();
protected:
/**
......@@ -173,6 +182,10 @@ protected:
void moduleError( boost::shared_ptr< WModule > module, const WException& exception );
private:
/**
* Object storing certain persistent application settings.
*/
static QSettings* m_settings;
/**
* Main window containing all needed widgets.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment