Standalone simulator startup options (#4164)
[opentx.git] / companion / src / storage / appdata.h
blob5190503a8da59d2d92419d4d500b16d0624bd4a8
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 // All temporary and permanent global variables are defined here to make
22 // initialization and storage safe and visible.
23 // Do not access variables in QSettings directly, it is not type safe!
26 #ifndef _APPDATA_H_
27 #define _APPDATA_H_
28 #include <QByteArray>
29 #include <QStringList>
30 #include <QString>
31 #include <QSettings>
33 #define COMPANY "OpenTX"
34 #define PRODUCT "Companion 2.2"
36 #define MAX_PROFILES 15
37 #define MAX_JOYSTICKS 8
39 class CompStoreObj
41 public:
42 void clear (const QString tag1="", const QString tag2="", const QString tag3="");
43 void store(const QByteArray newArray, QByteArray &array, const QString tag, const QString group1="", const QString group2="" );
44 void store(const QStringList newSList, QStringList &stringList, const QString tag, const QString group1="", const QString group2="" );
45 void store(const QString newString, QString &string, const QString tag, const QString group1="", const QString group2="" );
46 void store(const bool newTruth, bool &truth, const QString tag, const QString group1="", const QString group2="" );
47 void store(const int newNumber, int &number, const QString tag, const QString group1="", const QString group2="" );
49 // Retrieval functions
50 void retrieve( QByteArray &array, const QString tag, const QString def, const QString group1="", const QString group2="" );
51 void retrieve( QStringList &stringList, const QString tag, const QString def, const QString group1="", const QString group2="" );
52 void retrieve( QString &string, const QString tag, const QString def, const QString group1="", const QString group2="" );
53 void retrieve( bool &truth, const QString tag, const bool def, const QString group1="", const QString group2="" );
54 void retrieve( int &number, const QString tag, const int def, const QString group1="", const QString group2="" );
56 // Retrieve and Store functions
57 void getset( QByteArray &array, const QString tag, const QString def, const QString group1="", const QString group2="" );
58 void getset( QStringList &stringList, const QString tag, const QString def, const QString group1="", const QString group2="" );
59 void getset( QString &string, const QString tag, const QString def, const QString group1="", const QString group2="" );
60 void getset( bool &truth, const QString tag, const bool def, const QString group1="", const QString group2="" );
61 void getset( int &number, const QString tag, const int def, const QString group1="", const QString group2="" );
64 class FwRevision: protected CompStoreObj
66 public:
67 int get( const QString);
68 void set( const QString, const int );
69 void remove( const QString );
72 class JStickData: protected CompStoreObj
74 private:
75 int index;
77 int _stickAxe;
78 int _stickMin;
79 int _stickMed;
80 int _stickMax;
81 int _stickInv;
83 public:
84 // All the get definitions
85 int stick_axe();
86 int stick_min();
87 int stick_med();
88 int stick_max();
89 int stick_inv();
91 // All the set definitions
92 void stick_axe(const int);
93 void stick_min(const int);
94 void stick_med(const int);
95 void stick_max(const int);
96 void stick_inv(const int);
98 JStickData();
99 void remove();
100 bool existsOnDisk();
101 void init(int index);
102 void flush();
105 class Profile: protected CompStoreObj
107 private:
108 // Class Internal Variable
109 int index;
111 // Application Variables
112 QString _fwName;
113 QString _fwType;
114 QString _name;
115 QString _sdPath;
116 int _volumeGain;
117 QString _pBackupDir;
118 QString _splashFile;
119 bool _burnFirmware;
120 bool _penableBackup;
121 bool _renameFwFiles;
122 int _channelOrder;
123 int _defaultMode;
125 // Simulator variables
126 QByteArray _simuWinGeo;
128 // Firmware Variables
129 QString _beeper;
130 QString _countryCode;
131 QString _display;
132 QString _haptic;
133 QString _speaker;
134 QString _stickPotCalib;
135 QString _timeStamp;
136 QString _trainerCalib;
137 QString _controlTypes;
138 QString _controlNames;
139 int _txCurrentCalibration;
140 int _gsStickMode;
141 int _ppmMultiplier;
142 int _txVoltageCalibration;
143 int _vBatWarn;
144 int _vBatMin;
145 int _vBatMax;
147 public:
148 // All the get definitions
149 QString fwName() const;
150 QString fwType() const;
151 QString name() const;
152 QString sdPath() const;
153 int volumeGain() const;
154 QString pBackupDir() const;
155 QString splashFile() const;
156 bool burnFirmware() const;
157 bool renameFwFiles() const;
158 bool penableBackup() const;
159 int channelOrder() const;
160 int defaultMode() const;
162 QByteArray simuWinGeo() const;
164 QString beeper() const;
165 QString countryCode() const;
166 QString display() const;
167 QString haptic() const;
168 QString speaker() const;
169 QString stickPotCalib() const;
170 QString timeStamp() const;
171 QString trainerCalib() const;
172 QString controlTypes() const;
173 QString controlNames() const;
174 int txCurrentCalibration() const;
175 int gsStickMode() const;
176 int ppmMultiplier() const;
177 int txVoltageCalibration() const;
178 int vBatWarn() const;
179 int vBatMin() const;
180 int vBatMax() const;
182 // All the set definitions
183 void name (const QString);
184 void fwName (const QString);
185 void fwType (const QString);
186 void volumeGain (const int);
187 void sdPath (const QString);
188 void pBackupDir (const QString);
189 void splashFile (const QString);
190 void burnFirmware (const bool);
191 void renameFwFiles (const bool);
192 void penableBackup (const bool);
193 void channelOrder (const int);
194 void defaultMode (const int);
196 void simuWinGeo (const QByteArray);
198 void beeper (const QString);
199 void countryCode (const QString);
200 void display (const QString);
201 void haptic (const QString);
202 void speaker (const QString);
203 void stickPotCalib (const QString);
204 void timeStamp (const QString);
205 void trainerCalib (const QString);
206 void controlTypes (const QString);
207 void controlNames (const QString);
208 void txCurrentCalibration (const int);
209 void gsStickMode (const int);
210 void ppmMultiplier (const int);
211 void txVoltageCalibration (const int);
212 void vBatWarn (const int);
213 void vBatMin (const int);
214 void vBatMax (const int);
216 Profile();
217 Profile& operator=(const Profile&);
218 void remove();
219 bool existsOnDisk();
220 void init(int newIndex);
221 void initFwVariables();
222 void flush();
225 #define BOOL_PROPERTY(name, dflt) \
226 public: \
227 inline bool name() { return _ ## name; } \
228 void name(const bool val) { store(val, _ ## name, # name); } \
229 private: \
230 bool _ ## name;
232 class AppData: protected CompStoreObj
234 BOOL_PROPERTY(enableBackup, false)
235 BOOL_PROPERTY(outputDisplayDetails, false)
236 BOOL_PROPERTY(backupOnFlash, true)
237 BOOL_PROPERTY(checkHardwareCompatibility, true)
238 BOOL_PROPERTY(useCompanionNightlyBuilds, false)
239 BOOL_PROPERTY(useFirmwareNightlyBuilds, false)
241 // All the global variables
242 public:
243 Profile profile[MAX_PROFILES];
244 JStickData joystick[MAX_JOYSTICKS];
245 FwRevision fwRev;
247 private:
248 QStringList _recentFiles;
249 QByteArray _mainWinGeo;
250 QByteArray _mainWinState;
251 QByteArray _modelEditGeo;
253 QString _armMcu;
254 QString _avrArguments;
255 QString _avrPort;
256 QString _avrdudeLocation;
257 QString _dfuArguments;
258 QString _dfuLocation;
259 QString _locale;
260 QString _mcu;
261 QString _programmer;
262 QString _sambaLocation;
263 QString _sambaPort;
264 QString _lastSimulator;
265 QString _simuLastEepe;
267 QString _backupDir;
268 QString _gePath;
269 QString _eepromDir;
270 QString _flashDir;
271 QString _imagesDir;
272 QString _logDir;
273 QString _libDir;
274 QString _snapshotDir;
275 QString _updatesDir;
277 bool _maximized;
278 bool _jsSupport;
279 bool _showSplash;
280 bool _snapToClpbrd;
281 bool _autoCheckApp;
282 bool _autoCheckFw;
283 bool _simuSW;
284 bool _useWizard;
286 int _backLight;
287 int _embedSplashes;
288 int _fwServerFails;
289 int _generalEditTab;
290 int _iconSize;
291 int _jsCtrl;
292 int _historySize;
293 int _id;
294 int _theme;
295 int _warningId;
296 int _simuLastProfId;
298 public:
299 // All the get definitions
300 QStringList recentFiles();
301 QByteArray mainWinGeo();
302 QByteArray mainWinState();
303 QByteArray modelEditGeo();
305 QString armMcu();
306 QString avrArguments();
307 QString avrPort();
308 QString avrdudeLocation();
309 QString dfuArguments();
310 QString dfuLocation();
311 QString lastFw();
312 QString locale();
313 QString mcu();
314 QString programmer();
315 QString sambaLocation();
316 QString sambaPort();
317 QString lastSimulator();
318 QString simuLastEepe();
320 QString backupDir();
321 QString gePath();
322 QString eepromDir();
323 QString flashDir();
324 QString imagesDir();
325 QString logDir();
326 QString libDir();
327 QString snapshotDir();
328 QString updatesDir();
330 bool jsSupport();
331 bool maximized();
332 bool showSplash();
333 bool snapToClpbrd();
334 bool autoCheckApp();
335 bool autoCheckFw();
336 bool simuSW();
337 bool useWizard();
339 int backLight();
340 int embedSplashes();
341 int fwServerFails();
342 int generalEditTab();
343 int iconSize();
344 int historySize();
345 int jsCtrl();
346 int id();
347 int theme();
348 int warningId();
349 int simuLastProfId();
351 // All the set definitions
352 void recentFiles (const QStringList x);
353 void mainWinGeo (const QByteArray);
354 void mainWinState (const QByteArray);
355 void modelEditGeo (const QByteArray);
357 void armMcu (const QString);
358 void avrArguments (const QString);
359 void avrPort (const QString);
360 void avrdudeLocation (const QString);
361 void dfuArguments (const QString);
362 void dfuLocation (const QString);
363 void lastFw (const QString);
364 void locale (const QString);
365 void mcu (const QString);
366 void programmer (const QString);
367 void sambaLocation (const QString);
368 void sambaPort (const QString);
369 void lastSimulator (const QString);
370 void simuLastEepe (const QString);
372 void backupDir (const QString);
373 void gePath (const QString);
374 void eepromDir (const QString);
375 void flashDir (const QString);
376 void imagesDir (const QString);
377 void logDir (const QString);
378 void libDir (const QString);
379 void snapshotDir (const QString);
380 void updatesDir (const QString);
382 void maximized (const bool);
383 void jsSupport (const bool);
384 void showSplash (const bool);
385 void snapToClpbrd (const bool);
386 void autoCheckApp (const bool);
387 void autoCheckFw (const bool);
388 void simuSW (const bool);
389 void useWizard (const bool);
391 void backLight (const int);
392 void embedSplashes (const int);
393 void fwServerFails (const int);
394 void generalEditTab (const int);
395 void iconSize (const int);
396 void historySize (const int);
397 void jsCtrl (const int);
398 void modelEditTab (const int);
399 void id (const int);
400 void theme (const int);
401 void warningId (const int);
402 void simuLastProfId (const int);
404 // Constructor
405 AppData();
406 void init();
408 QMap<int, QString> getActiveProfiles();
411 extern AppData g;
413 #endif // _APPDATA_H_