Commit 97808b83 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX] - permanent toolbar now also uses QActions. This creates a more...

[FIX] - permanent toolbar now also uses QActions. This creates a more consistent look. Additionally, set minimum Width and Height for the toolbar a little bit larger because some had problems with them (too small).
parent 3c809505
......@@ -286,28 +286,26 @@ void WMainWindow::setupPermanentToolBar()
m_iconManager.addIcon( std::string( "coronal icon" ), cor_xpm );
m_iconManager.addIcon( std::string( "sagittal icon" ), sag_xpm );
// TODO(all): this should be QActions to allow the toolbar style to work properly
m_loadButton = new WQtPushButton( m_iconManager.getIcon( "load" ), "load", m_permanentToolBar );
WQtPushButton* roiButton = new WQtPushButton( m_iconManager.getIcon( "ROI icon" ), "ROI", m_permanentToolBar );
WQtPushButton* resetButton = new WQtPushButton( m_iconManager.getIcon( "Reset icon" ), "Reset", m_permanentToolBar );
m_loadButton = new QAction( m_iconManager.getIcon( "load" ), "load", m_permanentToolBar );
QAction* roiButton = new QAction( m_iconManager.getIcon( "ROI icon" ), "ROI", m_permanentToolBar );
QAction* resetButton = new QAction( m_iconManager.getIcon( "Reset icon" ), "Reset", m_permanentToolBar );
resetButton->setShortcut( QKeySequence( Qt::Key_Escape ) );
WQtPushButton* projectLoadButton = new WQtPushButton( m_iconManager.getIcon( "loadProject" ), "loadProject", m_permanentToolBar );
WQtPushButton* projectSaveButton = new WQtPushButton( m_iconManager.getIcon( "saveProject" ), "saveProject", m_permanentToolBar );
QAction* projectLoadButton = new QAction( m_iconManager.getIcon( "loadProject" ), "loadProject", m_permanentToolBar );
QAction* projectSaveButton = new QAction( m_iconManager.getIcon( "saveProject" ), "saveProject", m_permanentToolBar );
// setup save button
QMenu* saveMenu = new QMenu( "Save Project", projectSaveButton );
QMenu* saveMenu = new QMenu( "Save Project" );
saveMenu->addAction( "Save Project", this, SLOT( projectSaveAll() ) );
saveMenu->addAction( "Save Modules", this, SLOT( projectSaveModuleOnly() ) );
saveMenu->addAction( "Save Camera", this, SLOT( projectSaveCameraOnly() ) );
saveMenu->addAction( "Save ROIs", this, SLOT( projectSaveROIOnly() ) );
projectSaveButton->setPopupMode( QToolButton::MenuButtonPopup );
projectSaveButton->setMenu( saveMenu );
connect( m_loadButton, SIGNAL( pressed() ), this, SLOT( openLoadDialog() ) );
connect( resetButton, SIGNAL( pressed() ), m_mainGLWidget.get(), SLOT( reset() ) );
connect( roiButton, SIGNAL( pressed() ), this, SLOT( newRoi() ) );
connect( projectLoadButton, SIGNAL( pressed() ), this, SLOT( projectLoad() ) );
connect( projectSaveButton, SIGNAL( pressed() ), this, SLOT( projectSaveAll() ) );
connect( m_loadButton, SIGNAL( triggered( bool ) ), this, SLOT( openLoadDialog() ) );
connect( resetButton, SIGNAL( triggered( bool ) ), m_mainGLWidget.get(), SLOT( reset() ) );
connect( roiButton, SIGNAL( triggered( bool ) ), this, SLOT( newRoi() ) );
connect( projectLoadButton, SIGNAL( triggered( bool ) ), this, SLOT( projectLoad() ) );
connect( projectSaveButton, SIGNAL( triggered( bool ) ), this, SLOT( projectSaveAll() ) );
m_loadButton->setToolTip( "Load Data" );
resetButton->setToolTip( "Reset main view" );
......@@ -315,13 +313,13 @@ void WMainWindow::setupPermanentToolBar()
projectLoadButton->setToolTip( "Load a project from file" );
projectSaveButton->setToolTip( "Save current project to file" );
m_permanentToolBar->addWidget( m_loadButton );
m_permanentToolBar->addAction( m_loadButton );
m_permanentToolBar->addSeparator();
m_permanentToolBar->addWidget( projectLoadButton );
m_permanentToolBar->addWidget( projectSaveButton );
m_permanentToolBar->addAction( projectLoadButton );
m_permanentToolBar->addAction( projectSaveButton );
m_permanentToolBar->addSeparator();
m_permanentToolBar->addWidget( resetButton );
m_permanentToolBar->addWidget( roiButton );
m_permanentToolBar->addAction( resetButton );
m_permanentToolBar->addAction( roiButton );
m_permanentToolBar->addSeparator();
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
......@@ -711,9 +709,6 @@ void WMainWindow::openLoadDialog()
}
m_loaderSignal( stdFileNames );
// walkaround that a button keeps his down state after invoking a dialog
m_loadButton->setDown( false );
}
void WMainWindow::openAboutQtDialog()
......
......@@ -293,7 +293,7 @@ private:
WQtToolBar* m_permanentToolBar; //!< The permanent toolbar of the main window.
WQtPushButton* m_loadButton; //!< the load Data Button
QAction* m_loadButton; //!< the load Data Button
WQtControlPanel* m_controlPanel; //!< control panel
......
......@@ -46,8 +46,8 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc
setAllowedAreas( Qt::AllToolBarAreas );
setObjectName( QString( "Compatible Modules" ) );
setMinimumWidth( 50 );
setMinimumHeight( 30 );
setMinimumWidth( 60 );
setMinimumHeight( 40 );
// this sets the toolbar style
int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
......
......@@ -35,33 +35,17 @@ WQtToolBar::WQtToolBar( const QString & title, QWidget* parent )
this->setAllowedAreas( Qt::AllToolBarAreas );
setMinimumWidth( 50 );
setMinimumHeight( 30 );
setMinimumWidth( 60 );
setMinimumHeight( 40 );
}
WQtToolBar::~WQtToolBar()
{
}
WQtPushButton* WQtToolBar::addPushButton( QString name, QIcon icon, QString label )
{
WQtPushButton* button = new WQtPushButton( icon, label, this, label );
button->setName( name );
addWidget( button );
return button;
}
QAction* WQtToolBar::addWidget( QWidget* widget )
{
m_widgets.push_back( widget );
return QToolBar::addWidget( widget );
}
void WQtToolBar::addAction( QAction* action )
{
m_actions.push_back( action );
QToolBar::addAction( action );
}
......@@ -70,12 +54,12 @@ void WQtToolBar::clearButtons()
clear();
// iterate all items and delete them
for ( std::list< QWidget* >::iterator it = m_widgets.begin(); it != m_widgets.end(); ++it )
for ( std::list< QAction* >::iterator it = m_actions.begin(); it != m_actions.end(); ++it )
{
delete ( *it );
}
// clear the lists
m_widgets.clear();
m_actions.clear();
}
......@@ -49,23 +49,6 @@ public:
*/
virtual ~WQtToolBar();
/**
* Adds a push button to the toolbar. The button is identifiable by its name.
* \param name a name for the new button to identifie it
* \param icon and icon for the button
* \param label The optional text that is displayed besides the icon on the button.
*/
WQtPushButton* addPushButton( QString name, QIcon icon, QString label = 0 );
/**
* Add a widget to the toolbar. This also stores the reference and removes it if clearButtons is called.
*
* \param widget the widget to add
*
* \return the corresponding action object
*/
QAction* addWidget( QWidget* widget );
/**
* Allows addition of new actions to the toolbar. See the Qt Doc of QToolBar for details. Actions have the advantage that they build a
* uniform interface for menus, toolbars, buttons and menued toolbuttons.
......@@ -84,7 +67,7 @@ protected:
/**
* The list of widgets in this toolbar.
*/
std::list< QWidget* > m_widgets;
std::list< QAction* > m_actions;
private:
};
......
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