Advanced Settings Panel
[pierogi] / macros / pirmacro.h
1 #ifndef PIRMACRO_H
2 #define PIRMACRO_H
3
4 #include <QObject>
5 #include <QTreeWidgetItem>
6 #include <QString>
7
8 class PIRMacroCommandItem;
9 class PIRMacroPack;
10 class QListWidget;
11 class QSettings;
12 class MainWindow;
13
14 #include <list>
15 typedef std::list<PIRMacroCommandItem *> CommandSequence;
16
17 class PIRMacro: public QObject, public QTreeWidgetItem
18 {
19   Q_OBJECT
20
21 public:
22   PIRMacro(
23     PIRMacroPack *parent,
24     QString name,
25     char key,
26     unsigned int buttonID,
27     MainWindow *mw);
28
29   ~PIRMacro();
30
31   QString getName();
32
33   void setName(
34     QString name);
35
36   char getKey();
37
38   void setKey(
39     char key);
40
41   unsigned int getButtonID();
42
43   void setButtonID(
44     unsigned int id);
45
46   void appendCommand(
47     PIRMacroCommandItem *c);
48
49   bool deleteCommand(
50     int index);
51
52   bool moveUp(
53     int index);
54
55   bool moveDown(
56     int index);
57
58   void populateList(
59     QListWidget *lw);
60
61   bool executeMacro();
62
63   void storeSettings(
64     QSettings &settings);
65
66   QString getCommandType(
67     int index);
68
69   QString getCommandName(
70     int index);
71
72 signals:
73   void macroCompleted();
74
75 private slots:
76   void startNextCommand();
77
78 private:
79   char key;
80   unsigned int buttonID;
81   CommandSequence commands;
82   CommandSequence::iterator currentCommand;
83   unsigned int preMacroKeysetID;
84
85   static bool macroRunning; // only one macro can run at a time!
86
87   MainWindow *mainWindow;
88 };
89
90 #endif // PIRMACRO_H