HAL
graph_tab_widget.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
29 
33 
34 #include <QMap>
35 
36 class QTabWidget;
37 class QVBoxLayout;
38 
39 namespace hal
40 {
41  class SettingsItemDropdown;
42  class SettingsItemKeybind;
43 
49  {
50  Q_OBJECT
51 
52  public:
54 
60  GraphTabWidget(QWidget* parent = nullptr);
61 
67  virtual QList<QShortcut*> createShortcuts() override;
68 
76  int addTab(QWidget* tab, QString tab_name = "default");
77 
84  void showContext(GraphContext *context);
85 
91 
96  bool isSelectMode() const { return mSelectCursor == Select; }
97 
103  int visibleStatus(const GraphContext* ctx) const;
104 
107 
108 
111  void emitTerminatePicker() const;
112  Q_SIGNALS:
117 
118  public Q_SLOTS:
119 
126  void handleContextCreated(GraphContext* context);
127 
133  void handleContextRenamed(GraphContext* context);
134 
141  void handleContextRemoved(GraphContext* context);
142 
147  void handleTabChanged(int index);
148 
155  void handleGateFocus(u32 gateId);
156 
163  void handleNetFocus(u32 netId);
164 
171  void handleModuleFocus(u32 moduleId);
172 
179 
186  void setSelectCursor(int icurs);
187 
193  void handleTabCloseRequested(int index);
194 
200  void handleCloseTabsToRight(int index);
201 
207  void handleCloseTabsToLeft(int index);
208 
212  void handleCloseAllTabs();
213 
214  private Q_SLOTS:
215  void handleZoomInShortcut();
216  void handleZoomOutShortcut();
217  void handleFoldModuleShortcut();
218  void handleUnfoldModuleShortcut();
219  void handleRemoveNodeShortcut();
220 
221  private:
222  QTabWidget* mTabWidget;
223  QVBoxLayout* mLayout;
224 
225  float mZoomFactor;
226 
227  QMap<GraphContext*, QWidget*> mContextWidgetMap;
228 
229  int getContextTabIndex(const GraphContext *context) const;
230 
231  void addGraphWidgetTab(GraphContext* context);
232 
233  static SettingsItemDropdown* sSettingGridType;
234  static SettingsItemDropdown* sSettingDragModifier;
235  static SettingsItemDropdown* sSettingPanModifier;
236 
237  static SettingsItemKeybind* sSettingZoomIn;
238  static SettingsItemKeybind* sSettingZoomOut;
239  static SettingsItemKeybind* sSettingFoldModule;
240  static SettingsItemKeybind* sSettingUnfoldModule;
241  static SettingsItemKeybind* sSettingRemoveNode;
242 
243  static bool sSettingsInitialized;
244 
245  static bool initSettings();
246 
248  GraphCursor mSelectCursor;
249  };
250 }
Abstract class for Widgets within HAL's ContentArea.
Logical container for modules, gates, and nets.
Definition: graph_context.h:55
A ContentWidget that holds all GraphWidget objects (GraphView) as tabs of a QTabWidget.
void handleGateFocus(u32 gateId)
void handleTabCloseRequested(int index)
void handleCustomContextMenuRequested(const QPoint &pos)
void handleCloseTabsToRight(int index)
virtual QList< QShortcut * > createShortcuts() override
int visibleStatus(const GraphContext *ctx) const
void handleContextRemoved(GraphContext *context)
void setSelectCursor(int icurs)
void handleCloseTabsToLeft(int index)
void handleNetFocus(u32 netId)
void showContext(GraphContext *context)
Q_ENUM(KeyboardModifier) void emitTerminatePicker() const
int addTab(QWidget *tab, QString tab_name="default")
void handleContextCreated(GraphContext *context)
GraphTabWidget(QWidget *parent=nullptr)
void handleModuleFocus(u32 moduleId)
void handleTabChanged(int index)
void triggerTerminatePicker() const
bool isSelectMode() const
void handleContextRenamed(GraphContext *context)
A SettingsItem that represents a dropdown menu.
A SettingsItem to modify keybinds.
quint32 u32
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const