OpenMS  2.7.0
TOPPViewMenu.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
44 
45 #include <QObject>
46 
47 #include <vector>
48 
49 class QAction;
50 class QMenu;
51 
52 namespace OpenMS
53 {
54  class TOPPViewBase;
55  class EnhancedWorkspace;
56  class RecentFilesMenu;
57 
58  enum class TV_STATUS
59  {
60  HAS_CANVAS,
61  HAS_LAYER,
62  HAS_MIRROR_MODE, // implies 1D View
63  IS_1D_VIEW,
64  TOPP_IDLE
65  };
66 
69  FS_TV OPENMS_GUI_DLLAPI operator+(const TV_STATUS left, const TV_STATUS right);
70 
73  FS_LAYER OPENMS_GUI_DLLAPI operator+(const LayerData::DataType left, const LayerData::DataType right);
74 
75 
83  : public QObject
84  {
85  Q_OBJECT
86  public:
93  TOPPViewMenu(TOPPViewBase* const parent, EnhancedWorkspace* const ws, RecentFilesMenu* const recent_files);
94 
96  void addWindowToggle(QAction* const window_toggle);
97 
98  public slots:
100  void update(const FS_TV status, const LayerData::DataType layer_type);
101 
102  private:
104  {
105  ActionRequirement_(QAction* action, const FS_TV& needs, const FS_LAYER layer_set)
106  : action_(action), needs_(needs), layer_set_(layer_set) {}
107  ActionRequirement_(QAction* action, const TV_STATUS& needs, const FS_LAYER layer_set)
108  : action_(action), needs_(needs), layer_set_(layer_set) {}
109 
113  void enableAction(const FS_TV status, const LayerData::DataType layer_type);
114 
115  private:
116  QAction* action_;
119  };
120 
124  QAction* addAction_(QAction* action, const TV_STATUS req, const FS_LAYER layer_set = FS_LAYER());
126  QAction* addAction_(QAction* action, const FS_TV req, const FS_LAYER layer_set = FS_LAYER());
127 
129  std::vector<ActionRequirement_> menu_items_;
130 
132  QMenu* m_windows_;
133  };
134 
135 } //namespace
136 
Definition: EnhancedWorkspace.h:53
DataType
Definition: LayerData.h:103
Manages recent files opened by the user and provides a QMenu to go with it.
Definition: RecentFilesMenu.h:61
Main window of TOPPView tool.
Definition: TOPPViewBase.h:127
The file menu items for TOPPView.
Definition: TOPPViewMenu.h:84
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:129
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
QMenu * m_windows_
the windows submenu (holds all windows added via addWindowToggle())
Definition: TOPPViewMenu.h:132
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 update(const FS_TV status, const LayerData::DataType layer_type)
enable/disable entries according to a given state of TOPPViewBase
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:47
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< LayerData::DataType > FS_LAYER
Definition: TOPPViewMenu.h:71
TV_STATUS
Definition: TOPPViewMenu.h:59
Definition: TOPPViewMenu.h:104
QAction * action_
Definition: TOPPViewMenu.h:116
FS_TV needs_
Definition: TOPPViewMenu.h:117
FS_LAYER layer_set_
Definition: TOPPViewMenu.h:118
ActionRequirement_(QAction *action, const FS_TV &needs, const FS_LAYER layer_set)
Definition: TOPPViewMenu.h:105
ActionRequirement_(QAction *action, const TV_STATUS &needs, const FS_LAYER layer_set)
Definition: TOPPViewMenu.h:107
void enableAction(const FS_TV status, const LayerData::DataType layer_type)