dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
inputpage.cpp
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 #include "inputpage.h"
31 #include "ui_inputpage.h"
32 #include "setupwizard.h"
35 
36 InputPage::InputPage(SetupWizard *wizard, QWidget *parent)
37  : AbstractWizardPage(wizard, parent)
38  ,
39 
40  ui(new Ui::InputPage)
41 {
42  ui->setupUi(this);
43 
44  // disable invalid input types
46  if (board) {
47  ui->pwmButton->setEnabled(
49  ui->ppmButton->setEnabled(
51  ui->hottSumDButton->setEnabled(
53  ui->hottSumHButton->setEnabled(
55  ui->sbusButton->setEnabled(
57  ui->sbusNonInvertedButton->setEnabled(
59  ui->spectrumButton->setEnabled(
61  ui->ibusButton->setEnabled(
63  ui->srxlButton->setEnabled(
65  ui->tbsCrossfireButton->setEnabled(
67  }
68  // the default might have been disabled, choose one that's available
69  foreach (QToolButton *button, findChildren<QToolButton *>()) {
70  if (button->isEnabled()) {
71  button->setChecked(true);
72  break;
73  }
74  }
75 }
76 
78 {
79  delete ui;
80 }
81 
83 {
84  if (ui->pwmButton->isChecked()) {
86  } else if (ui->ppmButton->isChecked()) {
88  } else if (ui->sbusButton->isChecked()) {
90  } else if (ui->sbusNonInvertedButton->isChecked()) {
92  } else if (ui->spectrumButton->isChecked()) {
94  } else if (ui->hottSumDButton->isChecked()) {
96  } else if (ui->hottSumHButton->isChecked()) {
98  } else if (ui->ibusButton->isChecked()) {
100  } else if (ui->srxlButton->isChecked()) {
102  } else if (ui->tbsCrossfireButton->isChecked()) {
104  } else {
106  }
107  getWizard()->setRestartNeeded(getWizard()->isRestartNeeded()
108  || restartNeeded(getWizard()->getInputType()));
109 
110  return true;
111 }
112 
119 bool InputPage::restartNeeded(Core::IBoardType::InputType selectedType)
120 {
122  Q_ASSERT(board);
123  if (!board)
124  return true;
125 
126  // Map from the enums used in SetupWizard to IBoardType
127  Core::IBoardType::InputType boardInputType = board->getInputType();
128  return (selectedType != boardInputType);
129 }
The SetupWizard class is the main interface to the setup wizard. It provides selects the sequence of ...
Definition: setupwizard.h:47
InputType
Types of input to configure for the default port.
Definition: iboardtype.h:158
void setInputType(Core::IBoardType::InputType type)
Definition: setupwizard.h:64
SetupWizard * getWizard() const
void setRestartNeeded(bool needed)
Definition: setupwizard.h:91
virtual InputType getInputType()
getInputType get the current input type
Definition: iboardtype.h:203
Core::IBoardType * getControllerType() const
Definition: setupwizard.h:56
virtual bool isInputConfigurationSupported(InputType type=INPUT_TYPE_ANY)
Determine if this board supports configuring the receiver.
Definition: iboardtype.h:186
InputPage(SetupWizard *wizard, QWidget *parent=nullptr)
Definition: inputpage.cpp:36
bool validatePage()
Definition: inputpage.cpp:82
Core::IBoardType * getControllerType() const
ControllerPage::getControllerType get the interface for the connected board.