Commit e6a89632 by Sebastian Eichelbaum

[CHANGE] - added some more config options to move the toolbars to the dataset browser or hide them

parent 91ed945c
......@@ -35,6 +35,8 @@ compatiblesToolBarStyle = 0 # this pref allows the compatibles toolbar to have a
# 1 -> bottom
# 2 -> left
# 3 -> right
# 4 -> hide completely
# 5 -> inside the dataset browser ( 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)
......
......@@ -41,6 +41,8 @@ compatiblesToolBarStyle = 0 # this pref allows the compatibles toolbar to have a
# 1 -> bottom
# 2 -> left
# 3 -> right
# 4 -> hide completely
# 5 -> inside the dataset browser ( 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)
......
......@@ -293,7 +293,21 @@ void WMainWindow::setupPermanentToolBar()
m_permanentToolBar->addWidget( roiButton );
m_permanentToolBar->addSeparator();
addToolBar( WMainWindow::getToolbarPos(), m_permanentToolBar );
if ( getToolbarPos() == InDSB )
{
m_datasetBrowser->addToolbar( m_permanentToolBar );
//m_datasetBrowser->setTitleBarWidget( m_permanentToolBar );
}
else if ( getToolbarPos() == Hide )
{
m_permanentToolBar->setVisible( false );
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
}
else
{
addToolBar( toQtToolBarArea( getToolbarPos() ), m_permanentToolBar );
}
}
void WMainWindow::autoAdd( boost::shared_ptr< WModule > module, std::string proto )
......@@ -465,31 +479,46 @@ Qt::ToolButtonStyle WMainWindow::getToolbarStyle() const
return static_cast< Qt::ToolButtonStyle >( toolBarStyle );
}
Qt::ToolBarArea WMainWindow::getToolbarPos()
WMainWindow::ToolBarPosition WMainWindow::getToolbarPos()
{
int toolbarPos = 0;
WPreferences::getPreference( "qt4gui.toolBarPos", &toolbarPos );
return static_cast< ToolBarPosition >( toolbarPos );
}
WMainWindow::ToolBarPosition WMainWindow::getCompatiblesToolbarPos()
{
int compatiblesToolbarPos = 0;
WPreferences::getPreference( "qt4gui.compatiblesToolBarPos", &compatiblesToolbarPos );
Qt::ToolBarArea pos = Qt::TopToolBarArea;
switch ( compatiblesToolbarPos )
if ( !WPreferences::getPreference( "qt4gui.compatiblesToolBarPos", &compatiblesToolbarPos ) )
{
case 0:
pos = Qt::TopToolBarArea;
return getToolbarPos();
}
return static_cast< ToolBarPosition >( compatiblesToolbarPos );
}
Qt::ToolBarArea WMainWindow::toQtToolBarArea( ToolBarPosition pos )
{
switch ( pos )
{
case Top:
return Qt::TopToolBarArea;
break;
case 1:
pos = Qt::BottomToolBarArea;
case Bottom:
return Qt::BottomToolBarArea;
break;
case 2:
pos = Qt::LeftToolBarArea;
case Left:
return Qt::LeftToolBarArea;
break;
case 3:
pos = Qt::RightToolBarArea;
case Right:
return Qt::RightToolBarArea;
break;
case InDSB:
return Qt::RightToolBarArea;
default:
pos = Qt::TopToolBarArea;
return Qt::NoToolBarArea;
break;
}
return pos;
}
}
void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
......@@ -500,6 +529,16 @@ 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
......@@ -513,12 +552,12 @@ void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
WPreferences::getPreference( "qt4gui.useToolBarBreak", &useToolBarBreak );
if( useToolBarBreak )
{
addToolBarBreak( m_currentCompatiblesToolbar->getCompatiblesToolbarPos() );
addToolBarBreak( toQtToolBarArea( getCompatiblesToolbarPos() ) );
}
}
// and the position of the toolbar
addToolBar( m_currentCompatiblesToolbar->getCompatiblesToolbarPos(), m_currentCompatiblesToolbar );
addToolBar( toQtToolBarArea( getCompatiblesToolbarPos() ), m_currentCompatiblesToolbar );
}
WQtDatasetBrowser* WMainWindow::getDatasetBrowser()
......
......@@ -120,11 +120,40 @@ public:
Qt::ToolButtonStyle getToolbarStyle() const;
/**
* All possible positions of the toolbars.
*/
typedef enum
{
Top = 0,
Bottom,
Left,
Right,
Hide,
InDSB
}
ToolBarPosition;
/**
* Returns the preferred position of toolbars.
*
* \return QT Position for the toolbars used as default for all toolbars.
*/
static Qt::ToolBarArea getToolbarPos();
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 (InDSB, 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.
......
......@@ -62,7 +62,8 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, WCompatiblesList co
// The following makes the bar having button size from the beginning.
QPushButton* dummyButton = new QPushButton;
if ( ( parent->getToolbarPos() == Qt::TopToolBarArea ) || ( ( parent->getToolbarPos() == Qt::BottomToolBarArea ) ) )
if ( ( parent->toQtToolBarArea( parent->getCompatiblesToolbarPos() ) == Qt::TopToolBarArea ) ||
( parent->toQtToolBarArea( parent->getCompatiblesToolbarPos() ) == Qt::BottomToolBarArea ) )
{
dummyButton->setFixedWidth( 0 );
dummyButton->setFixedHeight( 32 );
......@@ -80,30 +81,3 @@ WQtCombinerToolbar::~WQtCombinerToolbar()
{
}
Qt::ToolBarArea WQtCombinerToolbar::getCompatiblesToolbarPos()
{
int compatiblesToolbarPos = -1;
WPreferences::getPreference( "qt4gui.compatiblesToolBarPos", &compatiblesToolbarPos );
Qt::ToolBarArea pos = Qt::TopToolBarArea;
switch ( compatiblesToolbarPos )
{
case 0:
pos = Qt::TopToolBarArea;
break;
case 1:
pos = Qt::BottomToolBarArea;
break;
case 2:
pos = Qt::LeftToolBarArea;
break;
case 3:
pos = Qt::RightToolBarArea;
break;
default:
pos = WMainWindow::getToolbarPos();
break;
}
return pos;
}
......@@ -51,13 +51,6 @@ public:
*/
virtual ~WQtCombinerToolbar();
/**
* Returns the preferred position of compatibles toolbars. This overrides WMainWindow::getToolbarPos().
*
* \return QT Position for the compatibles toolbars
*/
static Qt::ToolBarArea getCompatiblesToolbarPos();
protected:
private:
......
......@@ -77,10 +77,11 @@ WQtDatasetBrowser::WQtDatasetBrowser( WMainWindow* parent )
m_moduleTreeWidget->setMinimumHeight( 250 );
// create context menu for tree items
m_deleteModuleAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "remove" ), "Remove Module", m_moduleTreeWidget );
m_deleteModuleAction->setShortcut( QKeySequence( Qt::Key_Backspace ) );
connect( m_deleteModuleAction, SIGNAL( triggered() ), this, SLOT( deleteModuleTreeItem() ) );
m_moduleTreeWidget->addAction( m_deleteModuleAction );
// a separator to clean up the tree widget's context menu
QAction* separator = new QAction( m_moduleTreeWidget );
separator->setSeparator( true );
m_moduleTreeWidget->addAction( separator );
m_connectWithPrototypeAction = new QAction( "Connect with Prototype", m_moduleTreeWidget );
m_moduleTreeWidget->addAction( m_connectWithPrototypeAction );
......@@ -89,6 +90,14 @@ WQtDatasetBrowser::WQtDatasetBrowser( WMainWindow* parent )
m_disconnectAction = new QAction( "Disconnect", m_moduleTreeWidget );
m_moduleTreeWidget->addAction( m_disconnectAction );
// a separator to clean up the tree widget's context menu
m_moduleTreeWidget->addAction( separator );
m_deleteModuleAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "remove" ), "Remove Module", m_moduleTreeWidget );
m_deleteModuleAction->setShortcut( QKeySequence( Qt::Key_Backspace ) );
connect( m_deleteModuleAction, SIGNAL( triggered() ), this, SLOT( deleteModuleTreeItem() ) );
m_moduleTreeWidget->addAction( m_deleteModuleAction );
m_textureSorter = new WQtTextureSorter( this );
m_textureSorter->setToolTip( "Reorder the textures." );
......@@ -164,6 +173,11 @@ void WQtDatasetBrowser::connectSlots()
this, SLOT( selectDataModule( boost::shared_ptr< WDataSet > ) ) );
}
void WQtDatasetBrowser::addToolbar( QToolBar* tb )
{
m_layout->insertWidget( 0, tb );
}
WQtSubjectTreeItem* WQtDatasetBrowser::addSubject( std::string name )
{
WQtSubjectTreeItem* subject = new WQtSubjectTreeItem( m_moduleTreeWidget );
......
......@@ -154,6 +154,13 @@ public:
*/
QAction* toggleViewAction() const;
/**
* Add the specified toolbar to the top of the dsb.
*
* \param tb the toolbar to add
*/
void addToolbar( QToolBar* tb );
protected:
/**
......
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