Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerModulesMenu.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Julien Finet, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __qSlicerModulesMenu_h
22 #define __qSlicerModulesMenu_h
23 
24 // Qt includes
25 #include <QMenu>
26 
27 // CTK includes
28 #include "qSlicerBaseQTGUIExport.h"
29 
31 class qSlicerModulesMenuPrivate;
33 
37 class Q_SLICER_BASE_QTGUI_EXPORT qSlicerModulesMenu: public QMenu
38 {
39  Q_OBJECT
40  Q_PROPERTY(QString currentModule READ currentModule WRITE setCurrentModule NOTIFY currentModuleChanged)
48  Q_PROPERTY(bool duplicateActions READ duplicateActions WRITE setDuplicateActions)
49 
56  Q_PROPERTY(bool showHiddenModules READ showHiddenModules WRITE setShowHiddenModules)
57 
58  Q_PROPERTY(QStringList topLevelCategoryOrder READ topLevelCategoryOrder WRITE setTopLevelCategoryOrder)
59 public:
60  typedef QMenu Superclass;
61 
65  qSlicerModulesMenu(const QString& title, QWidget* parent = nullptr);
66  qSlicerModulesMenu(QWidget* parent = nullptr);
67  ~qSlicerModulesMenu() override;
68 
70  Q_INVOKABLE QAction* moduleAction(const QString& moduleName)const;
71 
73  inline void addModules(const QStringList& moduleNames);
74 
76  inline void removeModules(const QStringList& moduleNames);
77 
79  QString currentModule()const;
80 
82  void setModuleManager(qSlicerModuleManager* moduleManager);
83  qSlicerModuleManager* moduleManager()const;
84 
85  void setDuplicateActions(bool duplicate);
86  bool duplicateActions()const;
87 
90  void setShowHiddenModules(bool show);
91  bool showHiddenModules()const;
92 
93  void setTopLevelCategoryOrder(const QStringList& categories);
94  QStringList topLevelCategoryOrder()const;
95 
101  Q_INVOKABLE bool removeCategory(const QString& categoryName);
102 
103 public slots:
113  void addModule(const QString& moduleName);
114 
123  bool removeModule(const QString& moduleName);
124 
127  void setCurrentModuleByTitle(const QString& title);
128 
131  void setCurrentModule(const QString& moduleName);
132 
134  void addModule(qSlicerAbstractCoreModule*);
135 
143  bool removeModule(qSlicerAbstractCoreModule*);
144 
145 signals:
148  void currentModuleChanged(const QString& name);
149 
150 protected slots:
151  void onActionTriggered();
152  void actionSelected(QAction* action);
153 
154 protected:
155  QScopedPointer<qSlicerModulesMenuPrivate> d_ptr;
156 
157 private:
158  Q_DECLARE_PRIVATE(qSlicerModulesMenu);
159  Q_DISABLE_COPY(qSlicerModulesMenu);
160 };
161 
162 //---------------------------------------------------------------------------
163 void qSlicerModulesMenu::addModules(const QStringList& moduleNames)
164 {
165  foreach(const QString& moduleName, moduleNames)
166  {
167  this->addModule(moduleName);
168  }
169 }
170 
171 //---------------------------------------------------------------------------
172 void qSlicerModulesMenu::removeModules(const QStringList& moduleNames)
173 {
174  foreach(const QString& moduleName, moduleNames)
175  {
176  this->removeModule(moduleName);
177  }
178 }
179 
180 #endif
qSlicerAbstractCoreModule is the base class of any module in Slicer.
void removeModules(const QStringList &moduleNames)
Add a list of module available for selection.