Commit 376433b5 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] - texture sorter, ROI widget, prop widget and module tree are now DOCK...

[ADD] - texture sorter, ROI widget, prop widget and module tree are now DOCK windows. You can move them as YOU! want. The cool thing is: OpenWalnut stores position/state of all windows and restores it when started! So you can click your GUI as you like it.
parent 57212a3c
......@@ -41,6 +41,7 @@
#include <QtGui/QSlider>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include <QtCore/QSettings>
#include "../../common/WColor.h"
#include "../../common/WPreferences.h"
......@@ -82,6 +83,11 @@ WMainWindow::WMainWindow() :
{
}
WMainWindow::~WMainWindow()
{
// cleanup
}
void WMainWindow::setupGUI()
{
m_iconManager.addIcon( std::string( "load" ), fileopen_xpm );
......@@ -95,7 +101,6 @@ void WMainWindow::setupGUI()
m_iconManager.addIcon( std::string( "remove" ), remove_xpm );
m_iconManager.addIcon( std::string( "config" ), preferences_system_xpm );
if( objectName().isEmpty() )
{
setObjectName( QString::fromUtf8( "MainWindow" ) );
......@@ -105,17 +110,28 @@ void WMainWindow::setupGUI()
setWindowIcon( m_iconManager.getIcon( "logo" ) );
setWindowTitle( QApplication::translate( "MainWindow", "OpenWalnut (development version)", 0, QApplication::UnicodeUTF8 ) );
setDockOptions( QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks );
//network Editor
m_networkEditor = new WQtNetworkEditor( this );
m_networkEditor->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::RightDockWidgetArea, m_networkEditor );
// the control panel instance is needed for the menu
m_controlPanel = new WQtControlPanel( this );
m_controlPanel->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel );
m_controlPanel->addSubject( "Default Subject" );
// add all docks
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel->getModuleDock() );
addDockWidget( Qt::RightDockWidgetArea, m_networkEditor );
tabifyDockWidget( m_networkEditor, m_controlPanel->getModuleDock() );
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel->getTextureSorterDock() );
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel->getRoiDock() );
tabifyDockWidget( m_controlPanel->getTextureSorterDock(), m_controlPanel->getRoiDock() );
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel );
setupPermanentToolBar();
// we want the upper most tree item to be selected. This helps to make the always compatible modules
......@@ -277,6 +293,12 @@ void WMainWindow::setupGUI()
m_navSagittal->getGLWidget()->setBgColor( bgColor );
}
}
// after creating the GUI, restore its saved state
QSettings setting( "OpenWalnut.org", "OpenWalnut" );
QByteArray state = setting.value( "MainWindowState", "" ).toByteArray();
restoreGeometry( setting.value( "MainWindowGeometry", "" ).toByteArray() );
restoreState( state );
}
void WMainWindow::setupPermanentToolBar()
......@@ -931,10 +953,16 @@ void WMainWindow::closeEvent( QCloseEvent* e )
// use some "Really Close?" Dialog here
bool reallyClose = true;
// handle close event
if( reallyClose )
{
// this saves the window state to some common location on the target OS in user scope.
QByteArray state = saveState();
QSettings setting( "OpenWalnut.org", "OpenWalnut" );
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() );
// signal everybody to shut down properly.
WKernel::getRunningKernel()->finalize();
......
......@@ -66,7 +66,12 @@ public:
/**
* Constructor of the main window
*/
explicit WMainWindow();
WMainWindow();
/**
* Destructor. Stores window state.
*/
virtual ~WMainWindow();
/**
* Set up all widgets menus an buttons in the main window.
......
......@@ -243,6 +243,8 @@ int WQt4Gui::run()
// run
int qtRetCode = appl.exec();
delete m_mainWindow;
// signal everybody to shut down properly.
WKernel::getRunningKernel()->wait( true );
WKernel::getRunningKernel()->getGraphicsEngine()->wait( true );
......
......@@ -33,6 +33,8 @@ WQtCustomDockWidget::WQtCustomDockWidget( std::string title, QWidget* parent, WG
: QDockWidget( QString::fromStdString( title ), parent ),
m_useCount( 1 )
{
setObjectName( QString( "Custom Dock Window " ) + QString::fromStdString( title ) );
// setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
setFloating( true );
......
......@@ -40,6 +40,7 @@
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, std::string sliderTitle, const QGLWidget * shareWidget )
: QDockWidget( title, parent )
{
setObjectName( QString( "Navigation Window " ) + title );
propertyWidgetMap.clear();
m_sliderTitle = QString( sliderTitle.c_str() );
......
......@@ -64,6 +64,8 @@ WQtControlPanel::WQtControlPanel( WMainWindow* parent )
: QDockWidget( "Control Panel", parent ),
m_ignoreSelectionChange( false )
{
setObjectName( "Control Panel Dock" );
m_mainWindow = parent;
m_panel = new QWidget( this );
......@@ -116,31 +118,22 @@ WQtControlPanel::WQtControlPanel( WMainWindow* parent )
m_mainWindow->getNetworkEditor()->addAction( m_disconnectAction );
m_mainWindow->getNetworkEditor()->addAction( m_deleteModuleAction );
m_textureSorter = new WQtTextureSorter( this );
m_textureSorter = new WQtTextureSorter( m_mainWindow );
m_textureSorter->setToolTip( "Reorder the textures." );
m_tabWidget = new QTabWidget( m_panel );
m_tabWidget2 = new QTabWidget( m_panel );
m_tabWidget->setMinimumHeight( 250 );
// should the Tree, Texture Sorter and the ROI Display be combined in one tab widget?
bool combineThem = false;
WPreferences::getPreference( "qt4gui.combineTreeAndRoiAndTextureSorter", &combineThem );
m_splitter = new QSplitter( Qt::Vertical );
if ( !combineThem )
{
m_splitter->addWidget( m_moduleTreeWidget );
}
else
{
m_tabWidget2->addTab( m_moduleTreeWidget, QString( "Modules" ) );
}
m_splitter->addWidget( m_tabWidget2 );
m_tabWidget2->addTab( m_textureSorter, QString( "Texture Sorter" ) );
m_moduleDock = new QDockWidget( "Module Tree", m_mainWindow );
m_moduleDock->setObjectName( "Module Dock" );
m_moduleDock->setWidget( m_moduleTreeWidget );
m_roiDock = new QDockWidget( "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>, "
"inside the branches the ROIs are combined using logic <b>and</b>." );
......@@ -150,27 +143,15 @@ WQtControlPanel::WQtControlPanel( WMainWindow* parent )
m_roiTreeWidget->viewport()->setAcceptDrops( true );
m_roiTreeWidget->setDropIndicatorShown( true );
m_roiTreeWidget->setDragDropMode( QAbstractItemView::InternalMove );
m_tabWidget2->addTab( m_roiTreeWidget, QString( "ROIs" ) );
m_splitter->addWidget( m_tabWidget );
// set the initial sizes.
QList< int > splitterList;
splitterList.push_back( 200 );
if ( !combineThem )
{
splitterList.push_back( 200 );
}
splitterList.push_back( 400 );
m_splitter->setSizes( splitterList );
m_roiDock->setWidget( m_roiTreeWidget );
m_layout = new QVBoxLayout();
m_layout->addWidget( m_splitter );
m_layout->addWidget( m_tabWidget );
m_panel->setLayout( m_layout );
this->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
this->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
this->setAllowedAreas( Qt::AllDockWidgetAreas );
this->setFeatures( QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
this->setWidget( m_panel );
m_tiModules = new WQtModuleHeaderTreeItem( m_moduleTreeWidget );
......@@ -587,7 +568,6 @@ void WQtControlPanel::addRoi( osg::ref_ptr< WROI > roi )
branchItem = m_tiRois->addBranch( WKernel::getRunningKernel()->getRoiManager()->getBranch( roi ) );
}
m_tabWidget2->setCurrentIndex( m_tabWidget2->indexOf( m_roiTreeWidget ) );
branchItem->setExpanded( true );
newItem = branchItem->addRoiItem( roi );
newItem->setDisabled( false );
......@@ -1129,3 +1109,18 @@ void WQtControlPanel::handleDragDrop()
WLogger::getLogger()->addLogMessage( "Drag and drop handler not implemented yet!", "ControlPanel", LL_DEBUG );
}
QDockWidget* WQtControlPanel::getRoiDock() const
{
return m_roiDock;
}
QDockWidget* WQtControlPanel::getModuleDock() const
{
return m_moduleDock;
}
QDockWidget* WQtControlPanel::getTextureSorterDock() const
{
return m_textureSorter;
}
......@@ -175,6 +175,27 @@ public:
**/
void setNewActiveModule( boost::shared_ptr< WModule > module );
/**
* Gets the ROI dock widget.
*
* \return the ROI dock.
*/
QDockWidget* getRoiDock() const;
/**
* Gets the module dock widget.
*
* \return the module dock
*/
QDockWidget* getModuleDock() const;
/**
* Gets the texture sorter dock
*
* \return the dock
*/
QDockWidget* getTextureSorterDock() const;
protected:
/**
......@@ -248,6 +269,9 @@ 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
/**
* The action to remove a module from the tree.
*/
......
......@@ -47,12 +47,18 @@
WQtTextureSorter::WQtTextureSorter( QWidget* parent )
: QWidget( parent )
: QDockWidget( "Texture Sorter", parent )
{
setObjectName( "Texture Sorter Dock" );
m_textureListWidget = new QListWidget( this );
m_textureListWidget->setToolTip( "List of available textures. Only the upper <b>"
+ QString().setNum( wlimits::MAX_NUMBER_OF_TEXTURES )
+ "</b> textures will be applied." );
this->setAllowedAreas( Qt::AllDockWidgetAreas );
this->setFeatures( QDockWidget::DockWidgetClosable |QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
QWidget* panel = new QWidget( this );
m_layout = new QVBoxLayout();
......@@ -73,7 +79,8 @@ WQtTextureSorter::WQtTextureSorter( QWidget* parent )
connect( m_textureListWidget, SIGNAL( itemClicked( QListWidgetItem* ) ), this, SLOT( handleTextureClicked() ) );
setLayout( m_layout );
panel->setLayout( m_layout );
setWidget( panel );
}
WQtTextureSorter::~WQtTextureSorter()
......
......@@ -28,7 +28,7 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include <QtGui/QWidget>
#include <QtGui/QDockWidget>
#include <QtGui/QListWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
......@@ -41,7 +41,7 @@ class WDataSet;
/**
* container widget for a tree widget with context menu and some control widgets
*/
class WQtTextureSorter : public QWidget
class WQtTextureSorter : public QDockWidget
{
Q_OBJECT
......
......@@ -50,9 +50,10 @@
#include "../events/WModuleRemovedEvent.h"
WQtNetworkEditor::WQtNetworkEditor( WMainWindow* parent )
: QDockWidget( "NetworkEditor", parent ),
: QDockWidget( "Module Graph", parent ),
timerId( 0 )
{
setObjectName( "Module Graph Dock" );
m_mainWindow = parent;
m_panel = new QWidget( this );
......@@ -73,8 +74,8 @@ WQtNetworkEditor::WQtNetworkEditor( WMainWindow* parent )
m_panel->setLayout( m_layout );
this->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
this->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
this->setAllowedAreas( Qt::AllDockWidgetAreas );
this->setFeatures( QDockWidget::DockWidgetClosable |QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
setWidget( m_panel );
connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( selectItem() ) );
......
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