Commit 79d3ce70 authored by finetjul's avatar finetjul
Browse files

BUG: using settings, toolbars can be hidden, synchronize with action

Directly connect the menu actions controlling the toolbar visibility with
the toolbars themselves (done in the ui).
After reading the settings, make sure the menu actions are synchro with the
toolbar visibility
Rename ModuleSelector into ModuleSelectorToolBar

git-svn-id: http://svn.slicer.org/Slicer4/trunk@15613 3bd1e089-480b-0410-8dfb-8563597acbee
parent 1513e0e1
......@@ -24,7 +24,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -168,11 +168,11 @@
</widget>
</item>
<item>
<widget class="qSlicerModulePanel" name="ModulePanel" native="true"/>
<widget class="qSlicerModulePanel" name="ModulePanel"/>
</item>
<item>
<widget class="ctkCollapsibleButton" name="SliceControlsCollapsibleWidget" native="true">
<property name="text" stdset="0">
<widget class="ctkCollapsibleButton" name="SliceControlsCollapsibleWidget">
<property name="text">
<string>Manipulate Slice Views</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
......@@ -196,13 +196,13 @@
</widget>
</item>
<item>
<widget class="ctkCollapsibleButton" name="View3DControlsCollapsibleWidget" native="true">
<property name="text" stdset="0">
<widget class="ctkCollapsibleButton" name="View3DControlsCollapsibleWidget">
<property name="text">
<string>Manipulate 3D View</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="qMRMLThreeDViewsControllerWidget" name="MRMLThreeDViewsControllerWidget" native="true"/>
<widget class="qMRMLThreeDViewsControllerWidget" name="MRMLThreeDViewsControllerWidget"/>
</item>
</layout>
</widget>
......@@ -860,6 +860,12 @@
<extends>QToolBar</extends>
<header>qMRMLSlicesControllerToolBar.h</header>
</customwidget>
<customwidget>
<class>qMRMLThreeDViewsControllerWidget</class>
<extends>qMRMLWidget</extends>
<header>qMRMLThreeDViewsControllerWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>qMRMLWidget</class>
<extends>QWidget</extends>
......@@ -883,12 +889,6 @@
<extends>QToolBar</extends>
<header>qSlicerMouseModeToolBar.h</header>
</customwidget>
<customwidget>
<class>qMRMLThreeDViewsControllerWidget</class>
<extends>qMRMLWidget</extends>
<header>qMRMLThreeDViewsControllerWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../Base/QTCoreModules/Resources/qSlicerBaseQTCoreModules.qrc"/>
......@@ -914,22 +914,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionWindowToolbarsModules</sender>
<signal>triggered(bool)</signal>
<receiver>ModuleToolBar</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>447</x>
<y>43</y>
</hint>
</hints>
</connection>
<connection>
<sender>PanelDockWidget</sender>
<signal>visibilityChanged(bool)</signal>
......@@ -978,5 +962,69 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionWindowToolbarsLoadSave</sender>
<signal>triggered(bool)</signal>
<receiver>MainToolBar</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>42</x>
<y>42</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionWindowToolbarsUndoRedo</sender>
<signal>triggered(bool)</signal>
<receiver>UndoRedoToolBar</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>140</x>
<y>42</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionWindowToolbarsModules</sender>
<signal>triggered(bool)</signal>
<receiver>ModuleToolBar</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>91</x>
<y>42</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionWindowToolbarsView</sender>
<signal>triggered(bool)</signal>
<receiver>ViewToolBar</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>189</x>
<y>42</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -63,7 +63,7 @@ public:
bool confirmClose();
qSlicerMainWindowCore* Core;
qSlicerModuleSelectorToolBar* ModuleSelector;
qSlicerModuleSelectorToolBar* ModuleSelectorToolBar;
QStringList ModuleToolBarList;
//QSignalMapper* ModuleToolBarMapper;
ctkSettingsDialog* SettingsDialog;
......@@ -76,7 +76,7 @@ qSlicerMainWindowPrivate::qSlicerMainWindowPrivate(qSlicerMainWindow& object)
: q_ptr(&object)
{
this->Core = 0;
this->ModuleSelector = 0;
this->ModuleSelectorToolBar = 0;
this->ModuleToolBarList << "Data" << "Volumes" << "Models" << "Transforms"
<< "Fiducials" << "Editor" << "Measurements"
<< "Colors";
......@@ -107,13 +107,13 @@ void qSlicerMainWindowPrivate::setupUi(QMainWindow * mainWindow)
// this->ModulePanel, SLOT(setModule(const QString&)));
// Create a Module selector
this->ModuleSelector = new qSlicerModuleSelectorToolBar("Module Selector",q);
this->ModuleSelector->setObjectName(QString::fromUtf8("ModuleSelectorToolBar"));
this->ModuleSelector->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
q->insertToolBar(this->ModuleToolBar, this->ModuleSelector);
this->ModuleSelectorToolBar = new qSlicerModuleSelectorToolBar("Module Selector",q);
this->ModuleSelectorToolBar->setObjectName(QString::fromUtf8("ModuleSelectorToolBar"));
this->ModuleSelectorToolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
q->insertToolBar(this->ModuleToolBar, this->ModuleSelectorToolBar);
// Connect the selector with the module panel
QObject::connect(this->ModuleSelector, SIGNAL(moduleSelected(const QString&)),
QObject::connect(this->ModuleSelectorToolBar, SIGNAL(moduleSelected(const QString&)),
this->ModulePanel, SLOT(setModule(const QString&)));
// MouseMode toolBar should listen the MRML scene
......@@ -124,8 +124,8 @@ void qSlicerMainWindowPrivate::setupUi(QMainWindow * mainWindow)
SLOT(setMRMLScene(vtkMRMLScene*)));
// Hide the Layout toolbar by default
q->showUndoRedoToolBar(false);
q->showLayoutToolBar(false);
this->actionWindowToolbarsUndoRedo->setChecked(false);
this->actionWindowToolbarsLayout->setChecked(false);
// Instanciate and assign the layout manager to the slicer application
qSlicerLayoutManager* layoutManager = new qSlicerLayoutManager(this->CentralWidget);
......@@ -263,12 +263,21 @@ qSlicerMainWindow::qSlicerMainWindow(QWidget *_parent):Superclass(_parent)
{
Q_D(qSlicerMainWindow);
d->setupUi(this);
// Main window core helps to coordinate various widgets and panels
d->Core = new qSlicerMainWindowCore(this);
this->setupMenuActions();
d->readSettings();
// reading settings might have enable/disable toolbar visibility, need to
// synchronize with the menu actions
d->actionWindowToolbarsLoadSave->setChecked(d->MainToolBar->isVisibleTo(this));
d->actionWindowToolbarsUndoRedo->setChecked(d->UndoRedoToolBar->isVisibleTo(this));
d->actionWindowToolbarsLayout->setChecked(d->LayoutToolBar->isVisibleTo(this));
d->actionWindowToolbarsView->setChecked(d->ViewToolBar->isVisibleTo(this));
d->actionWindowToolbarsModuleSelector->setChecked(d->ModuleSelectorToolBar->isVisibleTo(this));
d->actionWindowToolbarsModules->setChecked(d->ModuleToolBar->isVisibleTo(this));
}
//-----------------------------------------------------------------------------
......@@ -283,7 +292,7 @@ CTK_GET_CPP(qSlicerMainWindow, qSlicerMainWindowCore*, core, Core);
qSlicerModuleSelectorToolBar* qSlicerMainWindow::moduleSelector()const
{
Q_D(const qSlicerMainWindow);
return d->ModuleSelector;
return d->ModuleSelectorToolBar;
}
//-----------------------------------------------------------------------------
......@@ -330,7 +339,6 @@ void qSlicerMainWindow::setupMenuActions()
this->connect(d->actionFileExit, SIGNAL(triggered()),
this, SLOT(close()));
qSlicerMainWindowCore_connect(EditUndo);
qSlicerMainWindowCore_connect(EditRedo);
......@@ -362,20 +370,8 @@ void qSlicerMainWindow::setupMenuActions()
qSlicerMainWindowCore_connect(FeedbackCommunitySlicerVisualBlog);
//connect ToolBars actions
connect(d->actionWindowToolbarsLoadSave, SIGNAL(toggled(bool)),
this, SLOT(showMainToolBar(bool)));
connect(d->actionWindowToolbarsUndoRedo, SIGNAL(toggled(bool)),
this, SLOT(showUndoRedoToolBar(bool)));
connect(d->actionWindowToolbarsLayout, SIGNAL(toggled(bool)),
this, SLOT(showLayoutToolBar(bool)));
connect(d->actionWindowToolbarsView, SIGNAL(toggled(bool)),
this, SLOT(showViewToolBar(bool)));
connect(d->actionWindowToolbarsMouseMode, SIGNAL(toggled(bool)),
this, SLOT(showMouseModeToolBar(bool)));
connect(d->actionWindowToolbarsModules, SIGNAL(toggled(bool)),
this, SLOT(showModuleToolBar(bool)));
connect(d->actionWindowToolbarsModuleSelector, SIGNAL(toggled(bool)),
this, SLOT(showModuleSelectorToolBar(bool)));
d->ModuleSelectorToolBar, SLOT(setVisible(bool)));
}
#undef qSlicerMainWindowCore_connect
......@@ -404,7 +400,7 @@ void qSlicerMainWindow::onModuleLoaded(qSlicerAbstractCoreModule* coreModule)
}
// Module Selector ToolBar
d->ModuleSelector->addModule(module->name());
d->ModuleSelectorToolBar->addModule(module->name());
// Module ToolBar
QAction * action = module->action();
......@@ -448,7 +444,7 @@ void qSlicerMainWindow::onModuleAboutToBeUnloaded(qSlicerAbstractCoreModule* mod
if (action->data().toString() == module->name())
{
d->ModuleToolBar->removeAction(action);
d->ModuleSelector->removeModule(module->name());
d->ModuleSelectorToolBar->removeModule(module->name());
//d->ModuleToolBarMapper->removeMappings(action);
return;
}
......@@ -459,7 +455,7 @@ void qSlicerMainWindow::onModuleAboutToBeUnloaded(qSlicerAbstractCoreModule* mod
void qSlicerMainWindow::onMRMLSceneModified(vtkObject* sender)
{
Q_D(qSlicerMainWindow);
vtkMRMLScene* scene = vtkMRMLScene::SafeDownCast(sender);
if (scene->GetIsUpdating())
{
......@@ -468,73 +464,3 @@ void qSlicerMainWindow::onMRMLSceneModified(vtkObject* sender)
d->actionEditUndo->setEnabled(scene && scene->GetNumberOfUndoLevels());
d->actionEditRedo->setEnabled(scene && scene->GetNumberOfRedoLevels());
}
//---------------------------------------------------------------------------
void qSlicerMainWindow::showMainToolBar(bool visible)
{
Q_D(qSlicerMainWindow);
// set the action state just in case the slot has been called by something
// else than the toolbar QAction
d->actionWindowToolbarsLoadSave->setChecked(visible);
d->MainToolBar->setVisible(visible);
}
//---------------------------------------------------------------------------
void qSlicerMainWindow::showUndoRedoToolBar(bool visible)
{
Q_D(qSlicerMainWindow);
// set the action state just in case the slot has been called by something
// else than the toolbar QAction
d->actionWindowToolbarsUndoRedo->setChecked(visible);
d->UndoRedoToolBar->setVisible(visible);
}
//---------------------------------------------------------------------------
void qSlicerMainWindow::showViewToolBar(bool visible)
{
Q_D(qSlicerMainWindow);
// set the action state just in case the slot has been called by something
// else than the toolbar QAction
d->actionWindowToolbarsView->setChecked(visible);
d->ViewToolBar->setVisible(visible);
}
//---------------------------------------------------------------------------
void qSlicerMainWindow::showLayoutToolBar(bool visible)
{
Q_D(qSlicerMainWindow);
// set the action state just in case the slot has been called by something
// else than the toolbar QAction
d->actionWindowToolbarsLayout->setChecked(visible);
d->LayoutToolBar->setVisible(visible);
}
//---------------------------------------------------------------------------
void qSlicerMainWindow::showMouseModeToolBar(bool visible)
{
Q_D(qSlicerMainWindow);
// set the action state just in case the slot has been called by something
// else than the toolbar QAction
d->actionWindowToolbarsMouseMode->setChecked(visible);
d->MouseModeToolBar->setVisible(visible);
}
//---------------------------------------------------------------------------
void qSlicerMainWindow::showModuleToolBar(bool visible)
{
Q_D(qSlicerMainWindow);
// set the action state just in case the slot has been called by something
// else than the toolbar QAction
d->actionWindowToolbarsModules->setChecked(visible);
d->ModuleToolBar->setVisible(visible);
}
//---------------------------------------------------------------------------
void qSlicerMainWindow::showModuleSelectorToolBar(bool visible)
{
Q_D(qSlicerMainWindow);
// set the action state just in case the slot has been called by something
// else than the toolbar QAction
d->actionWindowToolbarsModuleSelector->setChecked(visible);
d->ModuleSelector->setVisible(visible);
}
......@@ -41,7 +41,7 @@ class Q_SLICERQT_EXPORT qSlicerMainWindow : public QMainWindow
Q_OBJECT
QVTK_OBJECT
public:
typedef QMainWindow Superclass;
qSlicerMainWindow(QWidget *parent=0);
virtual ~qSlicerMainWindow();
......@@ -52,15 +52,6 @@ public:
/// Return the module selector
Q_INVOKABLE qSlicerModuleSelectorToolBar* moduleSelector()const;
public slots:
void showMainToolBar(bool visible);
void showUndoRedoToolBar(bool visible);
void showViewToolBar(bool visible);
void showLayoutToolBar(bool visible);
void showMouseModeToolBar(bool visible);
void showModuleToolBar(bool visible);
void showModuleSelectorToolBar(bool visible);
protected slots:
void onModuleLoaded(qSlicerAbstractCoreModule* module);
void onModuleAboutToBeUnloaded(qSlicerAbstractCoreModule* module);
......
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