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

[ADD] - created baseclass for all toolbars in openwalnut.

parent 1025a65d
......@@ -207,9 +207,6 @@ void WMainWindow::setupGUI()
saveMenu->addAction( "Save ROIs Only", this, SLOT( projectSaveROIOnly() ) );
projectSaveButton->setMenu( saveMenu );
fileMenu->addSeparator();
fileMenu->addAction( m_iconManager.getIcon( "config" ), "Config", this, SLOT( openConfigDialog() ) );
fileMenu->addSeparator();
// TODO(all): If all distributions provide a newer QT version we should use QKeySequence::Quit here
//fileMenu->addAction( m_iconManager.getIcon( "quit" ), "Quit", this, SLOT( close() ), QKeySequence( QKeySequence::Quit ) );
fileMenu->addAction( m_iconManager.getIcon( "quit" ), "Quit", this, SLOT( close() ), QKeySequence( Qt::CTRL + Qt::Key_Q ) );
......@@ -217,6 +214,24 @@ void WMainWindow::setupGUI()
// This QAction stuff is quite ugly and complicated some times ... There is no nice constructor which takes name, slot keysequence and so on
// directly -> set shortcuts, and some further properties using QAction's interface
QMenu* viewMenu = m_menuBar->addMenu( "View" );
viewMenu->addAction( "Show Menubar", this, SLOT( showMenuBar() ) );
viewMenu->addAction( "Show Statusbar", this, SLOT( showStatusBar() ) );
viewMenu->addSeparator();
viewMenu->addAction( "Show Navigation Views", this, SLOT( showNavViews() ) );
viewMenu->addSeparator();
viewMenu->addMenu( m_permanentToolBar->getStyleMenu() );
// Camera menu
QMenu* cameraMenu = m_menuBar->addMenu( "Camera" );
cameraMenu->addAction( "Set Background Color", this, SLOT( setBGColor() ) );
cameraMenu->addAction( "Allow Camera Throwing", this, SLOT( setAllowThrow() ) );
cameraMenu->addSeparator();
QMenu* settingsMenu = m_menuBar->addMenu( "Settings" );
settingsMenu->addAction( "Enable Auto-Display", this, SLOT( setAutoDisplay() ) );
// a separate menu for some presets
QMenu* cameraPresetMenu = cameraMenu->addMenu( "Presets" );
QAction* controlPanelTrigger = m_controlPanel->toggleViewAction();
QList< QKeySequence > controlPanelShortcut;
......@@ -228,37 +243,37 @@ void WMainWindow::setupGUI()
// so the user may get confused. It is also not a good idea to take letters as they might be used by OpenSceneGraph widget ( like "S" for
// statistics ).
// By additionally adding the action to the main window, we ensure the action can be triggered even if the menu bar is hidden.
QAction* tmpAction = viewMenu->addAction( m_iconManager.getIcon( "sagittal icon" ), "Left", this, SLOT( setPresetViewLeft() ),
QAction* tmpAction = cameraPresetMenu->addAction( m_iconManager.getIcon( "sagittal icon" ), "Left", this, SLOT( setPresetViewLeft() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_L ) );
tmpAction->setIconVisibleInMenu( true );
this->addAction( tmpAction );
tmpAction = viewMenu->addAction( m_iconManager.getIcon( "sagittal icon" ), "Right", this, SLOT( setPresetViewRight() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_R ) );
tmpAction = cameraPresetMenu->addAction( m_iconManager.getIcon( "sagittal icon" ), "Right", this, SLOT( setPresetViewRight() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_R ) );
tmpAction->setIconVisibleInMenu( true );
this->addAction( tmpAction );
tmpAction = viewMenu->addAction( m_iconManager.getIcon( "axial icon" ), "Superior", this, SLOT( setPresetViewSuperior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_S ) );
tmpAction = cameraPresetMenu->addAction( m_iconManager.getIcon( "axial icon" ), "Superior", this, SLOT( setPresetViewSuperior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_S ) );
tmpAction->setIconVisibleInMenu( true );
this->addAction( tmpAction );
tmpAction = viewMenu->addAction( m_iconManager.getIcon( "axial icon" ), "Inferior", this, SLOT( setPresetViewInferior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_I ) );
tmpAction = cameraPresetMenu->addAction( m_iconManager.getIcon( "axial icon" ), "Inferior", this, SLOT( setPresetViewInferior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_I ) );
tmpAction->setIconVisibleInMenu( true );
this->addAction( tmpAction );
tmpAction = viewMenu->addAction( m_iconManager.getIcon( "coronal icon" ), "Anterior", this, SLOT( setPresetViewAnterior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_A ) );
tmpAction = cameraPresetMenu->addAction( m_iconManager.getIcon( "coronal icon" ), "Anterior", this, SLOT( setPresetViewAnterior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_A ) );
tmpAction->setIconVisibleInMenu( true );
this->addAction( tmpAction );
tmpAction = viewMenu->addAction( m_iconManager.getIcon( "coronal icon" ), "Posterior", this, SLOT( setPresetViewPosterior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_P ) );
tmpAction = cameraPresetMenu->addAction( m_iconManager.getIcon( "coronal icon" ), "Posterior", this, SLOT( setPresetViewPosterior() ),
QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_P ) );
tmpAction->setIconVisibleInMenu( true );
this->addAction( tmpAction );
resetButton->setMenu( viewMenu );
resetButton->setMenu( cameraPresetMenu );
QMenu* helpMenu = m_menuBar->addMenu( "Help" );
helpMenu->addAction( m_iconManager.getIcon( "help" ), "OpenWalnut Help", this, SLOT( openOpenWalnutHelpDialog() ),
......@@ -1011,33 +1026,11 @@ void WMainWindow::newRoi()
}
}
void WMainWindow::openConfigDialog()
{
// TODO(all): we need a nice dialog box here.
QString msg = "OpenWalnut allows you to configure several features. Most of these options are only useful to advanced users. "
"You can have a user-scope configuration in your HOME directory as \".walnut.cfg\". "
"If this file exists, OpenWalnut loads this file. You can also specify a \"walnut.cfg\" in your OpenWalnut directory under "
"\"share/OpenWalnut/\". A default file will be there after installation. The default file is very well documented.";
QMessageBox::information( this, "OpenWalnut - Configuration", msg );
}
void WMainWindow::restoreSavedState()
{
// should we do it?
bool saveStateEnabled = true;
WPreferences::getPreference( "qt4gui.saveState", &saveStateEnabled );
if( !saveStateEnabled )
{
return;
}
// the state name postfix allows especially developers to have multiple OW with different GUI settings.
std::string stateName = "";
if( WPreferences::getPreference( "qt4gui.stateNamePostfix", &stateName ) )
{
stateName = "-" + stateName;
}
stateName = "OpenWalnut" + stateName;
stateName = "OpenWalnut";
wlog::info( "MainWindow" ) << "Restoring window state from \"" << stateName << "\"";
QSettings setting( "OpenWalnut.org", QString::fromStdString( stateName ) );
......@@ -1050,20 +1043,8 @@ void WMainWindow::restoreSavedState()
void WMainWindow::saveWindowState()
{
// should we do it?
bool saveStateEnabled = true;
WPreferences::getPreference( "qt4gui.saveState", &saveStateEnabled );
if( !saveStateEnabled )
{
return;
}
std::string stateName = "";
if( WPreferences::getPreference( "qt4gui.stateNamePostfix", &stateName ) )
{
stateName = "-" + stateName;
}
stateName = "OpenWalnut" + stateName;
stateName = "OpenWalnut";
wlog::info( "MainWindow" ) << "Saving window state for \"" << stateName << "\"";
// this saves the window state to some common location on the target OS in user scope.
......
......@@ -272,11 +272,6 @@ public slots:
*/
void projectSaveModuleOnly();
/**
* Gets called when menu option or toolbar button load is activated
*/
void openConfigDialog();
private:
/**
* The currently set compatibles toolbar
......
......@@ -40,16 +40,9 @@
#include "WQtCombinerToolbar.moc"
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerActionList& compatibles )
: QToolBar( "Compatible Modules", parent ),
: WQtToolBarBase( "Compatible Modules", parent ),
m_parent( parent )
{
// setup toolbar
setAllowedAreas( Qt::AllToolBarAreas );
setObjectName( QString( "Compatible Modules" ) );
setMinimumWidth( 60 );
setMinimumHeight( 40 );
// this sets the toolbar style
int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle );
......@@ -66,12 +59,9 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc
}
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent )
: QToolBar( "Compatible Modules", parent ),
: WQtToolBarBase( "Compatible Modules", parent ),
m_parent( parent )
{
// setup toolbar
setAllowedAreas( Qt::AllToolBarAreas );
// this sets the toolbar style
int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle );
......
......@@ -30,13 +30,14 @@
#include "core/kernel/WModuleCombinerTypes.h"
#include "WQtCombinerActionList.h"
#include "WQtToolBarBase.h"
class WMainWindow;
/**
* This is a toolbar. Its main usage for now is the "compatible modules" toolbar.
*/
class WQtCombinerToolbar : public QToolBar
class WQtCombinerToolbar : public WQtToolBarBase
{
Q_OBJECT
......
......@@ -29,14 +29,8 @@
#include "WQtToolBar.h"
WQtToolBar::WQtToolBar( const QString & title, QWidget* parent )
: QToolBar( title, parent )
: WQtToolBarBase( title, parent )
{
setObjectName( title );
this->setAllowedAreas( Qt::AllToolBarAreas );
setMinimumWidth( 60 );
setMinimumHeight( 40 );
}
WQtToolBar::~WQtToolBar()
......
......@@ -27,14 +27,13 @@
#include <list>
#include <QtGui/QToolBar>
#include "guiElements/WQtPushButton.h"
#include "WQtToolBarBase.h"
/**
* This is a toolbar. Its main usage for now is the "compatible modules" toolbar
*/
class WQtToolBar : public QToolBar
class WQtToolBar : public WQtToolBarBase
{
public:
/**
......@@ -42,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.
*/
explicit WQtToolBar( const QString & title, QWidget* parent );
WQtToolBar( const QString & title, QWidget* parent );
/**
* destructor
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WQtToolBarBase.h"
WQtToolBarBase::WQtToolBarBase( const QString & title, QWidget* parent ):
QToolBar( title, parent )
{
setObjectName( title );
setAllowedAreas( Qt::AllToolBarAreas );
setMinimumWidth( 60 );
setMinimumHeight( 40 );
}
WQtToolBarBase::~WQtToolBarBase()
{
// cleanup
}
QMenu* WQtToolBarBase::getStyleMenu( QString title ) const
{
QMenu* tbStyleMenu = new QMenu( title );
// create radio-button like behaviour
QActionGroup* tbStyleMenuGroup = new QActionGroup( tbStyleMenu );
QAction* tbStyleMenuActionIconOnly = new QAction( "Icon Only", tbStyleMenuGroup );
QAction* tbStyleMenuActionTextOnly = new QAction( "Text Only", tbStyleMenuGroup );
QAction* tbStyleMenuActionTextBesidesIcon = new QAction( "Text besides Icon", tbStyleMenuGroup );
QAction* tbStyleMenuActionTextUnderIcon = new QAction( "Text under Icon", tbStyleMenuGroup );
tbStyleMenuActionIconOnly->setCheckable( true );
tbStyleMenuActionTextOnly->setCheckable( true );
tbStyleMenuActionTextBesidesIcon->setCheckable( true );
tbStyleMenuActionTextUnderIcon->setCheckable( true );
tbStyleMenuActionIconOnly->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionTextOnly->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionTextBesidesIcon->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionTextUnderIcon->setActionGroup( tbStyleMenuGroup );
tbStyleMenuActionIconOnly->setChecked( true );
tbStyleMenu->addAction( tbStyleMenuActionIconOnly );
tbStyleMenu->addAction( tbStyleMenuActionTextOnly );
tbStyleMenu->addAction( tbStyleMenuActionTextBesidesIcon );
tbStyleMenu->addAction( tbStyleMenuActionTextUnderIcon );
return tbStyleMenu;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WQTTOOLBARBASE_H
#define WQTTOOLBARBASE_H
#include <QtGui/QToolBar>
#include <QtGui/QMenu>
/**
* Base class for toolbars.
*/
class WQtToolBarBase: public QToolBar
{
public:
/**
* Constructs the toolbar.
* \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 );
/**
* Destructor.
*/
virtual ~WQtToolBarBase();
/**
* Returns a menu for styling the menu items. All the handling is done internally. Just use the menu.
*
* \return
*/
QMenu* getStyleMenu( QString title = QString( "Toolbar Style" ) ) const;
protected:
private:
};
#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