Make TX volatge for simu more flexible (#7124)
[opentx.git] / companion / src / mainwindow.h
blob222c047e035628f771f319d16c1506c74af7ba7a
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 QT_END_NAMESPACE
39 class MainWindow : public QMainWindow
41 friend class FirmwarePreferencesDialog;
43 Q_OBJECT
45 public:
46 MainWindow();
47 ~MainWindow();
49 signals:
50 void firmwareDownloadCompleted();
51 void firmwareChanged();
52 void startSync();
54 protected:
55 QString getCompanionUpdateBaseUrl() const;
56 QString seekCodeString(const QByteArray & qba, const QString & label) const;
58 protected slots:
59 void dowloadLastFirmwareUpdate();
60 void startFirmwareDownload();
61 virtual void closeEvent(QCloseEvent *event);
62 virtual void changeEvent(QEvent *e);
63 virtual void dragEnterEvent(QDragEnterEvent *event);
64 virtual void dropEvent(QDropEvent *event);
66 private slots:
67 void openDocURL();
68 void initWindowOptions();
69 void retranslateUi(bool showMsg = false);
71 void setLanguage(const QString & langString);
72 void onLanguageChanged(QAction * act);
73 void setTheme(int index);
74 void onThemeChanged(QAction * act);
75 void setIconThemeSize(int index);
76 void onIconSizeChanged(QAction * act);
77 void setTabbedWindows(bool on);
78 void onChangeWindowAction(QAction * act);
79 void updateWindowActions();
80 void updateWindowActionTitle(const QMdiSubWindow * win, QAction * act = NULL);
81 void onSubwindowTitleChanged();
82 void onSubwindowModified();
83 void onCurrentProfileChanged();
85 void checkForUpdates();
86 void checkForFirmwareUpdate();
88 void checkForCompanionUpdateFinished(QNetworkReply * reply);
89 void checkForFirmwareUpdateFinished(QNetworkReply * reply);
91 void displayWarnings();
92 void doAutoUpdates();
93 void doUpdates();
94 void updateDownloaded();
95 void firmwareDownloadAccepted();
96 void newFile();
97 void openFile();
98 void save();
99 void saveAs();
100 void saveAll();
101 void closeFile();
102 void openRecentFile();
103 bool loadProfileId(const unsigned pid);
104 void loadProfile();
105 void logFile();
106 void writeEeprom();
107 void readEeprom();
108 void writeFlash(QString fileToFlash="");
109 void readFlash();
110 void writeBackup();
111 void readBackup();
112 void burnConfig();
113 void burnList();
114 void burnFuses();
115 void contributors();
116 void sdsync();
117 void changelog();
118 void customizeSplash();
119 void about();
120 void compare();
121 void appPrefs();
122 void fwPrefs();
123 void updateMenus();
124 void createProfile();
125 void copyProfile();
126 void deleteProfile(const int pid);
127 void deleteCurrentProfile();
128 void exportSettings();
129 void importSettings();
130 void autoClose();
132 void openUpdatesWaitDialog();
133 void closeUpdatesWaitDialog();
134 void onUpdatesError(const QString & err);
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 bool checkProfileRadioExists(int profId);
165 QMdiArea *mdiArea;
167 QString installer_fileName;
168 DownloadDialog * downloadDialog_forWait;
169 unsigned int checkForUpdatesState;
170 QString firmwareVersionString;
172 QNetworkAccessManager *networkManager;
174 QVector<QAction *> recentFileActs;
175 QVector<QAction *> profileActs;
176 QList<QAction *> fileWindowActions;
178 QMenu *fileMenu;
179 QMenu *editMenu;
180 QMenu *settingsMenu;
181 QMenu *burnMenu;
182 QMenu *helpMenu;
183 QMenu *windowMenu;
184 QMenu *iconThemeSizeMenu;
185 QMenu *themeMenu;
186 QMenu *recentFilesMenu;
187 QMenu *profilesMenu;
188 QActionGroup * windowsListActions;
189 QToolBar *fileToolBar;
190 QToolBar *editToolBar;
191 QToolBar *burnToolBar;
192 QToolBar *helpToolBar;
193 QAction *newAct;
194 QAction *openAct;
195 QAction *saveAct;
196 QAction *saveAsAct;
197 QAction *closeAct;
198 QAction *recentFilesAct;
199 QAction *exitAct;
200 QAction *appPrefsAct;
201 QAction *fwPrefsAct;
202 QAction *checkForUpdatesAct;
203 QAction *contributorsAct;
204 QAction *sdsyncAct;
205 QAction *changelogAct;
206 QAction *compareAct;
207 QAction *editSplashAct;
208 QAction *writeEepromAct;
209 QAction *readEepromAct;
210 QAction *burnConfigAct;
211 QAction *burnListAct;
212 QAction *burnFusesAct;
213 QAction *writeFlashAct;
214 QAction *readFlashAct;
215 QAction *writeBUToRadioAct;
216 QAction *readBUToFileAct;
217 QAction *aboutAct;
218 QAction *logsAct;
219 QAction *profilesMenuAct;
220 QAction *createProfileAct;
221 QAction *copyProfileAct;
222 QAction *deleteProfileAct;
223 QAction *exportSettingsAct;
224 QAction *importSettingsAct;
225 QAction *openDocURLAct;
226 QAction *actTabbedWindows;
227 QAction *actTileWindows;
228 QAction *actCascadeWindows;
229 QAction *actCloseAllWindows;
232 #endif // _MAINWINDOW_H_