Validate RSSI instance to allow user defined RSSI source (issue #5842) (#5846)
[opentx.git] / companion / src / simulation / simulateduiwidget.h
blob11ed5b39b442c77be34861b940159226c0e80536
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 SIMULATEDUIWIDGET_H
22 #define SIMULATEDUIWIDGET_H
24 #include "boards.h"
25 #include "constants.h"
26 #include "radiowidget.h"
27 #include "simulator.h"
28 #include "simulator_strings.h"
30 #include <QWidget>
31 #include <QMouseEvent>
33 class SimulatorInterface;
34 class LcdWidget;
35 class RadioKeyWidget;
36 class RadioUiAction;
39 * This is a base class for the main hardware-specific radio user interface, including LCD screen and navigation buttons/widgets.
40 * It is responsible for hanlding all interactions with this part of the simulation (vs. common radio widgets like sticks/switches/knobs).
41 * Sub-classes are responsible for building the actual UI form they need for presentation.
42 * This base class should not be instantiated directly.
44 class SimulatedUIWidget : public QWidget
46 Q_OBJECT
48 protected:
50 explicit SimulatedUIWidget(SimulatorInterface * simulator, QWidget * parent = NULL);
52 public:
54 ~SimulatedUIWidget();
56 RadioWidget * addRadioWidget(RadioWidget * keyWidget);
57 RadioUiAction * addRadioAction(RadioUiAction * act);
59 QVector<Simulator::keymapHelp_t> getKeymapHelp() const;
61 static QPolygon polyArc(int ctrX, int ctrY, int radius, int startAngle = 0, int endAngle = 360, int step = 10);
63 public slots:
65 void captureScreenshot();
67 void wheelEvent(QWheelEvent *event);
68 void mousePressEvent(QMouseEvent *event);
69 void mouseReleaseEvent(QMouseEvent *event);
71 signals:
73 void controlValueChange(RadioWidget::RadioWidgetType type, int index, int value);
74 void customStyleRequest(const QString & style);
75 void simulatorWheelEvent(qint8 steps);
77 protected slots:
79 void setLcd(LcdWidget * lcd);
80 void connectScrollActions();
81 void onLcdChange(bool backlightEnable);
82 virtual void setLightOn(bool enable) { }
84 protected:
86 SimulatorInterface * m_simulator;
87 QWidget * m_parent;
88 LcdWidget * m_lcd;
89 QVector<QColor> m_backlightColors;
90 QList<RadioUiAction *> m_actions;
91 QList<RadioWidget *> m_widgets;
92 RadioUiAction * m_scrollUpAction;
93 RadioUiAction * m_scrollDnAction;
94 RadioUiAction * m_mouseMidClickAction;
95 RadioUiAction * m_screenshotAction;
96 Board::Type m_board;
97 unsigned int m_backLight;
98 int m_beepShow;
99 int m_beepVal;
104 // Each subclass is responsible for its own Ui
105 namespace Ui {
106 class SimulatedUIWidget9X;
107 class SimulatedUIWidgetX7;
108 class SimulatedUIWidgetX9;
109 class SimulatedUIWidgetX9E;
110 class SimulatedUIWidgetX10;
111 class SimulatedUIWidgetX12;
114 class SimulatedUIWidget9X: public SimulatedUIWidget
116 Q_OBJECT
118 public:
119 explicit SimulatedUIWidget9X(SimulatorInterface * simulator, QWidget * parent = NULL);
120 virtual ~SimulatedUIWidget9X();
122 protected:
123 void setLightOn(bool enable);
125 private:
126 Ui::SimulatedUIWidget9X * ui;
130 class SimulatedUIWidgetX7: public SimulatedUIWidget
132 Q_OBJECT
134 public:
135 explicit SimulatedUIWidgetX7(SimulatorInterface * simulator, QWidget * parent = NULL);
136 virtual ~SimulatedUIWidgetX7();
138 private:
139 Ui::SimulatedUIWidgetX7 * ui;
142 class SimulatedUIWidgetX9: public SimulatedUIWidget
144 Q_OBJECT
146 public:
147 explicit SimulatedUIWidgetX9(SimulatorInterface * simulator, QWidget * parent = NULL);
148 virtual ~SimulatedUIWidgetX9();
150 private:
151 Ui::SimulatedUIWidgetX9 * ui;
154 class SimulatedUIWidgetX9E: public SimulatedUIWidget
156 Q_OBJECT
158 public:
159 explicit SimulatedUIWidgetX9E(SimulatorInterface * simulator, QWidget * parent = NULL);
160 virtual ~SimulatedUIWidgetX9E();
162 private:
163 Ui::SimulatedUIWidgetX9E * ui;
166 class SimulatedUIWidgetX10: public SimulatedUIWidget
168 Q_OBJECT
170 public:
171 explicit SimulatedUIWidgetX10(SimulatorInterface * simulator, QWidget * parent = NULL);
172 virtual ~SimulatedUIWidgetX10();
174 private:
175 Ui::SimulatedUIWidgetX10 * ui;
178 class SimulatedUIWidgetX12: public SimulatedUIWidget
180 Q_OBJECT
182 public:
183 explicit SimulatedUIWidgetX12(SimulatorInterface * simulator, QWidget * parent = NULL);
184 virtual ~SimulatedUIWidgetX12();
186 private:
187 Ui::SimulatedUIWidgetX12 * ui;
190 #endif // SIMULATEDUIWIDGET_H