Commit 8e206545 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] our dock widgets now use a custom title. This (later) allows to add...

[CHANGE] our dock widgets now use a custom title. This (later) allows to add custom actions and buttons to the titlebar.
parent 8743a7b0
......@@ -73,8 +73,6 @@ WQtGLDockWidget::WQtGLDockWidget( QString viewTitle, QString dockTitle, QWidget*
// all view docks have a screen capture object
m_screenCapture = new WQtGLScreenCapture( this );
// hide the screen capture object by default
//m_screenCapture->setHidden( true );
// set custom title
setTitleBarWidget( new WQtGLDockWidgetTitle( this, dockTitle ) );
......
......@@ -42,7 +42,7 @@
/**
* Dock widget containing only a GLWidget.
*/
class WQtGLDockWidget : public QDockWidget
class WQtGLDockWidget: public QDockWidget
{
Q_OBJECT
......
......@@ -42,7 +42,7 @@
#define MAXITEMS 1000
WQtMessageDock::WQtMessageDock( QString dockTitle, QWidget* parent ):
QDockWidget( dockTitle, parent )
WQtDockWidget( dockTitle, parent )
{
setObjectName( "MessageDock:" + dockTitle );
setAllowedAreas( Qt::AllDockWidgetAreas );
......
......@@ -31,12 +31,13 @@
#include "core/common/WLogEntry.h"
#include "guiElements/WQtDockWidget.h"
#include "WQtMessagePopup.h"
/**
* Dock widget for showing messages and logs
*/
class WQtMessageDock: public QDockWidget
class WQtMessageDock: public WQtDockWidget
{
Q_OBJECT
public:
......
......@@ -49,7 +49,7 @@
#include "WQtColormapper.moc"
WQtColormapper::WQtColormapper( QWidget* parent )
: QDockWidget( "Colormaps", parent )
: WQtDockWidget( "Colormaps", parent )
{
setObjectName( "Colormapper Dock" );
......@@ -63,6 +63,7 @@ WQtColormapper::WQtColormapper( QWidget* parent )
QWidget* panel = new QWidget( this );
m_layout = new QVBoxLayout();
m_layout->setContentsMargins( 0, 0, 0, 0 );
QHBoxLayout* buttonLayout = new QHBoxLayout();
m_downButton = new QPushButton();
......@@ -145,7 +146,7 @@ bool WQtColormapper::event( QEvent* event )
return true;
}
return QDockWidget::event( event );
return WQtDockWidget::event( event );
}
void WQtColormapper::update()
......
......@@ -39,12 +39,14 @@
#include "core/common/WSharedObject.h"
#include "core/graphicsEngine/WGETexture.h"
#include "../guiElements/WQtDockWidget.h"
class WDataSet;
/**
* This widget controls the colormapper of openwalnut. It directly interacts with WGEColormapper.
*/
class WQtColormapper : public QDockWidget
class WQtColormapper : public WQtDockWidget
{
Q_OBJECT
......
......@@ -69,7 +69,7 @@
#include "WQtControlPanel.moc"
WQtControlPanel::WQtControlPanel( WMainWindow* parent )
: QDockWidget( "Control Panel", parent ),
: WQtDockWidget( "Control Panel", parent ),
m_ignoreSelectionChange( false ),
m_activeModule( WModule::SPtr() ),
m_previousTab()
......@@ -150,12 +150,12 @@ WQtControlPanel::WQtControlPanel( WMainWindow* parent )
m_tabWidget = new QTabWidget( );
m_tabWidget->setMinimumHeight( 100 );
m_moduleDock = new QDockWidget( "Module Tree", m_mainWindow );
m_moduleDock = new WQtDockWidget( "Module Tree", m_mainWindow );
m_moduleDock->setObjectName( "Module Dock" );
m_moduleDock->setWidget( m_moduleTreeWidget );
m_moduleDock->setHidden( true );
m_roiDock = new QDockWidget( "ROIs", m_mainWindow );
m_roiDock = new WQtDockWidget( "ROIs", m_mainWindow );
m_roiDock->setObjectName( "ROI Dock" );
m_roiTreeWidget = new WQtTreeWidget();
m_roiTreeWidget->setToolTip( "Regions of intrest (ROIs) for selecting fiber clusters. Branches are combined using logic <b>or</b>, "
......@@ -495,7 +495,7 @@ bool WQtControlPanel::event( QEvent* event )
return true;
}
return QDockWidget::event( event );
return WQtDockWidget::event( event );
}
std::list< WQtTreeItem* > WQtControlPanel::findItemsByModule( boost::shared_ptr< WModule > module, QTreeWidgetItem* where )
......@@ -1131,7 +1131,7 @@ osg::ref_ptr< WROI > WQtControlPanel::getFirstRoiInSelectedBranch()
QAction* WQtControlPanel::toggleViewAction() const
{
QAction* result = QDockWidget::toggleViewAction();
QAction* result = WQtDockWidget::toggleViewAction();
QList< QKeySequence > shortcut;
#if defined( __APPLE__ )
shortcut.append( QKeySequence( Qt::CTRL + Qt::Key_F9 ) ); // In Mac OS X F9 is already taken by window managment
......@@ -1223,17 +1223,17 @@ void WQtControlPanel::handleRoiDragDrop()
WLogger::getLogger()->addLogMessage( "Drag and drop handler not implemented yet!", "ControlPanel", LL_DEBUG );
}
QDockWidget* WQtControlPanel::getRoiDock() const
WQtDockWidget* WQtControlPanel::getRoiDock() const
{
return m_roiDock;
}
QDockWidget* WQtControlPanel::getModuleDock() const
WQtDockWidget* WQtControlPanel::getModuleDock() const
{
return m_moduleDock;
}
QDockWidget* WQtControlPanel::getColormapperDock() const
WQtDockWidget* WQtControlPanel::getColormapperDock() const
{
return m_colormapper;
}
......
......@@ -48,6 +48,7 @@
#include "WQtRoiHeaderTreeItem.h"
#include "WQtSubjectTreeItem.h"
#include "WQtTreeWidget.h"
#include "../guiElements/WQtDockWidget.h"
class WMainWindow;
class WQtColormapper;
......@@ -55,7 +56,7 @@ class WQtColormapper;
/**
* container widget for a tree widget with context menu and some control widgets
*/
class WQtControlPanel : public QDockWidget
class WQtControlPanel : public WQtDockWidget
{
Q_OBJECT
......@@ -174,21 +175,21 @@ public:
*
* \return the ROI dock.
*/
QDockWidget* getRoiDock() const;
WQtDockWidget* getRoiDock() const;
/**
* Gets the module dock widget.
*
* \return the module dock
*/
QDockWidget* getModuleDock() const;
WQtDockWidget* getModuleDock() const;
/**
* Gets the colormapper dock
*
* \return the dock
*/
QDockWidget* getColormapperDock() const;
WQtDockWidget* getColormapperDock() const;
/**
* Returns the module excluder. It then can be used for configuration.
......@@ -294,8 +295,8 @@ private:
bool m_showToolBarText; //!< Show tool bar icons with text
QDockWidget* m_roiDock; //!< the dock widget with the ROI tree
QDockWidget* m_moduleDock; //!< the dock widget with the module tree
WQtDockWidget* m_roiDock; //!< the dock widget with the ROI tree
WQtDockWidget* m_moduleDock; //!< the dock widget with the module tree
/**
* The action to remove a module from the tree.
......
//---------------------------------------------------------------------------
//
// 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 "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "WQtDockWidget.h"
#include "WQtDockWidget.moc"
WQtDockWidget::WQtDockWidget( const QString& title, QWidget* parent, Qt::WindowFlags flags ):
QDockWidget( title, parent, flags )
{
construct();
}
WQtDockWidget::WQtDockWidget( QWidget* parent, Qt::WindowFlags flags ):
QDockWidget( parent, flags )
{
construct();
}
WQtDockWidget::~WQtDockWidget()
{
// cleanup
}
void WQtDockWidget::setupButton( QToolButton* btn )
{
btn->setToolButtonStyle( Qt::ToolButtonIconOnly );
btn->setContentsMargins( 0, 0, 0, 0 );
btn->setFixedHeight( 24 );
btn->setAutoRaise( true );
btn->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) );
}
void WQtDockWidget::construct()
{
// some standard dock features
setAllowedAreas( Qt::AllDockWidgetAreas );
setFeatures( QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
// create titlebar widget and its layout
m_titleWidget = new QWidget( this );
QHBoxLayout* titleWidgetLayout = new QHBoxLayout( m_titleWidget );
titleWidgetLayout->setMargin( 0 );
titleWidgetLayout->setSpacing( 0 );
m_titleWidget->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed ) );
// title
m_title = new WScaleLabel( " " + windowTitle(), 3, m_titleWidget );
m_title->setTextInteractionFlags( Qt::NoTextInteraction );
// close Btn
m_closeBtn = new QToolButton( m_titleWidget );
QAction* closeAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "popup_close" ), "Close", m_titleWidget );
connect( closeAction, SIGNAL( triggered( bool ) ), this, SLOT( close() ) );
m_closeBtn->setDefaultAction( closeAction );
setupButton( m_closeBtn );
m_closeBtn->setMinimumSize( 24, 24 );
m_closeBtn->setMaximumSize( 24, 24 );
// create the container for the actions shown in the titlebar directly
m_tools = new QWidget( m_titleWidget );
m_toolsLayout = new QHBoxLayout( m_tools );
m_tools->setLayout( m_toolsLayout );
m_tools->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
m_toolsLayout->setMargin( 0 );
m_toolsLayout->setSpacing( 0 );
m_tools->setContentsMargins( 0, 0, 0, 0 );
m_tools->setMinimumSize( 1, 24 );
// create the container for the actions dropped out the titlebar to save some space
m_toolsMenu = new QWidget( m_titleWidget );
QHBoxLayout* toolsMenuLayout = new QHBoxLayout( m_toolsMenu );
m_toolsMenu->setLayout( toolsMenuLayout );
toolsMenuLayout->setMargin( 0 );
toolsMenuLayout->setSpacing( 0 );
m_toolsMenu->setContentsMargins( 0, 0, 0, 0 );
// create a button that shows the m_toolsMenu container widget
m_moreBtn = new QToolButton( m_titleWidget );
m_moreBtn->setHidden( true );
setupButton( m_moreBtn );
m_moreBtn->setPopupMode( QToolButton::InstantPopup );
m_moreBtn->setIcon( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "popup_more" ) );
QMenu* moreMenu = new QMenu();
QWidgetAction* moreAction = new QWidgetAction( m_toolsMenu );
moreAction->setDefaultWidget( m_toolsMenu );
moreMenu->addAction( moreAction );
m_moreBtn->setMenu( moreMenu );
// fill layout
titleWidgetLayout->addWidget( m_title );
titleWidgetLayout->addStretch( 100000 );
titleWidgetLayout->addWidget( m_tools );
titleWidgetLayout->addWidget( m_moreBtn );
titleWidgetLayout->addWidget( m_closeBtn );
// thats it. we now have the title bar
setTitleBarWidget( m_titleWidget );
}
//---------------------------------------------------------------------------
//
// 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 WQTDOCKWIDGET_H
#define WQTDOCKWIDGET_H
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include <QtGui/QLabel>
#include <QtGui/QResizeEvent>
#include <QtGui/QWidgetAction>
#include "WScaleLabel.h"
/**
* Advanced QDockWidget. This class allows you to add actions to the titlebar of the dock widget
*/
class WQtDockWidget: public QDockWidget
{
Q_OBJECT
public:
/**
* Construct dock widget.
*
* \param title the title of the widget
* \param parent the parent widget
* \param flags optional window flags
*/
WQtDockWidget( const QString& title, QWidget* parent = 0, Qt::WindowFlags flags = 0 );
/**
* Construct dock widget.
*
* \param parent the parent widget
* \param flags optional window flags
*/
WQtDockWidget( QWidget* parent = 0, Qt::WindowFlags flags = 0 );
/**
* Destructor.
*/
virtual ~WQtDockWidget();
protected:
/**
* Apply default settings for dock widget title buttons.
*
* \param btn the button to setup
*/
virtual void setupButton( QToolButton* btn );
private:
/**
* Construct the title and configure the widget.
*/
void construct();
/**
* The title of this dock
*/
QWidget* m_titleWidget;
/**
* The tools buttons
*/
QWidget* m_tools;
/**
* The tool inside the menu
*/
QWidget* m_toolsMenu;
/**
* Layout containing the tools
*/
QHBoxLayout* m_toolsLayout;
/**
* The tool button used when shrinking the title bar too much
*/
QToolButton* m_moreBtn;
/**
* Title label
*/
WScaleLabel* m_title;
/**
* Close button
*/
QToolButton* m_closeBtn;
};
#endif // WQTDOCKWIDGET_H
......@@ -54,7 +54,7 @@
#include "WQtNetworkEditor.moc"
WQtNetworkEditor::WQtNetworkEditor( WMainWindow* parent )
: QDockWidget( "Module Graph", parent )
: WQtDockWidget( "Module Graph", parent )
{
setObjectName( "Module Graph Dock" );
m_mainWindow = parent;
......@@ -70,8 +70,6 @@ WQtNetworkEditor::WQtNetworkEditor( WMainWindow* parent )
m_view->setScene( m_scene );
this->setAllowedAreas( Qt::AllDockWidgetAreas );
this->setFeatures( QDockWidget::DockWidgetClosable |QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
setWidget( m_view );
connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( selectItem() ) );
connect( m_view, SIGNAL( loadAction() ), m_mainWindow, SLOT( openLoadDialog() ) );
......@@ -449,7 +447,7 @@ bool WQtNetworkEditor::event( QEvent* event )
return true;
}
return QDockWidget::event( event );
return WQtDockWidget::event( event );
}
WQtNetworkItem* WQtNetworkEditor::findItemByModule( boost::shared_ptr< WModule > module )
......
......@@ -37,6 +37,7 @@
#include "core/kernel/WModule.h"
#include "../WQtCombinerToolbar.h"
#include "../guiElements/WQtDockWidget.h"
#include "layout/WNetworkLayout.h"
#include "WQtNetworkEditorView.h"
#include "WQtNetworkItem.h"
......@@ -49,7 +50,7 @@ class WNetworkLayout;
/**
* Container widget to hold the WQtNetworkScene
*/
class WQtNetworkEditor : public QDockWidget
class WQtNetworkEditor : public WQtDockWidget
{
Q_OBJECT
public:
......
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