dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
configradiowidget.cpp
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  */
25 
26 #include "configradiowidget.h"
27 
30 
31 #include "openlrs.h"
32 
33 #include "ui_integratedradio.h"
34 
36  : ConfigTaskWidget(parent)
37 {
38  ui = new Ui::radio();
39  ui->setupUi(this);
40 
41  // Load UAVObjects to widget relations from UI file
42  // using objrelation dynamic property
44 
45  // Refresh widget contents
47 
48  // Prevent mouse wheel from changing values
50 
51  connect(ui->rb_tx, &QRadioButton::toggled, this,
52  &ConfigRadioWidget::roleChanged);
53  connect(ui->rb_rx, &QRadioButton::toggled, this,
54  &ConfigRadioWidget::roleChanged);
55  connect(ui->rb_disabled, &QRadioButton::toggled, this,
56  &ConfigRadioWidget::roleChanged);
57 }
58 
60 {
61 }
62 
63 void ConfigRadioWidget::resizeEvent(QResizeEvent *event)
64 {
65  QWidget::resizeEvent(event);
66 }
67 
69 {
70  Q_UNUSED(enable);
71 }
72 
73 void ConfigRadioWidget::roleChanged(bool ignored)
74 {
75  (void) ignored;
76 
77  if (ui->rb_tx->isChecked()) {
78  ui->groupTxSettings->setEnabled(true);
79  ui->groupRxSettings->setEnabled(false);
80  } else if (ui->rb_rx->isChecked()) {
81  ui->groupTxSettings->setEnabled(false);
82  ui->groupRxSettings->setEnabled(true);
83  } else {
84  ui->groupTxSettings->setEnabled(false);
85  ui->groupRxSettings->setEnabled(false);
86  }
87 }
88 
89 void ConfigRadioWidget::refreshWidgetsValues(UAVObject *obj)
90 {
91  (void) obj;
92 
93  OpenLRS *olrsObj = OpenLRS::GetInstance(getObjectManager());
94 
95  OpenLRS::DataFields openlrs = olrsObj->getData();
96 
97  switch (openlrs.role) {
98  case OpenLRS::ROLE_DISABLED:
99  default:
100  ui->rb_disabled->setChecked(true);
101  break;
102  case OpenLRS::ROLE_RX:
103  ui->rb_rx->setChecked(true);
104  break;
105  case OpenLRS::ROLE_TX:
106  ui->rb_tx->setChecked(true);
107  break;
108  }
109 
111 }
112 
113 void ConfigRadioWidget::updateObjectsFromWidgets()
114 {
115  OpenLRS *olrsObj = OpenLRS::GetInstance(getObjectManager());
116 
117  if (ui->rb_tx->isChecked()) {
118  olrsObj->setrole(OpenLRS::ROLE_TX);
119  } else if (ui->rb_rx->isChecked()) {
120  olrsObj->setrole(OpenLRS::ROLE_RX);
121  } else {
122  olrsObj->setrole(OpenLRS::ROLE_DISABLED);
123  }
124 
126 }
127 
void resizeEvent(QResizeEvent *event)
virtual void enableControls(bool enable)
ConfigRadioWidget(QWidget *parent=nullptr)
Configure the integrated radio.
void(NAME)
virtual void updateObjectsFromWidgets()
virtual void refreshWidgetsValues(UAVObject *obj=NULL)
UAVObjectManager * getObjectManager()
ConfigTaskWidget::getObjectManager Utility function to get a pointer to the object manager...