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

[CHANGE] - changed first bunch of settings to use QSettings.

parent c20f5d56
......@@ -28,7 +28,6 @@
#include "../common/WIOTools.h"
#include "../common/WPathHelper.h"
#include "../common/WPreferences.h"
#include "../common/WSharedLib.h"
#include "WKernel.h"
......
......@@ -36,7 +36,6 @@
#include "core/common/WAssert.h"
#include "core/common/WProgress.h"
#include "core/common/WPreferences.h"
#include "core/common/math/WUnitSphereCoordinates.h"
#include "core/common/math/WMatrix.h"
#include "core/common/math/WSymmetricSphericalHarmonic.h"
......
......@@ -44,7 +44,6 @@
#include <osgDB/WriteFile>
#include "core/common/WProgress.h"
#include "core/common/WPreferences.h"
#include "core/common/math/linearAlgebra/WLinearAlgebra.h"
#include "core/dataHandler/WSubject.h"
#include "core/dataHandler/WGridRegular3D.h"
......
......@@ -43,7 +43,6 @@
#include "core/common/WAssert.h"
#include "core/common/WLimits.h"
#include "core/common/WPathHelper.h"
#include "core/common/WPreferences.h"
#include "core/common/WProgress.h"
#include "core/dataHandler/WDataHandler.h"
#include "core/dataHandler/WSubject.h"
......@@ -212,14 +211,6 @@ void WMMarchingCubes::properties()
m_isoValueProp = m_properties->addProperty( "Iso value", "The surface will show the area that has this value.", 100., m_recompute );
m_isoValueProp->setMin( wlimits::MIN_DOUBLE );
m_isoValueProp->setMax( wlimits::MAX_DOUBLE );
{
// If set in config file use standard isovalue from config file
double tmpIsoValue;
if( WPreferences::getPreference( "modules.MC.isoValue", &tmpIsoValue ) )
{
m_isoValueProp->set( tmpIsoValue );
}
}
m_opacityProp = m_properties->addProperty( "Opacity %", "Opaqueness of surface.", 100 );
m_opacityProp->setMin( 0 );
......
......@@ -44,7 +44,6 @@
#include "core/common/WPathHelper.h"
#include "core/common/WProgress.h"
#include "core/common/WPreferences.h"
#include "core/common/math/linearAlgebra/WLinearAlgebra.h"
#include "core/common/math/WLinearAlgebraFunctions.h"
#include "core/dataHandler/WDataHandler.h"
......
......@@ -25,7 +25,6 @@
#include <iostream>
#include <fstream>
#include "core/common/WPreferences.h"
#include "core/common/WSegmentationFault.h"
#include "core/common/WLogger.h"
#include "core/common/WLogStream.h"
......
......@@ -46,7 +46,6 @@
#include <QtCore/QSettings>
#include "core/common/WColor.h"
#include "core/common/WPreferences.h"
#include "core/common/WIOTools.h"
#include "core/common/WProjectFileIO.h"
#include "core/common/WPathHelper.h"
......@@ -76,12 +75,14 @@
#include "WQtCustomDockWidget.h"
#include "WQtNavGLWidget.h"
#include "WQtGLDockWidget.h"
#include "WQt4Gui.h"
#include "WMainWindow.h"
#include "WMainWindow.moc"
WMainWindow::WMainWindow() :
WMainWindow::WMainWindow():
QMainWindow(),
m_settings( "OpenWalnut.org", "OpenWalnut" ),
m_currentCompatiblesToolbar( NULL ),
m_iconManager(),
m_navSlicesAlreadyLoaded( false )
......@@ -151,10 +152,6 @@ void WMainWindow::setupGUI()
m_permanentToolBar = new WQtToolBar( "Permanent Toolbar", this );
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
// Set the style of the toolbar
// NOTE: this only works if the toolbar is used with QActions instead of buttons and other widgets
m_permanentToolBar->setToolButtonStyle( getToolbarStyle() );
m_iconManager.addIcon( std::string( "ROI icon" ), box_xpm );
m_iconManager.addIcon( std::string( "Reset icon" ), o_xpm );
m_iconManager.addIcon( std::string( "axial icon" ), axial_xpm );
......@@ -191,8 +188,7 @@ void WMainWindow::setupGUI()
m_menuBar = new QMenuBar( this );
// hide menu?
bool hideMenu = false;
WPreferences::getPreference( "qt4gui.hideMenuBar", &hideMenu );
bool hideMenu = m_settings.value( "qt4gui/hideMenu", false ).toBool();
m_menuBar->setVisible( !hideMenu );
QMenu* fileMenu = m_menuBar->addMenu( "File" );
......@@ -286,23 +282,19 @@ void WMainWindow::setupGUI()
// initially 3 navigation views
{
bool hideWidget;
if( !( WPreferences::getPreference( "qt4gui.hideAxial", &hideWidget ) && hideWidget) )
bool hideNavWidget = m_settings.value( "qt4gui/hideNavigationWidgets", false ).toBool();
if( !hideNavWidget )
{
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Axial View", "Axial View", this, "Axial Slice",
m_mainGLWidget.get() ) );
m_navAxial->setFeatures( QDockWidget::AllDockWidgetFeatures );
m_glDock->addDockWidget( Qt::LeftDockWidgetArea, m_navAxial.get() );
}
if( !( WPreferences::getPreference( "qt4gui.hideCoronal", &hideWidget ) && hideWidget) )
{
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Coronal View", "Coronal View", this, "Coronal Slice",
m_mainGLWidget.get() ) );
m_navCoronal->setFeatures( QDockWidget::AllDockWidgetFeatures );
m_glDock->addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal.get() );
}
if( !( WPreferences::getPreference( "qt4gui.hideSagittal", &hideWidget ) && hideWidget) )
{
m_navSagittal =
boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Sagittal View", "Sagittal View", this, "Sagittal Slice",
m_mainGLWidget.get() ) );
......@@ -311,32 +303,6 @@ void WMainWindow::setupGUI()
}
}
// Default background color from config file
WColor bgColor( 1.0, 1.0, 1.0, 1.0 );
double r;
double g;
double b;
if( WPreferences::getPreference( "ge.bgColor.r", &r )
&& WPreferences::getPreference( "ge.bgColor.g", &g )
&& WPreferences::getPreference( "ge.bgColor.b", &b ) )
{
bgColor.set( r, g, b, 1.0 );
m_mainGLWidget->setBgColor( bgColor );
if( m_navAxial )
{
m_navAxial->getGLWidget()->setBgColor( bgColor );
}
if( m_navCoronal )
{
m_navCoronal->getGLWidget()->setBgColor( bgColor );
}
if( m_navSagittal )
{
m_navSagittal->getGLWidget()->setBgColor( bgColor );
}
}
// Temporarily disabled. We need a proper command prompt implementation first.
// create command prompt toolbar
// m_commandPrompt = new WQtCommandPromptToolbar( "Command Prompt", this );
......@@ -413,8 +379,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 = true;
WPreferences::getPreference( "qt4gui.useAutoDisplay", &useAutoDisplay );
bool useAutoDisplay = m_settings.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.",
......@@ -549,20 +514,6 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
}
}
Qt::ToolButtonStyle WMainWindow::getToolbarStyle() const
{
// this sets the toolbar style
int toolBarStyle = 0;
WPreferences::getPreference( "qt4gui.toolBarStyle", &toolBarStyle );
if( ( toolBarStyle < 0 ) || ( toolBarStyle > 3 ) ) // ensure a valid value
{
toolBarStyle = 0;
}
// cast and return
return static_cast< Qt::ToolButtonStyle >( toolBarStyle );
}
void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
{
if( m_currentCompatiblesToolbar )
......@@ -1028,32 +979,30 @@ void WMainWindow::newRoi()
void WMainWindow::restoreSavedState()
{
// the state name postfix allows especially developers to have multiple OW with different GUI settings.
std::string stateName = "";
stateName = "OpenWalnut";
wlog::info( "MainWindow" ) << "Restoring window state from \"" << stateName << "\"";
wlog::info( "MainWindow" ) << "Restoring window state.";
QSettings setting( "OpenWalnut.org", QString::fromStdString( stateName ) );
restoreGeometry( setting.value( "MainWindowGeometry", "" ).toByteArray() );
restoreState( setting.value( "MainWindowState", "" ).toByteArray() );
restoreGeometry( m_settings.value( "MainWindowGeometry", "" ).toByteArray() );
restoreState( m_settings.value( "MainWindowState", "" ).toByteArray() );
m_glDock->restoreGeometry( setting.value( "GLDockWindowGeometry", "" ).toByteArray() );
m_glDock->restoreState( setting.value( "GLDockWindowState", "" ).toByteArray() );
m_glDock->restoreGeometry( m_settings.value( "GLDockWindowGeometry", "" ).toByteArray() );
m_glDock->restoreState( m_settings.value( "GLDockWindowState", "" ).toByteArray() );
}
void WMainWindow::saveWindowState()
{
std::string stateName = "";
stateName = "OpenWalnut";
wlog::info( "MainWindow" ) << "Saving window state for \"" << stateName << "\"";
wlog::info( "MainWindow" ) << "Saving window state.";
// this saves the window state to some common location on the target OS in user scope.
QSettings setting( "OpenWalnut.org", QString::fromStdString( stateName ) );
setting.setValue( "MainWindowState", saveState() );
setting.setValue( "GLDockWindowState", m_glDock->saveState() );
m_settings.setValue( "MainWindowState", saveState() );
m_settings.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)
setting.setValue( "MainWindowGeometry", saveGeometry() );
setting.setValue( "GLDockWindowGeometry", m_glDock->saveGeometry() );
m_settings.setValue( "MainWindowGeometry", saveGeometry() );
m_settings.setValue( "GLDockWindowGeometry", m_glDock->saveGeometry() );
}
QSettings& WMainWindow::getSettings()
{
return WQt4Gui::getMainWindow()->m_settings;
}
......@@ -35,6 +35,7 @@
#include <boost/thread.hpp>
#include <QtGui/QMainWindow>
#include <QtCore/QSettings>
#include "WIconManager.h"
#include "WQtToolBar.h"
......@@ -117,13 +118,6 @@ public:
*/
void closeCustomDockWidget( std::string title );
/**
* This method returns the default style for ALL toolbars.
*
* \return the toolbar style
*/
Qt::ToolButtonStyle getToolbarStyle() const;
/**
* This method removes the old compatibles toolbar and sets the specified one.
*
......@@ -138,6 +132,12 @@ public:
*/
WQtCombinerToolbar* getCompatiblesToolbar();
/**
* Returns the settings object.
*
* \return settings object.
*/
static QSettings& getSettings();
protected:
/**
......@@ -273,6 +273,11 @@ public slots:
void projectSaveModuleOnly();
private:
/**
* Object storing certain persistent application settings.
*/
QSettings m_settings;
/**
* The currently set compatibles toolbar
*/
......
......@@ -43,17 +43,6 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc
: WQtToolBarBase( "Compatible Modules", parent ),
m_parent( parent )
{
// this sets the toolbar style
int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle );
if( ( compToolBarStyle < 0 ) || ( compToolBarStyle > 3 ) ) // ensure a valid value
{
compToolBarStyle = 0;
}
// cast and set
setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( compToolBarStyle ) );
// create the list of actions possible
addActions( compatibles );
}
......@@ -62,16 +51,6 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent )
: WQtToolBarBase( "Compatible Modules", parent ),
m_parent( parent )
{
// this sets the toolbar style
int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle );
if( ( compToolBarStyle < 0 ) || ( compToolBarStyle > 3 ) ) // ensure a valid value
{
compToolBarStyle = 0;
}
// cast and set
setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( compToolBarStyle ) );
}
WQtCombinerToolbar::~WQtCombinerToolbar()
......
......@@ -33,12 +33,15 @@
#include "core/common/WConditionOneShot.h"
#include "core/common/WFlag.h"
#include "core/common/WLogger.h"
#include "core/common/WColor.h"
#include "core/graphicsEngine/WGE2DManipulator.h"
#include "core/graphicsEngine/WGEViewer.h"
#include "core/graphicsEngine/WGEZoomTrackballManipulator.h"
#include "core/graphicsEngine/WGraphicsEngine.h"
#include "core/kernel/WKernel.h"
#include "WMainWindow.h"
#ifndef __APPLE__
#ifndef _WIN32
#include <osgViewer/api/X11/GraphicsWindowX11>
......@@ -87,6 +90,12 @@ WQtGLWidget::WQtGLWidget( std::string nameOfViewer, QWidget* parent, WGECamera::
connect( &m_Timer, SIGNAL( timeout() ), this, SLOT( updateGL() ) );
m_Timer.start( 10 );
#endif
// set bg color
double bgR = WMainWindow::getSettings().value( "qt4gui/glBGColor/r", 1.0 ).toDouble();
double bgG = WMainWindow::getSettings().value( "qt4gui/glBGColor/g", 1.0 ).toDouble();
double bgB = WMainWindow::getSettings().value( "qt4gui/glBGColor/b", 1.0 ).toDouble();
m_Viewer->setBgColor( WColor( bgR, bgG, bgB, 1.0 ) );
}
WQtGLWidget::~WQtGLWidget()
......@@ -123,11 +132,6 @@ void WQtGLWidget::setCameraManipulator( WQtGLWidget::CameraManipulators manipula
}
}
void WQtGLWidget::setBgColor( const WColor& bgColor )
{
m_Viewer->setBgColor( bgColor );
}
WQtGLWidget::CameraManipulators WQtGLWidget::getCameraManipulators()
{
return m_CurrentManipulator;
......
......@@ -94,12 +94,6 @@ public:
*/
void setCameraManipulator( CameraManipulators manipulator );
/**
* Sets the background color of the widget.
* \param bgColor the new backgorund color
*/
void setBgColor( const WColor& bgColor );
/**
* Returns the actually set camera manipulator.
*
......
......@@ -26,9 +26,11 @@
#include <QtGui/QAction>
#include "WMainWindow.h"
#include "WQtToolBar.h"
WQtToolBar::WQtToolBar( const QString & title, QWidget* parent )
WQtToolBar::WQtToolBar( const QString & title, WMainWindow* parent )
: WQtToolBarBase( title, parent )
{
}
......
......@@ -30,6 +30,8 @@
#include "guiElements/WQtPushButton.h"
#include "WQtToolBarBase.h"
class WMainWindow;
/**
* This is a toolbar. Its main usage for now is the "compatible modules" toolbar
*/
......@@ -41,7 +43,7 @@ public:
* \param title name of the toolbar.
* \param parent the parent widget of this widget, i.e. the widget that manages it.
*/
WQtToolBar( const QString & title, QWidget* parent );
WQtToolBar( const QString & title, WMainWindow* parent );
/**
* destructor
......
......@@ -22,10 +22,13 @@
//
//---------------------------------------------------------------------------
#include "WMainWindow.h"
#include "WQtToolBarBase.h"
WQtToolBarBase::WQtToolBarBase( const QString & title, QWidget* parent ):
QToolBar( title, parent )
WQtToolBarBase::WQtToolBarBase( const QString & title, WMainWindow* parent ):
QToolBar( title, parent ),
m_mainWindow( parent )
{
setObjectName( title );
......@@ -33,6 +36,10 @@ WQtToolBarBase::WQtToolBarBase( const QString & title, QWidget* parent ):
setMinimumWidth( 60 );
setMinimumHeight( 40 );
// Set the style of the toolbar
setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( m_mainWindow->getSettings().value( "qt4gui/toolbarStyle",
Qt::ToolButtonIconOnly ).toInt() ) );
}
WQtToolBarBase::~WQtToolBarBase()
......@@ -50,23 +57,46 @@ QMenu* WQtToolBarBase::getStyleMenu( QString title ) const
QAction* tbStyleMenuActionTextOnly = new QAction( "Text Only", tbStyleMenuGroup );
QAction* tbStyleMenuActionTextBesidesIcon = new QAction( "Text besides Icon", tbStyleMenuGroup );
QAction* tbStyleMenuActionTextUnderIcon = new QAction( "Text under Icon", tbStyleMenuGroup );
QAction* tbStyleMenuActionStyle = new QAction( "Follow Style", tbStyleMenuGroup );
tbStyleMenuActionIconOnly->setCheckable( true );
tbStyleMenuActionTextOnly->setCheckable( true );
tbStyleMenuActionTextBesidesIcon->setCheckable( true );
tbStyleMenuActionTextUnderIcon->setCheckable( true );
tbStyleMenuActionStyle->setCheckable( true );
tbStyleMenuActionIconOnly->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionTextOnly->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionTextBesidesIcon->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionTextUnderIcon->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionStyle->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionIconOnly->setChecked( true );
// set stored default
int style = m_mainWindow->getSettings().value( "qt4gui/toolbarStyle", Qt::ToolButtonIconOnly ).toInt();
switch( style )
{
case Qt::ToolButtonIconOnly:
tbStyleMenuActionIconOnly->setChecked( true );
break;
case Qt::ToolButtonTextOnly:
tbStyleMenuActionTextOnly->setChecked( true );
break;
case Qt::ToolButtonTextBesideIcon:
tbStyleMenuActionTextBesidesIcon->setChecked( true );
break;
case Qt::ToolButtonTextUnderIcon:
tbStyleMenuActionTextUnderIcon->setChecked( true );
break;
case Qt::ToolButtonFollowStyle:
tbStyleMenuActionStyle->setChecked( true );
break;
}
tbStyleMenu->addAction( tbStyleMenuActionIconOnly );
tbStyleMenu->addAction( tbStyleMenuActionTextOnly );
tbStyleMenu->addAction( tbStyleMenuActionTextBesidesIcon );
tbStyleMenu->addAction( tbStyleMenuActionTextUnderIcon );
tbStyleMenu->addAction( tbStyleMenuActionStyle );
return tbStyleMenu;
}
......
......@@ -28,6 +28,8 @@
#include <QtGui/QToolBar>
#include <QtGui/QMenu>
class WMainWindow;
/**
* Base class for toolbars.
*/
......@@ -39,7 +41,7 @@ public:
* \param title name of the toolbar.
* \param parent the parent widget of this widget, i.e. the widget that manages it.
*/
WQtToolBarBase( const QString & title, QWidget* parent );
WQtToolBarBase( const QString & title, WMainWindow* parent );
/**
* Destructor.
......@@ -56,6 +58,11 @@ public:
protected:
private:
/**
* The main window parent.
*/
WMainWindow* m_mainWindow;
};
#endif // WQTTOOLBARBASE_H
......
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