Fix doc path
[opentx.git] / companion / src / mainwindow.h
blob9f38bbc03584ef208dc9155046ee06a1186beedd
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _MAINWINDOW_H_
22 #define _MAINWINDOW_H_
24 #include <QtWidgets>
25 #include <QDateTime>
26 #include "downloaddialog.h"
27 #include "eeprominterface.h"
29 #define SPLASH_TIME 5
31 class MdiChild;
32 QT_BEGIN_NAMESPACE
33 class QAction;
34 class QMenu;
35 class QMdiArea;
36 class QMdiSubWindow;
37 class QSignalMapper;
38 QT_END_NAMESPACE
40 #define CHECK_COMPANION 1
41 #define CHECK_FIRMWARE 2
42 #define SHOW_DIALOG_WAIT 4
43 #define AUTOMATIC_DOWNLOAD 8
45 class MainWindow : public QMainWindow
47 friend class FirmwarePreferencesDialog;
49 Q_OBJECT
51 public:
52 MainWindow();
53 ~MainWindow();
55 signals:
56 void firmwareChanged();
57 void startSync();
59 protected:
60 QString getCompanionUpdateBaseUrl();
61 QString seekCodeString(const QByteArray & qba, const QString & label);
63 protected slots:
64 void dowloadLastFirmwareUpdate();
65 void startFirmwareDownload();
66 virtual void closeEvent(QCloseEvent *event);
67 virtual void changeEvent(QEvent *e);
68 virtual void dragEnterEvent(QDragEnterEvent *event);
69 virtual void dropEvent(QDropEvent *event);
71 private slots:
72 void openDocURL();
73 void retranslateUi(bool showMsg = false);
75 void setLanguage(const QString & langString);
76 void onLanguageChanged(QAction * act);
77 void setTheme(int index);
78 void onThemeChanged(QAction * act);
79 void setIconThemeSize(int index);
80 void onIconSizeChanged(QAction * act);
81 void setTabbedWindows(bool on);
82 void onChangeWindowAction(QAction * act);
83 void updateWindowActions();
84 void updateWindowActionTitle(const QMdiSubWindow * win, QAction * act = NULL);
85 void onSubwindowTitleChanged();
86 void onSubwindowModified();
88 void checkForUpdates();
89 void checkForFirmwareUpdate();
91 void checkForCompanionUpdateFinished(QNetworkReply * reply);
92 void checkForFirmwareUpdateFinished(QNetworkReply * reply);
94 void displayWarnings();
95 void doAutoUpdates();
96 void doUpdates();
97 void updateDownloaded();
98 void firmwareDownloadAccepted();
99 void newFile();
100 void openFile();
101 void save();
102 void saveAs();
103 void saveAll();
104 void closeFile();
105 void openRecentFile();
106 bool loadProfileId(const unsigned pid);
107 void loadProfile();
108 void logFile();
109 void writeEeprom();
110 void readEeprom();
111 void writeFlash(QString fileToFlash="");
112 void readFlash();
113 void writeBackup();
114 void readBackup();
115 void burnConfig();
116 void burnList();
117 void burnFuses();
118 void contributors();
119 void sdsync();
120 void changelog();
121 void customizeSplash();
122 void about();
123 void compare();
124 void appPrefs();
125 void fwPrefs();
126 void updateMenus();
127 void createProfile();
128 void copyProfile();
129 void deleteProfile(const int pid);
130 void deleteCurrentProfile();
131 void autoClose();
133 void closeUpdatesWaitDialog();
134 void onUpdatesError();
135 void openFile(const QString & fileName, bool updateLastUsedDir = false);
137 private:
138 QAction * addAct(const QString & icon, const char * slot = NULL, const QKeySequence & shortcut = 0, QObject * slotObj = NULL, const char * signal = NULL);
139 QAction * addActToGroup(QActionGroup * aGroup, const QString & sName, const QString & lName, const char * propName = 0,
140 const QVariant & propValue = QVariant(), const QVariant & dfltValue = QVariant(), const QKeySequence & shortcut = 0);
141 void trAct(QAction * act, const QString & text, const QString & descript);
143 QMenu * createLanguageMenu(QWidget * parent = Q_NULLPTR);
145 void createActions();
146 void createMenus();
147 void createToolBars();
148 void showReadyStatus();
149 void updateRecentFileActions();
150 void updateProfilesActions();
152 int newProfile(bool loadProfile = true);
153 QString strippedName(const QString & fullFileName);
155 MdiChild * createMdiChild();
156 MdiChild * activeMdiChild();
157 QMdiSubWindow * findMdiChild(const QString & fileName);
158 bool anyChildrenDirty();
160 bool readEepromFromRadio(const QString & filename);
161 bool readFirmwareFromRadio(const QString & filename);
163 QMdiArea *mdiArea;
164 QSignalMapper *windowMapper;
166 QString installer_fileName;
167 downloadDialog * downloadDialog_forWait;
168 unsigned int checkForUpdatesState;
169 QString firmwareVersionString;
171 QNetworkAccessManager *networkManager;
173 QVector<QAction *> recentFileActs;
174 QVector<QAction *> profileActs;
175 QList<QAction *> fileWindowActions;
177 QMenu *fileMenu;
178 QMenu *editMenu;
179 QMenu *settingsMenu;
180 QMenu *burnMenu;
181 QMenu *helpMenu;
182 QMenu *windowMenu;
183 QMenu *iconThemeSizeMenu;
184 QMenu *themeMenu;
185 QMenu *recentFilesMenu;
186 QMenu *profilesMenu;
187 QActionGroup * windowsListActions;
188 QToolBar *fileToolBar;
189 QToolBar *editToolBar;
190 QToolBar *burnToolBar;
191 QToolBar *helpToolBar;
192 QAction *newAct;
193 QAction *openAct;
194 QAction *saveAct;
195 QAction *saveAsAct;
196 QAction *closeAct;
197 QAction *recentFilesAct;
198 QAction *exitAct;
199 QAction *appPrefsAct;
200 QAction *fwPrefsAct;
201 QAction *checkForUpdatesAct;
202 QAction *contributorsAct;
203 QAction *sdsyncAct;
204 QAction *changelogAct;
205 QAction *compareAct;
206 QAction *editSplashAct;
207 QAction *writeEepromAct;
208 QAction *readEepromAct;
209 QAction *burnConfigAct;
210 QAction *burnListAct;
211 QAction *burnFusesAct;
212 QAction *writeFlashAct;
213 QAction *readFlashAct;
214 QAction *writeBUToRadioAct;
215 QAction *readBUToFileAct;
216 QAction *aboutAct;
217 QAction *logsAct;
218 QAction *profilesMenuAct;
219 QAction *createProfileAct;
220 QAction *copyProfileAct;
221 QAction *deleteProfileAct;
222 QAction *openDocURLAct;
223 QAction *actTabbedWindows;
224 QAction *actTileWindows;
225 QAction *actCascadeWindows;
226 QAction *actCloseAllWindows;
229 #endif // _MAINWINDOW_H_