Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
berryMenuManager.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef BERRYMENUMANAGER_H_
14 #define BERRYMENUMANAGER_H_
15 
16 #include "berryIMenuManager.h"
18 
20 
21 #include <QIcon>
22 
23 class QMenu;
24 class QMenuProxy;
25 class QAction;
26 
27 namespace berry
28 {
29 
37 class BERRY_UI_QT MenuManager: public QObject, public ContributionManager, public IMenuManager
38 {
39  Q_OBJECT
40 
41 public:
42 
44 
45 private:
46 
50  QString id;
51 
56  QMenuProxy* menu;
57  QAction* menuItem;
58 
64  //SmartPointer<IMenuItem> menuItem;
65 
69  QString menuText;
70 
74  QIcon image;
75 
80 
84  IContributionManager* parent;
85 
90  bool removeAllWhenShown;
91 
96  QString definitionId;
97 
98 private:
99 
100  Q_SLOT void HandleAboutToShow();
101  Q_SLOT void HandleAboutToHide();
102 
103 protected:
104 
109  bool visible;
110 
111 public:
112 
113  Q_SIGNAL void AboutToShow(IMenuManager* mm);
114  Q_SIGNAL void AboutToHide(IMenuManager* mm);
115 
124  MenuManager(const QString& text, const QString& id = QString());
125 
126  ~MenuManager() override;
127 
136  MenuManager(const QString& text, const QIcon& image,
137  const QString& id);
138 
139  bool IsDirty() const override;
140 
152  QMenu* CreateContextMenu(QWidget* parent);
153 
163  QMenuBar* CreateMenuBar(QWidget* parent);
164 
165  void AddMenuListener(QObject* listener) override;
166  void RemoveMenuListener(QObject *listener) override;
167 
168  /*
169  * @see IContributionItem#Fill(QStatusBar*)
170  */
171  void Fill(QStatusBar* parent) override;
172 
173  /*
174  * @see IContributionItem#Fill(QToolBar*, int)
175  */
176  void Fill(QToolBar* parent, QAction *index) override;
177 
178  /*
179  * @see IContributionItem#Fill(QMenu*, int)
180  */
181  void Fill(QMenu* parent, QAction *before) override;
182 
183  /*
184  * @see IContributionItem#Fill(QMenuBar*, int)
185  */
186  void Fill(QMenuBar* parent, QAction *before) override;
187 
188  /*
189  * @see IMenuManager#FindMenuUsingPath(const QString&)
190  */
191  IMenuManager::Pointer FindMenuUsingPath(const QString& path) const override;
192 
193  /*
194  * @see IMenuManager#FindUsingPath(const QString&)
195  */
196  IContributionItem::Pointer FindUsingPath(const QString& path) const override;
197 
204  QString GetId() const override;
205 
211  QMenu* GetMenu() const;
212 
219  QString GetMenuText() const;
220 
226  QIcon GetImage() const;
227 
228  /*
229  * @see IContributionManager#GetOverrides()
230  */
231  SmartPointer<IContributionManagerOverrides> GetOverrides() override;
232 
238  IContributionManager* GetParent() const;
239 
240  /*
241  * @see IMenuManager#GetRemoveAllWhenShown()
242  */
243  bool GetRemoveAllWhenShown() const override;
244 
245  /*
246  * @see IContributionItem#IsDynamic()
247  */
248  bool IsDynamic() const override;
249 
261  bool IsEnabled() const override;
262 
263  /*
264  * @see IContributionItem#IsGroupMarker()
265  */
266  bool IsGroupMarker() const override;
267 
268  /*
269  * @see IContributionItem#IsSeparator()
270  */
271  bool IsSeparator() const override;
272 
273  /*
274  * @see IContributionItem#IsVisible()
275  */
276  bool IsVisible() const override;
277 
282  void MarkDirty() override;
283 
284  /*
285  * @see IMenuManager#removeMenuListener(IMenuListener)
286  */
287  //void RemoveMenuListener(SmartPointer<IMenuListener> listener);
288 
289  /*
290  * @IContributionItem#SaveWidgetState()
291  */
292  void SaveWidgetState() override;
293 
299  void SetOverrides(SmartPointer<IContributionManagerOverrides> newOverrides);
300 
301  /*
302  * @see IContributionItem#SetParent(IContributionManager)
303  */
304  void SetParent(IContributionManager* manager) override;
305 
306  /*
307  * @see IMenuManager#SetRemoveAllWhenShown(boolean)
308  */
309  void SetRemoveAllWhenShown(bool removeAll) override;
310 
311  /*
312  * @see IContributionItem#SetVisible(bool)
313  */
314  void SetVisible(bool visible) override;
315 
324  void SetCommandId(const QString& definitionId);
325 
326  /*
327  * @see IContributionItem#Update()
328  */
329  void Update() override;
330 
331  void Update(const QString& property) override;
332 
339  void Update(bool force) override;
340 
341  /*
342  * @see IMenuManager#UpdateAll(bool)
343  */
344  void UpdateAll(bool force) override;
345 
346 private:
347 
351  void InitializeMenu();
352 
356  // void DisposeOldImages();
357 
363  void UpdateMenuItem();
364 
365  void FillMenu(QWidget* parent, QAction* before);
366 
367  void DumpActionInfo(QMenuProxy* menu);
368  void DumpActionInfo(QWidget* widget, int level);
369 
370 protected:
371 
385  void DoItemFill(IContributionItem::Pointer ci, QAction *before);
386 
397  void Update(bool force, bool recursive);
398 
399 };
400 
401 }
402 
403 #endif /* BERRYMENUMANAGER_H_ */
org_blueberry_ui_qt_Export.h
berry::MenuManager::visible
bool visible
Definition: berryMenuManager.h:109
berry::SmartPointer
Implements transparent reference counting.
Definition: berryICommandCategoryListener.h:21
berry::MenuManager
Definition: berryMenuManager.h:37
BERRY_UI_QT
#define BERRY_UI_QT
Definition: org_blueberry_ui_qt_Export.h:26
berry::IContributionManager
Definition: berryIContributionManager.h:45
berry::IMenuManager
Definition: berryIMenuManager.h:36
berry::ContributionManager
Definition: berryContributionManager.h:42
menu
The custom viewer plugin implements simple viewer functionality presented in a customized look and feel It was developed to demonstrate extensibility and customizability of the blueberry application framework As an example for the GUI customization capabilities provided by the BlueBerry application the custom viewer plugin was developed It features simple viewer functionality presented in a customized look and feel The custom viewer consists of two i e a viewer perspective and a DICOM perspective As part of the viewer an instance of QmitkDataManagerView allows for data selection Visualization of the selected data is then performed by a simple render window view According data can either be directly loaded from file or be imported as DICOM data DICOM import functionality is accessible from the DICOM perspective incorporating the QmitkDicomExternalDataWidget The customization of Qt Stylesheets is used to give the application a non native look and feel This is further emphasized by a Tab Widget like unification of the perspectives with the according perspective bar In addition to an absence of menu
Definition: CustomViewerExample.dox:312
berryIMenuManager.h
berryObjectMacro
#define berryObjectMacro(...)
Definition: berryMacros.h:31
berryContributionManager.h
berry
Definition: QmitkPropertyItemModel.h:24