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 _SIMULATORWIDGET_H_
22 #define _SIMULATORWIDGET_H_
24 #include "constants.h"
26 #include "radiodata.h"
27 #include "simulator.h"
33 #define FLASH_DURATION 10
35 #define CBEEP_ON "QLabel { background-color: #FF364E }"
36 #define CBEEP_OFF "QLabel { }"
38 void traceCb(const char * text
);
41 class SimulatorInterface
;
42 class SimulatedUIWidget
;
44 class RadioSwitchWidget
;
45 class VirtualJoystickWidget
;
56 class SimulatorWidget
;
59 using namespace Simulator
;
61 class SimulatorWidget
: public QWidget
66 explicit SimulatorWidget(QWidget
* parent
, SimulatorInterface
*simulator
, quint8 flags
=0);
67 virtual ~SimulatorWidget();
69 void setSdPath(const QString
& sdPath
);
70 void setDataPath(const QString
& dataPath
);
71 void setPaths(const QString
& sdPath
, const QString
& dataPath
);
72 void setRadioSettings(const GeneralSettings settings
);
73 bool setStartupData(const QByteArray
& dataSource
= NULL
, bool fromFile
= false);
74 bool setRadioData(RadioData
* radioData
);
75 bool setOptions(SimulatorOptions
& options
, bool withSave
= true);
76 bool saveRadioData(RadioData
* radioData
, const QString
& path
= "", QString
* error
= NULL
);
77 bool useTempDataPath(bool deleteOnClose
= true);
79 void deleteTempData();
81 void setUiAreaStyle(const QString
& style
);
82 void captureScreenshot(bool);
83 void setupJoysticks();
85 QString
getSdPath() const { return sdCardPath
; }
86 QString
getDataPath() const { return radioDataPath
; }
87 QVector
<keymapHelp_t
> * getKeymapHelp() { return &keymapHelp
; }
96 void setRadioProfileId(int value
);
97 void setupRadioWidgets();
99 void restoreRadioWidgetsState();
100 QList
<QByteArray
> saveRadioWidgetsState();
107 Ui::SimulatorWidget
* ui
;
108 SimulatorInterface
* simulator
;
110 GeneralSettings radioSettings
;
114 QVector
<keymapHelp_t
> keymapHelp
;
116 SimulatedUIWidget
* radioUiWidget
;
117 VirtualJoystickWidget
* vJoyLeft
;
118 VirtualJoystickWidget
* vJoyRight
;
120 QVector
<RadioSwitchWidget
*> switches
;
121 QVector
<RadioWidget
*> analogs
;
124 QString radioDataPath
;
125 QByteArray startupData
;
132 bool startupFromFile
;
133 bool deleteTempRadioData
;
134 bool saveTempRadioData
;
135 bool middleButtonPressed
;
143 //virtual void showEvent(QShowEvent *);
144 //virtual void closeEvent(QCloseEvent *);
145 virtual void mousePressEvent(QMouseEvent
*event
);
146 virtual void mouseReleaseEvent(QMouseEvent
*event
);
147 virtual void wheelEvent(QWheelEvent
*event
);
150 void onTrimPressed(int which
);
151 void onTrimReleased();
152 void onTrimSliderMoved(int which
, int value
);
154 void onjoystickAxisValueChanged(int axis
, int value
);
158 #endif // _SIMULATORWIDGET_H_