Adding Macros!
[pierogi] / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include <QtGui/QMainWindow>
5
6 #include "pirkeynames.h"
7 #include "pirpanelnames.h"
8 #include "pirmodprobe.h"
9
10 class QListWidget;
11 class QListWidgetItem;
12 class QDialog;
13 class QKeyEvent;
14
15 class PIRSelectKeysetForm;
16 class PIRSelectDeviceForm;
17 class PIRPreferencesForm;
18 class PIRDocumentationForm;
19 class PIRAboutForm;
20 class PIRFavoritesDialog;
21 class PIRKeysetWidgetItem;
22 class PIRMacroPack;
23
24 class PIRKeysetManager;
25 class PIRPanelManager;
26 class PIRMacroManager;
27
28 namespace Ui {
29     class MainWindow;
30 }
31
32 class MainWindow : public QMainWindow
33 {
34   Q_OBJECT
35
36 public:
37   enum ScreenOrientation {
38     ScreenOrientationLockPortrait,
39     ScreenOrientationLockLandscape,
40     ScreenOrientationAuto
41   };
42
43   explicit MainWindow(QWidget *parent = 0);
44   virtual ~MainWindow();
45
46   // Note that this will only have an effect on Symbian and Fremantle.
47   void setOrientation(ScreenOrientation orientation);
48
49   void showExpanded();
50
51   bool startRepeating(
52     PIRKeyName name);
53
54   bool startRepeating(
55     PIRKeyName name,
56     unsigned int keysetID);
57
58   void stopRepeating();
59
60   // Favorites panel actions:
61   void addToFavorites(
62     PIRKeysetWidgetItem *kwi);
63
64   void removeFromFavorites(
65     unsigned int keysetID);
66
67   void enableButtons();
68
69   // Preferences actions:
70   void useMainPanel();
71   void useAltMainPanel();
72
73   QString getCurrentMake();
74   QString getCurrentName();
75   QString getCurrentFullName();
76
77   QString getKeysetMake(
78     unsigned int id);
79
80   QString getKeysetName(
81     unsigned int id);
82
83   QString getFullKeysetName(
84     unsigned int id);
85
86   unsigned int getCurrentKeyset()
87   {
88     return currentKeyset;
89   }
90
91   bool findKeysetID(
92     QString make,
93     QString name,
94     unsigned int &id);
95
96   void insertCornerButtons();
97   void disableUpdates();
98   void enableUpdates();
99   void clearTabs();
100   void addTab(
101     QWidget *page,
102     QString label);
103   void setupTabs(PIRTabBarName name);
104
105   bool selectNextKeyset();
106   bool selectPrevKeyset();
107   bool selectFirstKeyset();
108   void openCurrentKeysetDialog();
109
110   void updateKeysetSelection(
111     unsigned int targetID);
112
113   PIRMacroPack *getUserPack();
114   PIRMacroPack *getMultitapPack();
115
116   bool hasMacroButton(
117     unsigned int buttonID);
118
119   QString getMacroButtonText(
120     unsigned int buttonID);
121
122   void executeMacroButton(
123     unsigned int buttonID);
124
125   void updateUserButtons(); // Should this be a slot?
126
127   void storeMacros();
128
129   void setMacroKbdFocus(
130     int index);
131
132   void setMacroBtnFocus(
133     int index);
134
135 signals:
136   void buttonPressed(
137     unsigned int keysetID,
138     PIRKeyName name);
139
140   void buttonReleased();
141
142 public slots:
143   void receivedExternalWarning(
144     const char *warning);
145
146   void selectPrevFavKeyset();
147   void selectNextFavKeyset();
148
149   void keysetSelectionChanged(
150     QListWidgetItem *item);
151
152 private slots:
153   void on_actionSelectKeyset_triggered();
154   void on_actionBrowse_Device_List_triggered();
155   void on_actionPreferences_triggered();
156   void on_actionAbout_triggered();
157   void on_actionDocumentation_triggered();
158
159   // Internal actions:
160   void finalCleanup();
161
162 private:
163   void keyPressEvent(
164     QKeyEvent *event);
165
166   void populateFavorites();
167
168   Ui::MainWindow *ui;
169
170   PIRSelectKeysetForm *selectKeysetForm;
171   PIRSelectDeviceForm *selectDeviceForm;
172   PIRPreferencesForm *preferencesForm;
173   PIRDocumentationForm *documentationForm;
174   PIRAboutForm *aboutForm;
175   PIRFavoritesDialog *favoritesDialog;
176
177   PIRKeysetManager *myKeysets;
178   PIRPanelManager *myPanels;
179   PIRMacroManager *myMacros;
180
181   unsigned int currentKeyset;
182
183   PIRModprobe modprobeObj;
184 };
185
186
187 #endif // MAINWINDOW_H