HAL
main_window.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 
28 #include "gui/action/action.h"
31 #include "gui/splitter/splitter.h"
34 
35 #include <QLayout>
36 #include <QMenuBar>
37 #include <QObject>
38 #include <QSplitter>
39 #include <QStackedWidget>
40 #include <QToolBar>
42 
43 namespace hal
44 {
45  class plugin_manager_dialog;
46  class PythonEditor;
47  class FileManager;
48  class FileActions;
49  class ContentManager;
50  class WelcomeScreen;
51  class SettingsItemKeybind;
53  class GuiPluginManager;
54 
64  class MainWindow : public QWidget
65  {
66  Q_OBJECT
69 
83 
84  public:
87 
88 
93  explicit MainWindow(QWidget* parent = nullptr);
94 
95 
96  // =====================================================================
97  // Q_PROPERTY functions
98  // =====================================================================
101 
108  QString halIconPath() const;
114  QString halIconStyle() const;
115 
121  QString openFileIconPath() const;
127  QString openFileIconStyle() const;
128 
134  QString quitIconPath() const;
140  QString quitIconStyle() const;
141 
147  QString settingsIconPath() const;
153  QString settingsIconStyle() const;
154 
160  QString pluginsIconPath() const;
166  QString pluginsIconStyle() const;
167 
168  QString undoIconPath() const;
169  QString undoIconStyle() const;
170  QString disabledIconStyle() const;
171  QString neGateIconPath() const;
172  QString neGateIconStyle() const;
173 
179  void setHalIconPath(const QString& path);
185  void setHalIconStyle(const QString &style);
186 
192  void setOpenFileIconPath(const QString& path);
198  void setOpenFileIconStyle(const QString& style);
199 
205  void setQuitIconPath(const QString& path);
211  void setQuitIconStyle(const QString& style);
212 
218  void setScheduleIconPath(const QString& path);
225 
231  void setRunIconPath(const QString& path);
238 
244  void setContentIconPath(const QString& path);
251 
257  void setSettingsIconPath(const QString& path);
263  void setSettingsIconStyle(const QString& style);
264 
270  void setPluginsIconPath(const QString& path);
276  void setPluginsIconStyle(const QString& style);
277 
278  void setUndoIconPath(const QString& path);
279  void setUndoIconStyle(const QString& style);
280  void setDisabledIconStyle(const QString &style);
281  void setNeGateIconPath(const QString &path);
282  void setNeGateIconStyle(const QString &style);
283 
291  void addContent(ContentWidget* widget, int index, ContentLayout::Position anchor);
292 
298  void removeContent(ContentWidget* widget);
299 
300  void clear();
301 
303 
304  public Q_SLOTS:
308  void onActionQuitTriggered();
309 
315 
319  void openSettings();
320 
324  void closeSettings();
325 
330 
334  void openPluginManager();
335 
339  void closePluginManager();
340 
345  void handleActionNew();
346 
351 
356 
362  void handleFileOpened(const QString& fileName);
363 
370  void handleProjectOpened(const QString& projDir, const QString& fileName);
371 
376  void handleSaveTriggered();
377 
383  void handleSaveAsTriggered();
384 
388  void handleActionCloseFile();
389 
395 
400 
404  void handleActionPlayMacro();
405 
409  void handleActionUndo();
410 
414  void handleActionAbout();
415 
419  void handleActionExport();
420 
425 
426  void enableUndo(bool enable=true);
427 
428  void reloadStylsheet(int istyle);
429 
433  ContentLayoutArea* layoutArea() const;
434 
435  private Q_SLOTS:
440  void handleEventLogEnabled(bool enable);
441 
442  void handleExportProjectTriggered();
443 
444  void handleImportProjectTriggered();
445 
446  private:
453  void closeEvent(QCloseEvent* event);
454 
455  bool tryToCloseFile();
456 
464  QString saveHandler(const QString& projectDir = QString());
465 
469  void restoreState();
470 
475  void saveState();
476 
477  QVBoxLayout* mLayout;
478  QMenuBar* mMenuBar;
479  QStackedWidget* mStackedWidget;
480 
481  MainSettingsWidget* mSettings;
482  GuiPluginManager* mPluginManager;
483  WelcomeScreen* mWelcomeScreen;
484  GateLibraryManager* mGateLibraryManager;
485  QHBoxLayout* mToolBarLayout;
486  QToolBar* mLeftToolBar;
487  QToolBar* mRightToolBar;
488  ContentLayoutArea* mLayoutArea;
489 
490  FileActions* mFileActions;
491  Action* mActionImportNetlist;
492  Action* mActionGateLibraryManager;
493  Action* mActionAbout;
494  Action* mActionStartRecording;
495  Action* mActionStopRecording;
496  Action* mActionPlayMacro;
497  Action* mActionUndo;
498  Action* mActionExportProject;
499  Action* mActionImportProject;
500 
501  Action* mActionSettings;
502  Action* mActionPluginManager;
503  Action* mActionQuit;
504 
505  QMenu* mMenuFile;
506  QMenu* mMenuEdit;
507  QMenu* mMenuMacro;
508  QMenu* mMenuUtilities;
509  QMenu* mMenuPlugins;
510  QMenu* mMenuHelp;
511 
512  QString mHalIconStyle;
513  QString mHalIconPath;
514 
515  QString mOpenFileIconPath;
516  QString mOpenFileIconStyle;
517 
518  QString mQuitIconPath;
519  QString mQuitIconStyle;
520 
521  QString mSettingsIconPath;
522  QString mSettingsIconStyle;
523 
524  QString mPluginsIconPath;
525  QString mPluginsIconStyle;
526 
527  QString mUndoIconPath;
528  QString mUndoIconStyle;
529 
530  QString mDisabledIconStyle;
531 
532  QString mNeGateIconPath;
533  QString mNeGateIconStyle;
534 
535  SettingsItemKeybind* mSettingUndoLast;
536 
537  };
538 }
Provides an interface for triggerable functionality that can be inserted into widgets and also connec...
Definition: action.h:42
Manages the layout of all ContentWidgets.
Manages all ContentWidgets.
Abstract class for Widgets within HAL's ContentArea.
Stores information about the currently opened netlist.
Definition: file_manager.h:48
The top-level widget that displays all settings.
The top level widget.
Definition: main_window.h:65
void closeGateLibraryManager()
void openPluginManager()
void handleActionImportNetlist()
void handleActionOpenProject()
QString quitIconStyle
Definition: main_window.h:73
void setUndoIconStyle(const QString &style)
void setRunIconStyle(const QString &style)
QString halIconPath
Definition: main_window.h:67
void handleActionAbout()
void handleActionGatelibraryManager()
void setHalIconPath(const QString &path)
QString undoIconStyle
Definition: main_window.h:79
void handleSaveAsTriggered()
void handleActionUndo()
QString settingsIconPath
Definition: main_window.h:74
void closePluginManager()
void handleActionCloseFile()
QString openFileIconStyle
Definition: main_window.h:71
void reloadStylsheet(int istyle)
void setContentIconPath(const QString &path)
void handleActionStopRecording()
QString pluginsIconStyle
Definition: main_window.h:77
void setScheduleIconStyle(const QString &style)
void setNeGateIconStyle(const QString &style)
void setSettingsIconStyle(const QString &style)
QString quitIconPath
Definition: main_window.h:72
void setScheduleIconPath(const QString &path)
void handleActionNew()
ContentLayoutArea * layoutArea() const
QString neGateIconPath
Definition: main_window.h:81
void setOpenFileIconPath(const QString &path)
void handleActionStartRecording()
void enableUndo(bool enable=true)
QString disabledIconStyle
Definition: main_window.h:80
void handleProjectOpened(const QString &projDir, const QString &fileName)
void addContent(ContentWidget *widget, int index, ContentLayout::Position anchor)
void setNeGateIconPath(const QString &path)
void setOpenFileIconStyle(const QString &style)
Q_ENUM(StyleSheetOption) explicit MainWindow(QWidget *parent
QString neGateIconStyle
Definition: main_window.h:82
void setUndoIconPath(const QString &path)
QString openFileIconPath
Definition: main_window.h:70
void handleActionPlayMacro()
QString halIconStyle
Definition: main_window.h:68
void onActionQuitTriggered()
void handleFileOpened(const QString &fileName)
void setRunIconPath(const QString &path)
void setSettingsIconPath(const QString &path)
void removeContent(ContentWidget *widget)
void setContentIconStyle(const QString &style)
void setQuitIconPath(const QString &path)
QString settingsIconStyle
Definition: main_window.h:75
void setHalIconStyle(const QString &style)
void onActionCloseDocumentTriggered()
void handleSaveTriggered()
void setQuitIconStyle(const QString &style)
void handleActionExport()
static SettingsItemDropdown * sSettingStyle
Definition: main_window.h:302
QString undoIconPath
Definition: main_window.h:78
void setDisabledIconStyle(const QString &style)
QString pluginsIconPath
Definition: main_window.h:76
void setPluginsIconStyle(const QString &style)
void setPluginsIconPath(const QString &path)
Main widget that combines all neccessary functionality to develop in python (for hal).
Definition: python_editor.h:99
A SettingsItem that represents a dropdown menu.
A SettingsItem to modify keybinds.
Hal's welcome screen.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
virtual bool event(QEvent *event) override
QStyle * style() const const