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"
32 #define FLASH_DURATION 10
34 #define CBEEP_ON "QLabel { background-color: #FF364E }"
35 #define CBEEP_OFF "QLabel { }"
37 void traceCb(const char * text
);
40 class SimulatorInterface
;
41 class SimulatedUIWidget
;
43 class RadioSwitchWidget
;
44 class VirtualJoystickWidget
;
55 class SimulatorWidget
;
58 using namespace Simulator
;
60 class SimulatorWidget
: public QWidget
65 explicit SimulatorWidget(QWidget
* parent
, SimulatorInterface
*simulator
, quint8 flags
=0);
66 virtual ~SimulatorWidget();
68 void setSdPath(const QString
& sdPath
);
69 void setDataPath(const QString
& dataPath
);
70 void setPaths(const QString
& sdPath
, const QString
& dataPath
);
71 void setRadioSettings(const GeneralSettings settings
);
72 bool setStartupData(const QByteArray
& dataSource
= NULL
, bool fromFile
= false);
73 bool setRadioData(RadioData
* radioData
);
74 bool setOptions(SimulatorOptions
& options
, bool withSave
= true);
75 bool saveRadioData(RadioData
* radioData
, const QString
& path
= "", QString
* error
= NULL
);
76 bool useTempDataPath(bool deleteOnClose
= true);
78 void deleteTempData();
80 void setUiAreaStyle(const QString
& style
);
81 void captureScreenshot(bool);
82 void setupJoysticks();
84 QString
getSdPath() const { return sdCardPath
; }
85 QString
getDataPath() const { return radioDataPath
; }
86 QVector
<keymapHelp_t
> * getKeymapHelp() { return &keymapHelp
; }
95 void setRadioProfileId(int value
);
96 void setupRadioWidgets();
98 void restoreRadioWidgetsState();
99 QList
<QByteArray
> saveRadioWidgetsState();
106 Ui::SimulatorWidget
* ui
;
107 SimulatorInterface
* simulator
;
109 GeneralSettings radioSettings
;
113 QVector
<keymapHelp_t
> keymapHelp
;
115 SimulatedUIWidget
* radioUiWidget
;
116 VirtualJoystickWidget
* vJoyLeft
;
117 VirtualJoystickWidget
* vJoyRight
;
119 QVector
<RadioSwitchWidget
*> switches
;
120 QVector
<RadioWidget
*> analogs
;
123 QString radioDataPath
;
124 QByteArray startupData
;
131 bool startupFromFile
;
132 bool deleteTempRadioData
;
133 bool saveTempRadioData
;
134 bool middleButtonPressed
;
144 //virtual void showEvent(QShowEvent *);
145 //virtual void closeEvent(QCloseEvent *);
146 virtual void mousePressEvent(QMouseEvent
*event
);
147 virtual void mouseReleaseEvent(QMouseEvent
*event
);
148 virtual void wheelEvent(QWheelEvent
*event
);
151 void onTrimPressed(int which
);
152 void onTrimReleased();
153 void onTrimSliderMoved(int which
, int value
);
155 void onjoystickAxisValueChanged(int axis
, int value
);
159 #endif // _SIMULATORWIDGET_H_