OpenMS
TOPPViewMenu.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
18 
19 #include <QObject>
20 
21 #include <vector>
22 
23 class QAction;
24 class QMenu;
25 
26 namespace OpenMS
27 {
28  class TOPPViewBase;
29  class EnhancedWorkspace;
30  class RecentFilesMenu;
31 
32  enum class TV_STATUS
33  {
34  HAS_CANVAS,
35  HAS_LAYER,
36  HAS_MIRROR_MODE, // implies 1D View
37  IS_1D_VIEW,
38  TOPP_IDLE
39  };
40 
43  FS_TV OPENMS_GUI_DLLAPI operator+(const TV_STATUS left, const TV_STATUS right);
44 
47  FS_LAYER OPENMS_GUI_DLLAPI operator+(const LayerDataBase::DataType left, const LayerDataBase::DataType right);
48 
49 
57  : public QObject
58  {
59  Q_OBJECT
60  public:
67  TOPPViewMenu(TOPPViewBase* const parent, EnhancedWorkspace* const ws, RecentFilesMenu* const recent_files);
68 
70  void addWindowToggle(QAction* const window_toggle);
71 
72  public slots:
74  void update(const FS_TV status, const LayerDataBase::DataType layer_type);
75 
76  private:
78  {
79  ActionRequirement_(QAction* action, const FS_TV& needs, const FS_LAYER layer_set)
80  : action_(action), needs_(needs), layer_set_(layer_set) {}
81  ActionRequirement_(QAction* action, const TV_STATUS& needs, const FS_LAYER layer_set)
82  : action_(action), needs_(needs), layer_set_(layer_set) {}
83 
87  void enableAction(const FS_TV status, const LayerDataBase::DataType layer_type);
88 
89  private:
90  QAction* action_;
93  };
94 
98  QAction* addAction_(QAction* action, const TV_STATUS req, const FS_LAYER layer_set = FS_LAYER());
100  QAction* addAction_(QAction* action, const FS_TV req, const FS_LAYER layer_set = FS_LAYER());
101 
103  std::vector<ActionRequirement_> menu_items_;
104 
106  QMenu* m_windows_;
107  };
108 
109 } //namespace
110 
Definition: EnhancedWorkspace.h:27
Manages recent files opened by the user and provides a QMenu to go with it.
Definition: RecentFilesMenu.h:35
Main window of TOPPView tool.
Definition: TOPPViewBase.h:103
The file menu items for TOPPView.
Definition: TOPPViewMenu.h:58
std::vector< ActionRequirement_ > menu_items_
holds all actions which have a set of requirements, i.e. depend on the state of TOPPViewBase
Definition: TOPPViewMenu.h:103
QAction * addAction_(QAction *action, const TV_STATUS req, const FS_LAYER layer_set=FS_LAYER())
QAction * addAction_(QAction *action, const FS_TV req, const FS_LAYER layer_set=FS_LAYER())
overload for multiple requirements
void update(const FS_TV status, const LayerDataBase::DataType layer_type)
enable/disable entries according to a given state of TOPPViewBase
QMenu * m_windows_
the windows submenu (holds all windows added via addWindowToggle())
Definition: TOPPViewMenu.h:106
TOPPViewMenu(TOPPViewBase *const parent, EnhancedWorkspace *const ws, RecentFilesMenu *const recent_files)
Constructor which connects slots/signals of this class with the objects given as arguments.
void addWindowToggle(QAction *const window_toggle)
add a menu entry at 'Windows -> [Windowname]' to allow hiding/showing a TOPPView subwindow (e....
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
FS_TV operator+(const TV_STATUS left, const TV_STATUS right)
allow + operations on the enum, e.g. 'HAS_CANVAS + HAS_LAYER + IS_1D_VIEW'
FlagSet< LayerDataBase::DataType > FS_LAYER
Definition: TOPPViewMenu.h:45
TV_STATUS
Definition: TOPPViewMenu.h:33
DataType
Definition: LayerDataBase.h:73
Definition: TOPPViewMenu.h:78
QAction * action_
Definition: TOPPViewMenu.h:90
FS_TV needs_
Definition: TOPPViewMenu.h:91
FS_LAYER layer_set_
Definition: TOPPViewMenu.h:92
ActionRequirement_(QAction *action, const FS_TV &needs, const FS_LAYER layer_set)
Definition: TOPPViewMenu.h:79
ActionRequirement_(QAction *action, const TV_STATUS &needs, const FS_LAYER layer_set)
Definition: TOPPViewMenu.h:81
void enableAction(const FS_TV status, const LayerDataBase::DataType layer_type)