-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathmainwindow.h
190 lines (144 loc) · 4.76 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSettings>
#include <QLabel>
#include <QQuickWidget>
#include "emuthread.h"
#include "fbaboutdialog.h"
#include "lcdwidget.h"
#include "qmlbridge.h"
namespace Ui {
class MainWindow;
}
/* QQuickWidget does not care about QEvent::Leave,
* which results in MouseArea::containsMouse to get stuck when
* the mouse leaves the widget without triggering a move outside
* the MouseArea. Work around it by translating QEvent::Leave
* to a MouseMove to (0/0). */
class QQuickWidgetLessBroken : public QQuickWidget
{
Q_OBJECT
public:
explicit QQuickWidgetLessBroken(QWidget *parent) : QQuickWidget(parent) {}
virtual ~QQuickWidgetLessBroken() {}
protected:
bool event(QEvent *event) override;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
//Miscellaneous
void changeEvent(QEvent* event) override;
void closeEvent(QCloseEvent *) override;
void showStatusMsg(QString str);
void kitDataChanged(QModelIndex, QModelIndex, QVector<int> roles);
void kitAnythingChanged();
void currentKitChanged(const Kit &kit);
//Drag & Drop
void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent *ev) override;
//Menu "Emulator"
void restart();
void openConfiguration();
void startKit();
void startKitDiags();
//Menu "Tools"
void screenshot();
void recordGIF();
void connectUSB();
void usblinkChanged(bool state);
void setExtLCD(bool state);
void xmodemSend();
void switchToMobileUI();
//Menu "State"
bool resume();
void suspend();
void resumeFromFile();
void suspendToFile();
//Menu "Flash"
void saveFlash();
void createFlash();
//Menu "Docks"
void setUIEditMode(bool e);
//Menu "About"
void showAbout();
//State
void isBusy(bool busy);
void started(bool success);
void resumed(bool success);
void suspended(bool success);
void stopped();
//Serial
void serialChar(const char c);
//Debugging
void debugInputRequested(bool b);
void debugStr(QString str);
void debugCommand();
//File transfer
void changeProgress(int value);
void usblinkDownload(int progress);
void usblinkProgress(int progress);
//Tool bar (above screen)
void showSpeed(double value);
signals:
void debuggerCommand(QString input);
void usblink_progress_changed(int progress);
public:
static void usblink_progress_callback(int progress, void *data);
void switchUIMode(bool mobile_ui);
private:
void setActive(bool b);
void suspendToPath(QString path);
bool resumeFromPath(QString path);
void convertTabsToDocks();
void retranslateDocks();
void updateUIActionState(bool emulation_running);
void raiseDebugger();
void refillKitMenus();
void updateWindowTitle();
// This changes the current GUI language to the one given in parameter, if available.
// The change is persistent (saved in settings) if it was successful.
void switchTranslator(const QLocale &locale);
// QMLBridge is used as settings storage,
// so the settings have to be read from there
// and emu_thread configured appropriately.
void applyQMLBridgeSettings();
Ui::MainWindow *ui = nullptr;
QTranslator appTranslator;
// Used to show a status message permanently
QLabel status_label;
QSettings *settings = nullptr;
// To make it possible to activate the debugger
QDockWidget *dock_debugger = nullptr;
// Second LCDWidget for use as external window
LCDWidget lcd{this, Qt::Window};
// The about dialog
FBAboutDialog aboutDialog{this};
// The QML engine shared by the keypad, config dialog and mobile UI
QQmlEngine *qml_engine = nullptr;
// The config dialog component, used to create the config_dialog
QQmlComponent *config_component = nullptr;
// The QML Config Dialog
QObject *config_dialog = nullptr;
// The flash dialog component, used to create the flash_dialog
QQmlComponent *flash_dialog_component = nullptr;
// The QML Config Dialog
QObject *flash_dialog = nullptr;
// The Mobile UI component, used to create the mobile_dialog
QQmlComponent *mobileui_component = nullptr;
// A Mobile UI instance
QObject *mobileui_dialog = nullptr;
// Used for autosuspend on close.
// The close event has to be deferred until the suspend operation completed successfully.
bool close_after_suspend = false;
// Whether this MainWindow is in charge of communicating with EmuThread
bool is_active = false;
};
// Used as global instance by EmuThread and friends
extern MainWindow *main_window;
#endif // MAINWINDOW_H