29 #include "ui_gcscontrolgadgetoptionspage.h"
32 #include <QFileDialog>
33 #include <QtAlgorithms>
34 #include <QStringList>
38 : IOptionsPage(parent)
44 sdlGamepad =
dynamic_cast<GCSControl *
>(parent)->sdlGamepad;
62 rbList << options_page->buttonInput0 << options_page->buttonInput1
63 << options_page->buttonInput2 << options_page->buttonInput3
64 << options_page->buttonInput4 << options_page->buttonInput5
65 << options_page->buttonInput6 << options_page->buttonInput7;
69 rbList.at(number)->setChecked(pressed);
78 pbList << options_page->joyCh0 << options_page->joyCh1 << options_page->joyCh2
79 << options_page->joyCh3 << options_page->joyCh4 << options_page->joyCh5
80 << options_page->joyCh6 << options_page->joyCh7;
82 foreach (qint16 value, values) {
85 if (chRevList.at(i)->isChecked() == 1)
86 value = 65535 - value;
87 if (pbList.at(i)->minimum() > value)
88 pbList.at(i)->setMinimum(value);
89 if (pbList.at(i)->maximum() < value)
90 pbList.at(i)->setMaximum(value);
91 pbList.at(i++)->setValue(value);
103 options_page =
new Ui::GCSControlGadgetOptionsPage();
104 QWidget *optionsPageWidget =
new QWidget;
105 options_page->setupUi(optionsPageWidget);
111 chList << options_page->channel0 << options_page->channel1 << options_page->channel2
112 << options_page->channel3 << options_page->channel4 << options_page->channel5
113 << options_page->channel6 << options_page->channel7;
114 QStringList chOptions;
120 foreach (QComboBox *qb, chList) {
121 qb->addItems(chOptions);
125 chRevList << options_page->revCheckBox_1 << options_page->revCheckBox_2
126 << options_page->revCheckBox_3 << options_page->revCheckBox_4
127 << options_page->revCheckBox_5 << options_page->revCheckBox_6
128 << options_page->revCheckBox_7 << options_page->revCheckBox_8;
131 buttonFunctionList.clear();
132 buttonFunctionList << options_page->buttonFunction0 << options_page->buttonFunction1
133 << options_page->buttonFunction2 << options_page->buttonFunction3
134 << options_page->buttonFunction4 << options_page->buttonFunction5
135 << options_page->buttonFunction6 << options_page->buttonFunction7;
136 QStringList buttonOptions;
144 foreach (QComboBox *qb, buttonFunctionList) {
145 qb->addItems(buttonOptions);
148 buttonActionList.clear();
149 buttonActionList << options_page->buttonAction0 << options_page->buttonAction1
150 << options_page->buttonAction2 << options_page->buttonAction3
151 << options_page->buttonAction4 << options_page->buttonAction5
152 << options_page->buttonAction6 << options_page->buttonAction7;
153 QStringList buttonActionOptions;
154 buttonActionOptions <<
"Does nothing"
158 foreach (QComboBox *qb, buttonActionList) {
159 qb->addItems(buttonActionOptions);
162 buttonValueList.clear();
163 buttonValueList << options_page->buttonAmount0 << options_page->buttonAmount1
164 << options_page->buttonAmount2 << options_page->buttonAmount3
165 << options_page->buttonAmount4 << options_page->buttonAmount5
166 << options_page->buttonAmount6 << options_page->buttonAmount7;
168 buttonLabelList.clear();
169 buttonLabelList << options_page->buttonLabel0 << options_page->buttonLabel1
170 << options_page->buttonLabel2 << options_page->buttonLabel3
171 << options_page->buttonLabel4 << options_page->buttonLabel5
172 << options_page->buttonLabel6 << options_page->buttonLabel7;
174 for (i = 0; i < 8; i++) {
179 connect(buttonFunctionList.at(i), SIGNAL(currentIndexChanged(
int)),
this,
185 connect(buttonActionList.at(0), SIGNAL(currentIndexChanged(
int)),
this,
187 connect(buttonActionList.at(1), SIGNAL(currentIndexChanged(
int)),
this,
189 connect(buttonActionList.at(2), SIGNAL(currentIndexChanged(
int)),
this,
191 connect(buttonActionList.at(3), SIGNAL(currentIndexChanged(
int)),
this,
193 connect(buttonActionList.at(4), SIGNAL(currentIndexChanged(
int)),
this,
195 connect(buttonActionList.at(5), SIGNAL(currentIndexChanged(
int)),
this,
197 connect(buttonActionList.at(6), SIGNAL(currentIndexChanged(
int)),
this,
199 connect(buttonActionList.at(7), SIGNAL(currentIndexChanged(
int)),
this,
204 options_page->controlsMode->setCurrentIndex(m_config->
getControlsMode() - 1);
206 qDebug() <<
"GCSControl: Invalid control modes setting! Did you edit by hand?";
209 for (
int i = 0; i < 4; i++) {
211 chList.at(ql.at(i))->setCurrentIndex(i + 1);
214 for (i = 0; i < 8; i++) {
215 chRevList.at(i)->setChecked(qlChRev.at(i));
221 connect(sdlGamepad, SIGNAL(
buttonState(ButtonNumber,
bool)),
this,
223 connect(sdlGamepad, SIGNAL(
gamepads(quint8)),
this, SLOT(
gamepads(quint8)));
226 return optionsPageWidget;
237 m_config->
setControlsMode(options_page->controlsMode->currentIndex() + 1);
239 int roll = -1, pitch = -1, yaw = -1, throttle = -1;
240 for (
int i = 0;
i < chList.length();
i++) {
241 switch (chList.at(
i)->currentIndex()) {
260 for (
unsigned int j = 0; j < 8; j++) {
271 disconnect(sdlGamepad, 0,
this, 0);
279 for (
unsigned int i = 0;
i < 8;
i++) {
280 if (buttonActionList.at(
i)->currentText().compare(
"Does nothing") == 0) {
281 buttonFunctionList.at(
i)->setVisible(0);
282 buttonLabelList.at(
i)->setVisible(0);
283 buttonValueList.at(
i)->setVisible(0);
284 }
else if (buttonActionList.at(
i)->currentText().compare(
"Toggles") == 0) {
285 buttonFunctionList.at(
i)->setVisible(1);
286 buttonLabelList.at(
i)->setVisible(0);
287 buttonValueList.at(
i)->setVisible(0);
289 buttonFunctionList.at(
i)->setVisible(1);
290 buttonLabelList.at(
i)->setVisible(1);
291 buttonValueList.at(
i)->setVisible(1);
298 QStringList buttonOptions;
301 if (buttonActionList.at(controlID)->currentText().compare(
"Does nothing") == 0) {
302 buttonFunctionList.at(controlID)->setVisible(0);
303 buttonLabelList.at(controlID)->setVisible(0);
304 buttonValueList.at(controlID)->setVisible(0);
305 }
else if (buttonActionList.at(controlID)->currentText().compare(
"Toggles") == 0) {
306 disconnect(buttonFunctionList.at(controlID), SIGNAL(currentIndexChanged(
int)),
this,
311 buttonFunctionList.at(controlID)->clear();
312 buttonFunctionList.at(controlID)->insertItems(-1, buttonOptions);
314 buttonFunctionList.at(controlID)->setVisible(1);
315 buttonLabelList.at(controlID)->setVisible(0);
316 buttonValueList.at(controlID)->setVisible(0);
317 connect(buttonFunctionList.at(controlID), SIGNAL(currentIndexChanged(
int)),
this,
320 disconnect(buttonFunctionList.at(controlID), SIGNAL(currentIndexChanged(
int)),
this,
327 buttonFunctionList.at(controlID)->clear();
328 buttonFunctionList.at(controlID)->addItems(buttonOptions);
330 buttonFunctionList.at(controlID)->setVisible(1);
331 buttonLabelList.at(controlID)->setVisible(1);
332 buttonValueList.at(controlID)->setVisible(1);
333 connect(buttonFunctionList.at(controlID), SIGNAL(currentIndexChanged(
int)),
this,
buttonSettingsStruct getbuttonSettings(int i)
void setChannelReverse(int i, bool Reverse)
void updateButtonFunction()
void setbuttonSettingsFunction(int i, int FunctionID)
void buttonState(ButtonNumber number, bool pressed)
void updateButtonAction_2(void)
void setbuttonSettingsAction(int i, int ActionID)
void updateButtonAction(int controlID)
void setControlsMode(int mode)
void updateButtonAction_7(void)
void updateButtonAction_0(void)
void axesValues(QListInt16 values)
GCSControlGadgetOptionsPage(GCSControlGadgetConfiguration *config, QObject *parent=nullptr)
void updateButtonAction_6(void)
QWidget * createPage(QWidget *parent)
void updateButtonAction_4(void)
void gamepads(quint8 count)
void setbuttonSettingsAmount(int i, double Amount)
void setRPYTchannels(int roll, int pitch, int yaw, int throttle)
void updateButtonAction_5(void)
QList< bool > getChannelsReverse()
void updateButtonAction_1(void)
bool getGcsReceiverMode()
QList< int > getChannelsMapping()
~GCSControlGadgetOptionsPage()
void setGcsReceiverMode(bool enable)
void updateButtonAction_3(void)