1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-235 Adding GUI for failsafe configuration.

TODO: Fix text in Failsafe tab to have information about how failsafe works and is intended to be configured.
This commit is contained in:
Fredrik Arvidsson 2016-02-24 00:16:03 +01:00
parent 85050f63ff
commit 98d416c493
9 changed files with 689 additions and 36 deletions

View File

@ -58,7 +58,8 @@ HEADERS += \
calibration/gyrobiascalibrationmodel.h \
calibration/calibrationuiutils.h \
configoplinkwidget.h \
configrevonanohwwidget.h
configrevonanohwwidget.h \
failsafechannelform.h
SOURCES += \
configplugin.cpp \
@ -99,7 +100,8 @@ SOURCES += \
calibration/levelcalibrationmodel.cpp \
calibration/gyrobiascalibrationmodel.cpp \
configoplinkwidget.cpp \
configrevonanohwwidget.cpp
configrevonanohwwidget.cpp \
failsafechannelform.cpp
FORMS += \
airframe.ui \
@ -124,6 +126,7 @@ FORMS += \
mixercurve.ui \
configrevohwwidget.ui \
oplink.ui \
configrevonanohwwidget.ui
configrevonanohwwidget.ui \
failsafechannelform.ui
RESOURCES += configgadget.qrc

View File

@ -42,6 +42,10 @@
#include <QMessageBox>
#include <utils/stylehelper.h>
#include <QMessageBox>
#include "inputchannelform.h"
#include "ui_inputchannelform.h"
#include "failsafechannelform.h"
#include "ui_failsafechannelform.h"
#define ACCESS_MIN_MOVE -3
#define ACCESS_MAX_MOVE 3
@ -101,37 +105,39 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
addApplySaveButtons(ui->saveRCInputToRAM, ui->saveRCInputToSD);
// Generate the rows of buttons in the input channel form GUI
unsigned int index = 0;
unsigned int indexRT = 0;
quint32 index = 0;
quint32 indexRT = 0;
foreach(QString name, manualSettingsObj->getField("ChannelNumber")->getElementNames()) {
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
InputChannelForm *form = new InputChannelForm(index, this);
form->setName(name);
form->moveTo(*(ui->channelLayout));
// Input channel setup
InputChannelForm *inputChannelForm = new InputChannelForm(index, this);
inputChannelForm->setName(name);
inputChannelForm->moveTo(*(ui->channelLayout));
// The order of the following binding calls is important. Since the values will be populated
// in reverse order of the binding order otherwise the 'Reversed' logic will floor the neutral value
// to the max value ( which is smaller than the neutral value when reversed ) and the channel number
// will not be set correctly.
addWidgetBinding("ManualControlSettings", "ChannelNumber", form->ui->channelNumber, index);
addWidgetBinding("ManualControlSettings", "ChannelGroups", form->ui->channelGroup, index);
addWidgetBinding("ManualControlSettings", "ChannelNumber", inputChannelForm->ui->channelNumber, index);
addWidgetBinding("ManualControlSettings", "ChannelGroups", inputChannelForm->ui->channelGroup, index);
// Slider position based on real time Rcinput (allow monitoring)
addWidgetBinding("ManualControlCommand", "Channel", form->ui->channelNeutral, index);
addWidgetBinding("ManualControlCommand", "Channel", inputChannelForm->ui->channelNeutral, index);
// Neutral value stored on board (SpinBox)
addWidgetBinding("ManualControlSettings", "ChannelNeutral", form->ui->neutralValue, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", form->ui->channelMax, index);
addWidgetBinding("ManualControlSettings", "ChannelMin", form->ui->channelMin, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", form->ui->channelMax, index);
addWidgetBinding("ManualControlSettings", "ChannelNeutral", inputChannelForm->ui->neutralValue, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", inputChannelForm->ui->channelMax, index);
addWidgetBinding("ManualControlSettings", "ChannelMin", inputChannelForm->ui->channelMin, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", inputChannelForm->ui->channelMax, index);
addWidget(form->ui->channelRev);
addWidget(inputChannelForm->ui->channelRev);
// Reversing supported for some channels only
bool reversable = ((index == ManualControlSettings::CHANNELGROUPS_THROTTLE) ||
(index == ManualControlSettings::CHANNELGROUPS_ROLL) ||
(index == ManualControlSettings::CHANNELGROUPS_PITCH) ||
(index == ManualControlSettings::CHANNELGROUPS_YAW));
form->ui->channelRev->setVisible(reversable);
inputChannelForm->ui->channelRev->setVisible(reversable);
// Input filter response time fields supported for some channels only
switch (index) {
@ -143,21 +149,30 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
case ManualControlSettings::CHANNELGROUPS_ACCESSORY1:
case ManualControlSettings::CHANNELGROUPS_ACCESSORY2:
case ManualControlSettings::CHANNELGROUPS_ACCESSORY3:
addWidgetBinding("ManualControlSettings", "ResponseTime", form->ui->channelResponseTime, indexRT);
addWidgetBinding("ManualControlSettings", "ResponseTime", inputChannelForm->ui->channelResponseTime, indexRT);
++indexRT;
break;
case ManualControlSettings::CHANNELGROUPS_THROTTLE:
case ManualControlSettings::CHANNELGROUPS_FLIGHTMODE:
form->ui->channelResponseTime->setVisible(false);
inputChannelForm->ui->channelResponseTime->setVisible(false);
break;
default:
Q_ASSERT(0);
break;
}
// Failsafe channels setup
FailsafeChannelForm *failsafeChannelForm = new FailsafeChannelForm(index, this);
addWidget(failsafeChannelForm->ui->channelValueSpinner);
failsafeChannelForm->setName(name);
failsafeChannelForm->moveTo(*(ui->failsafeChannelsLayout));
addWidgetBinding("ManualControlSettings", "FailsafeChannel", failsafeChannelForm->ui->channelValue, index, 0.01);
++index;
}
addWidgetBinding("ManualControlSettings", "FailsafeFlightModeSwitchPosition", ui->failsafeFlightMode, 0, 1, true);
addWidgetBinding("ManualControlSettings", "Deadband", ui->deadband, 0, 1);
addWidgetBinding("ManualControlSettings", "DeadbandAssistedControl", ui->assistedControlDeadband, 0, 1);
@ -208,6 +223,9 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
connect(ManualControlCommand::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(moveFMSlider()));
connect(ManualControlSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updatePositionSlider()));
connect(ui->failsafeFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(failsafeFlightModeChanged(int)));
connect(ui->failsafeFlightModeCb, SIGNAL(toggled(bool)), this, SLOT(failsafeFlightModeCbToggled(bool)));
addWidget(ui->configurationWizard);
addWidget(ui->runCalibration);
@ -215,6 +233,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
populateWidgets();
refreshWidgetsValues();
// Connect the help button
connect(ui->inputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
@ -401,6 +420,15 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
updateEnableControls();
}
void ConfigInputWidget::buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits)
{
if (combo == ui->failsafeFlightMode) {
ConfigTaskWidget::buildOptionComboBox(combo, flightModeSettingsObj->getField("FlightModePosition"), index, applyLimits);
} else {
ConfigTaskWidget::buildOptionComboBox(combo, field, index, applyLimits);
}
}
void ConfigInputWidget::resetTxControls()
{
m_txLeftStick->setTransform(m_txLeftStickOrig, false);
@ -1998,3 +2026,14 @@ void ConfigInputWidget::forceOneFlightMode()
manualSettingsData.FlightModeNumber = 1;
manualSettingsObj->setData(manualSettingsData);
}
void ConfigInputWidget::failsafeFlightModeChanged(int index)
{
ui->failsafeFlightMode->setEnabled(index != -1);
ui->failsafeFlightModeCb->setChecked(index != -1);
}
void ConfigInputWidget::failsafeFlightModeCbToggled(bool checked)
{
ui->failsafeFlightMode->setCurrentIndex(checked ? 0 : -1);
}

View File

@ -36,8 +36,6 @@
#include "uavobject.h"
#include <QWidget>
#include <QList>
#include "inputchannelform.h"
#include "ui_inputchannelform.h"
#include <QRadioButton>
#include "manualcontrolcommand.h"
#include "manualcontrolsettings.h"
@ -229,8 +227,12 @@ private slots:
void resetActuatorSettings();
void forceOneFlightMode();
void failsafeFlightModeChanged(int index);
void failsafeFlightModeCbToggled(bool checked);
protected:
void resizeEvent(QResizeEvent *event);
void buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits);
};
#endif // ifndef CONFIGINPUTWIDGET_H

View File

@ -0,0 +1,24 @@
#include "failsafechannelform.h"
#include "ui_failsafechannelform.h"
FailsafeChannelForm::FailsafeChannelForm(const int index, QWidget *parent) :
ChannelForm(index, parent), ui(new Ui::FailsafeChannelForm)
{
ui->setupUi(this);
disableMouseWheelEvents();
}
FailsafeChannelForm::~FailsafeChannelForm()
{
delete ui;
}
QString FailsafeChannelForm::name()
{
return ui->channelName->text();
}
void FailsafeChannelForm::setName(const QString &name)
{
ui->channelName->setText(name);
}

View File

@ -0,0 +1,29 @@
#ifndef FAILSAFECHANNELFORM_H
#define FAILSAFECHANNELFORM_H
#include "channelform.h"
#include "configinputwidget.h"
#include <QWidget>
namespace Ui {
class FailsafeChannelForm;
}
class FailsafeChannelForm : public ChannelForm {
Q_OBJECT
public:
explicit FailsafeChannelForm(const int index, QWidget *parent = NULL);
~FailsafeChannelForm();
friend class ConfigInputWidget;
virtual QString name();
virtual void setName(const QString &name);
private:
Ui::FailsafeChannelForm *ui;
};
#endif // FAILSAFECHANNELFORM_H

View File

@ -0,0 +1,284 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FailsafeChannelForm</class>
<widget class="QWidget" name="FailsafeChannelForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>993</width>
<height>57</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>12</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="legend4">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Channel value</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string>Channel Value relative to channel Neutral</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="legend5">
<property name="toolTip">
<string>Channel neutral</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>Value</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="TextBubbleSlider" name="channelValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Channel input value (µs)</string>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="accessibleDescription">
<string/>
</property>
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="channelValueSpinner">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="legend0">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Channel function</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string>Function</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="channelName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Text</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TextBubbleSlider</class>
<extends>QSlider</extends>
<header>utils/textbubbleslider.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>channelValue</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>channelValue</sender>
<signal>valueChanged(int)</signal>
<receiver>channelValueSpinner</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>530</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>965</x>
<y>43</y>
</hint>
</hints>
</connection>
<connection>
<sender>channelValueSpinner</sender>
<signal>valueChanged(int)</signal>
<receiver>channelValue</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>965</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>530</x>
<y>43</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -21,7 +21,7 @@
</property>
<widget class="QWidget" name="RCInput">
<attribute name="title">
<string>RC Input</string>
<string>Remote Control Input</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_11">
<property name="spacing">
@ -2125,6 +2125,272 @@ font:bold;</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_failsafe">
<attribute name="title">
<string>Failsafe Settings</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_4">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1220</width>
<height>655</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Failsafe Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="failsafeFlightModeCb">
<property name="text">
<string>On failsafe change flight mode to:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="failsafeFlightMode">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>When triggering failsafe switch to this flight mode.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="failsafeChannelsLayout">
<property name="topMargin">
<number>10</number>
</property>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Channel input settings on failsafe:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Failsafe Information</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoNone</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;LibrePilot supports a security function to handle the situation when there is a loss of signal from the transmitter used to control the craft. This function is often called Failsafe.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The condition to trigger failsafe differs between the type of receiver used.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Bla bla bla...&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Arming Settings</string>

View File

@ -1041,26 +1041,16 @@ void ConfigTaskWidget::checkWidgetsLimits(QWidget *widget, UAVObjectField *field
}
}
void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double scale)
void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool applyLimits, double scale)
{
if (!widget || !field) {
return;
}
if (QComboBox * cb = qobject_cast<QComboBox *>(widget)) {
cb->clear();
QStringList options = field->getOptions();
for (int optionIndex = 0; optionIndex < options.count(); optionIndex++) {
if (hasLimits) {
if (m_currentBoardId > -1 && field->isWithinLimits(options.at(optionIndex), index, m_currentBoardId)) {
cb->addItem(options.at(optionIndex), QVariant(optionIndex));
}
} else {
cb->addItem(options.at(optionIndex), QVariant(optionIndex));
}
}
buildOptionComboBox(cb, field, index, applyLimits);
}
if (!hasLimits) {
if (!applyLimits) {
return;
} else if (QDoubleSpinBox * cb = qobject_cast<QDoubleSpinBox *>(widget)) {
if (field->getMaxLimit(index).isValid()) {
@ -1105,6 +1095,21 @@ void ConfigTaskWidget::updateEnableControls()
enableControls(telMngr->isConnected());
}
void ConfigTaskWidget::buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits)
{
QStringList options = field->getOptions();
for (int optionIndex = 0; optionIndex < options.count(); optionIndex++) {
if (applyLimits) {
if (m_currentBoardId > -1 && field->isWithinLimits(options.at(optionIndex), index, m_currentBoardId)) {
combo->addItem(options.at(optionIndex), QVariant(optionIndex));
}
} else {
combo->addItem(options.at(optionIndex), QVariant(optionIndex));
}
}
}
void ConfigTaskWidget::disableMouseWheelEvents()
{
// Disable mouse wheel events

View File

@ -241,7 +241,7 @@ private:
void connectWidgetUpdatesToSlot(QWidget *widget, const char *function);
void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function);
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale);
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool applyLimits, double scale);
int fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName);
@ -262,6 +262,7 @@ protected:
virtual void enableControls(bool enable);
virtual QString mapObjectName(const QString objectName);
virtual UAVObject *getObject(const QString name, quint32 instId = 0);
virtual void buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits);
void checkWidgetsLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, QVariant value, double scale);
void updateEnableControls();
};