Commit 3b9f3532 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - removed the following preferences: useToolBarBreak, toolBarPos and...

[CHANGE] - removed the following preferences: useToolBarBreak, toolBarPos and compatiblesToolBarPos. They are not needed anymore. Simply drag the toolbars using the mouse to the desired position. The GUI stores this settings for you. In addition, several dirty dummyButton stuff was unified and now works properly for horizontal AND vertical toolbars.
parent 26e6c075
......@@ -26,7 +26,6 @@
####################################################################
# Toolbars
# useToolBarBreak = no # put compatibles toolbar in separate row
useAutoDisplay = no # automatically add a standard module after loading a data module.
# The next property controls the style of ALL toolbars in OpenWalnut.
......@@ -37,16 +36,6 @@ useAutoDisplay = no # automatically add a standard module after loading a data m
toolBarStyle = 0
compatiblesToolBarStyle = 0 # this pref allows the compatibles toolbar to have a different style (overrides toolBarStyle)
# Position of the compatibles toolbar
# 0 -> top
# 1 -> bottom
# 2 -> left
# 3 -> right
# 4 -> hide completely
# 5 -> inside the control panel ( not possible for compatiblesToolBarPos! This will be mapped to right (=3) )
toolBarPos = 0 # default position of the toolbars
compatiblesToolBarPos = 0 # position of the compatibles toolbar (overrides toolBarPos)
####################################################################
# Control panel
......
......@@ -29,7 +29,6 @@ whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbi
####################################################################
# Toolbars
# useToolBarBreak = no # put compatibles toolbar in separate row
# useAutoDisplay = no # automatically add a standard module after loading a data module.
# The next property controls the style of ALL toolbars in OpenWalnut.
......@@ -40,16 +39,6 @@ whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbi
toolBarStyle = 0
compatiblesToolBarStyle = 0 # this pref allows the compatibles toolbar to have a different style (overrides toolBarStyle)
# Position of the compatibles toolbar
# 0 -> top
# 1 -> bottom
# 2 -> left
# 3 -> right
# 4 -> hide completely
# 5 -> inside the control panel ( not possible for compatiblesToolBarPos! This will be mapped to right (=3) )
toolBarPos = 0 # default position of the toolbars
compatiblesToolBarPos = 0 # position of the compatibles toolbar (overrides toolBarPos)
####################################################################
# Control panel
......
......@@ -339,20 +339,7 @@ void WMainWindow::setupPermanentToolBar()
m_permanentToolBar->addWidget( roiButton );
m_permanentToolBar->addSeparator();
if( getToolbarPos() == InControlPanel )
{
m_controlPanel->addToolbar( m_permanentToolBar );
//m_controlPanel->setTitleBarWidget( m_permanentToolBar );
}
else if( getToolbarPos() == Hide )
{
m_permanentToolBar->setVisible( false );
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
}
else
{
addToolBar( toQtToolBarArea( getToolbarPos() ), m_permanentToolBar );
}
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
}
void WMainWindow::autoAdd( boost::shared_ptr< WModule > module, std::string proto )
......@@ -562,48 +549,6 @@ Qt::ToolButtonStyle WMainWindow::getToolbarStyle() const
return static_cast< Qt::ToolButtonStyle >( toolBarStyle );
}
WMainWindow::ToolBarPosition WMainWindow::getToolbarPos()
{
int toolbarPos = 0;
WPreferences::getPreference( "qt4gui.toolBarPos", &toolbarPos );
return static_cast< ToolBarPosition >( toolbarPos );
}
WMainWindow::ToolBarPosition WMainWindow::getCompatiblesToolbarPos()
{
int compatiblesToolbarPos = 0;
if( !WPreferences::getPreference( "qt4gui.compatiblesToolBarPos", &compatiblesToolbarPos ) )
{
return getToolbarPos();
}
return static_cast< ToolBarPosition >( compatiblesToolbarPos );
}
Qt::ToolBarArea WMainWindow::toQtToolBarArea( ToolBarPosition pos )
{
switch ( pos )
{
case Top:
return Qt::TopToolBarArea;
break;
case Bottom:
return Qt::BottomToolBarArea;
break;
case Left:
return Qt::LeftToolBarArea;
break;
case Right:
return Qt::RightToolBarArea;
break;
case InControlPanel:
return Qt::RightToolBarArea;
default:
return Qt::NoToolBarArea;
break;
}
}
void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
{
if( m_currentCompatiblesToolbar )
......@@ -612,16 +557,6 @@ void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
}
m_currentCompatiblesToolbar = toolbar;
// hide it?
if( getCompatiblesToolbarPos() == Hide )
{
if( toolbar )
{
toolbar->setVisible( false );
}
return;
}
if( !toolbar )
{
// ok, reset the toolbar
......@@ -629,18 +564,8 @@ void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
m_currentCompatiblesToolbar = new WQtCombinerToolbar( this );
}
// optional toolbar break
{
bool useToolBarBreak = true;
WPreferences::getPreference( "qt4gui.useToolBarBreak", &useToolBarBreak );
if( useToolBarBreak )
{
addToolBarBreak( toQtToolBarArea( getCompatiblesToolbarPos() ) );
}
}
// and the position of the toolbar
addToolBar( toQtToolBarArea( getCompatiblesToolbarPos() ), m_currentCompatiblesToolbar );
addToolBar( Qt::TopToolBarArea, m_currentCompatiblesToolbar );
}
WQtCombinerToolbar* WMainWindow::getCompatiblesToolbar()
......@@ -1126,13 +1051,15 @@ void WMainWindow::restoreSavedState()
}
// the state name postfix allows especially developers to have multiple OW with different GUI settings.
std::string postfix = "";
if ( WPreferences::getPreference( "qt4gui.stateNamePostfix", &postfix ) )
std::string stateName = "";
if ( WPreferences::getPreference( "qt4gui.stateNamePostfix", &stateName ) )
{
postfix = "-" + postfix;
stateName = "-" + stateName;
}
stateName = "OpenWalnut" + stateName;
wlog::info( "MainWindow" ) << "Restoring window state from \"" << stateName << "\"";
QSettings setting( "OpenWalnut.org", "OpenWalnut" + QString::fromStdString( postfix ) );
QSettings setting( "OpenWalnut.org", QString::fromStdString( stateName ) );
QByteArray state = setting.value( "MainWindowState", "" ).toByteArray();
restoreGeometry( setting.value( "MainWindowGeometry", "" ).toByteArray() );
restoreState( state );
......@@ -1148,16 +1075,17 @@ void WMainWindow::saveWindowState()
return;
}
// the state name postfix allows especially developers to have multiple OW with different GUI settings.
std::string postfix = "";
if ( WPreferences::getPreference( "qt4gui.stateNamePostfix", &postfix ) )
std::string stateName = "";
if ( WPreferences::getPreference( "qt4gui.stateNamePostfix", &stateName ) )
{
postfix = "-" + postfix;
stateName = "-" + stateName;
}
stateName = "OpenWalnut" + stateName;
wlog::info( "MainWindow" ) << "Saving window state for \"" << stateName << "\"";
// this saves the window state to some common location on the target OS in user scope.
QByteArray state = saveState();
QSettings setting( "OpenWalnut.org", "OpenWalnut" + QString::fromStdString( postfix ) );
QSettings setting( "OpenWalnut.org", QString::fromStdString( stateName ) );
setting.setValue( "MainWindowState", state );
// NOTE: Qt Doc says that saveState also saves geometry. But this somehow is wrong (at least for 4.6.3)
setting.setValue( "MainWindowGeometry", saveGeometry() );
......
......@@ -123,42 +123,6 @@ public:
*/
Qt::ToolButtonStyle getToolbarStyle() const;
/**
* All possible positions of the toolbars.
*/
typedef enum
{
Top = 0,
Bottom,
Left,
Right,
Hide,
InControlPanel
}
ToolBarPosition;
/**
* Returns the preferred position of toolbars.
*
* \return QT Position for the toolbars used as default for all toolbars.
*/
static ToolBarPosition getToolbarPos();
/**
* Returns the preferred position of toolbars.
*
* \return QT Position for the toolbars used as default for the compatibles toolbars.
*/
static ToolBarPosition getCompatiblesToolbarPos();
/**
* Converts the specified position to the appropriate qt toolbar area constant. Unknown positions (InControlPanel, Hide) are converted to
* Qt::NoToolBarArea.
*
* \param pos the position to convert.
*/
static Qt::ToolBarArea toQtToolBarArea( ToolBarPosition pos );
/**
* This method removes the old compatibles toolbar and sets the specified one.
*
......
......@@ -26,6 +26,7 @@
#include <QtGui/QAction>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
#include <QtGui/QMenu>
#include "../../common/WPreferences.h"
......@@ -43,6 +44,7 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc
{
// setup toolbar
setAllowedAreas( Qt::AllToolBarAreas );
setObjectName( QString( "Compatible Modules" ) );
// this sets the toolbar style
int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
......@@ -96,23 +98,16 @@ void WQtCombinerToolbar::updateButtons( const WQtCombinerActionList& compatibles
{
clear();
addActions( compatibles );
insertDummyButton();
}
void WQtCombinerToolbar::insertDummyButton()
{
// The following makes the bar having button size.
QPushButton* dummyButton = new QPushButton;
if ( ( m_parent->toQtToolBarArea( m_parent->getCompatiblesToolbarPos() ) == Qt::TopToolBarArea ) ||
( m_parent->toQtToolBarArea( m_parent->getCompatiblesToolbarPos() ) == Qt::BottomToolBarArea ) )
{
dummyButton->setFixedWidth( 0 );
dummyButton->setFixedHeight( 30 );
}
else
{
dummyButton->setFixedWidth( 48 ); // well this size must be more than 32 as there might be these little submenu arrows besides the icon
dummyButton->setFixedHeight( 0 );
}
addWidget( dummyButton );
// this is needed to ensure a constant height or width (if toolbar is in vertical mode). We use a label as an empty label has no graphical
// representation. The width and height are set both because we do not know a priori how the toolbar is oriented as it might change after
// creation.
QLabel* dummy = new QLabel;
dummy->setFixedWidth( 50 );
dummy->setFixedHeight( 30 );
addWidget( dummy );
}
......@@ -262,7 +262,6 @@ void WQtConfigWidget::registerComponents()
m_skipPropertyWrite.push_back( "ge.sColorWidget" );
m_defaultProperties->addProperty( "qt4gui.useAutoDisplay", "use Auto Display", true, m_propCondition );
m_defaultProperties->addProperty( "qt4gui.useToolBarBreak", "use ToolBarBreak", true, m_propCondition );
WPropInt tbs = m_defaultProperties->addProperty( "qt4gui.toolBarStyle", "The style of all toolbars in OpenWalnut", 0, m_propCondition );
WPropInt ctbs = m_defaultProperties->addProperty( "qt4gui.compatiblesToolBarStyle", "The style of all compatibles toolbar in OpenWalnut", 0,
m_propCondition );
......@@ -270,14 +269,7 @@ void WQtConfigWidget::registerComponents()
tbs->setMax( 3 );
ctbs->setMin( 0 );
ctbs->setMax( 3 );
WPropInt tbpos = m_defaultProperties->addProperty( "qt4gui.toolBarPos", "The position of the toolbar in OpenWalnut", 0,
m_propCondition );
WPropInt ctbpos = m_defaultProperties->addProperty( "qt4gui.compatiblesToolBarPos", "The position of the compatibles toolbar in OpenWalnut", 0,
m_propCondition );
tbpos->setMin( 0 );
tbpos->setMax( 5 );
ctbpos->setMin( 0 );
ctbpos->setMax( 5 );
m_defaultProperties->addProperty( "qt4gui.hideMenuBar", "Hide the menu bar.", false, m_propCondition );
WPropGroup moduleWhiteList = m_defaultProperties->addPropertyGroup( "modules.whiteListGroup", "moduleWhiteList" );
......
......@@ -31,7 +31,9 @@
WQtToolBar::WQtToolBar( const QString & title, QWidget* parent )
: QToolBar( title, parent )
{
this->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
setObjectName( title );
this->setAllowedAreas( Qt::AllToolBarAreas );
// The following makes the bar having button size from the beginning.
QPushButton* dummyButton = new QPushButton;
......
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