HAL
user_action_manager.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 #include <QObject>
28 #include <QList>
29 #include <QHash>
30 #include <QXmlStreamWriter>
31 #include <QXmlStreamReader>
32 #include <QElapsedTimer>
33 #include <QPlainTextEdit>
34 #include <QMessageBox>
35 #include <QMutex>
36 #include "hal_core/defines.h"
37 
38 namespace hal
39 {
40  class UserAction;
41  class UserActionFactory;
42  class GraphContext;
43  class SettingsItemCheckbox;
44 
53  class UserActionManager : public QObject
54  {
55  Q_OBJECT
56  public:
57 
63  static UserActionManager* instance();
64 
70  void addExecutedAction(UserAction* act);
71 
78 
82  void setStartRecording();
83 
91 
97  void playMacro(const QString& macroFilename);
98 
104  bool isRecording() const;
105 
112  bool hasRecorded() const;
113 
122 
128  qint64 timeStamp() const { return mElapsedTime.elapsed(); }
129 
133  void undoLastAction();
134 
140  void crashDump(int sig);
141 
143 
144  private:
145  UserActionManager(QObject *parent = nullptr);
146  void testUndo();
147 
148  QList<UserAction*> mActionHistory;
149  QHash<QString,UserActionFactory*> mActionFactory;
150  int mStartRecording;
151  QElapsedTimer mElapsedTime;
152  bool mRecordHashAttribute;
153 
154  static UserActionManager* inst;
155  QPlainTextEdit* mDumpAction;
156  SettingsItemCheckbox* mSettingDumpAction;
157  UserAction* mThreadedAction;
158  QMutex mMutex;
159 
160  public Q_SLOTS:
166  void handleSettingDumpActionChanged(bool wantDump);
167 
168  private Q_SLOTS:
169  void handleTriggerExecute();
170 
171  Q_SIGNALS:
178  void canUndoLastAction(bool yesWeCan);
179 
181  };
182 }
A SettingsItem representing a Checkbox.
The UserActionFactory is the abstract base class for registration.
Definition: user_action.h:225
The UserAction class is the abstract base class for user interactions.
Definition: user_action.h:57
Handles and manages user actions related proccesses.
void addExecutedAction(UserAction *act)
void registerFactory(UserActionFactory *fac)
void handleSettingDumpActionChanged(bool wantDump)
void canUndoLastAction(bool yesWeCan)
void executeActionBlockThread(UserAction *act)
static UserActionManager * instance()
void playMacro(const QString &macroFilename)
QMessageBox::StandardButton setStopRecording(const QString &macroFilename)
UserAction * getParsedAction(QXmlStreamReader &xmlIn) const
qint64 elapsed() const const
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const