mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
LP-525 Fixed USB function handling - not allowing USBTelemetry on both, but requiring at least one. Adjusted common option combobox sizes.
This commit is contained in:
parent
4bd3df43aa
commit
8b61e7b27f
@ -33,20 +33,22 @@
|
||||
#include "uavobjectmanager.h"
|
||||
|
||||
|
||||
CommonHWSettingsWidget::CommonHWSettingsWidget(QWidget *parent) : QWidget(parent)
|
||||
CommonHWSettingsWidget::CommonHWSettingsWidget(QWidget *parent) : ConfigTaskWidget(parent, Child)
|
||||
{
|
||||
m_ui = new Ui_CommonHWSettingsWidget();
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->cbDSMxBind->addItem(tr("Disabled"), 0);
|
||||
|
||||
// combo->addItem(options.at(optionIndex), QVariant(optionIndex));
|
||||
|
||||
setFeatures(0);
|
||||
|
||||
// Relay signals from private members
|
||||
connect(m_ui->cbUSBHID, SIGNAL(currentIndexChanged(int)), this, SIGNAL(USBHIDFunctionChanged(int)));
|
||||
connect(m_ui->cbUSBVCP, SIGNAL(currentIndexChanged(int)), this, SIGNAL(USBVCPFunctionChanged(int)));
|
||||
|
||||
// And these are here to handle conflicting VCP & HID options (such as USBTelemetry).
|
||||
connect(m_ui->cbUSBHID, SIGNAL(currentIndexChanged(int)), this, SLOT(USBHIDComboChanged(int)));
|
||||
connect(m_ui->cbUSBVCP, SIGNAL(currentIndexChanged(int)), this, SLOT(USBVCPComboChanged(int)));
|
||||
}
|
||||
|
||||
CommonHWSettingsWidget::~CommonHWSettingsWidget()
|
||||
@ -73,9 +75,7 @@ void CommonHWSettingsWidget::refreshWidgetsValues(UAVObject *obj)
|
||||
{
|
||||
Q_UNUSED(obj);
|
||||
|
||||
UAVObjectManager *objMngr = ExtensionSystem::PluginManager::instance()->getObject<UAVObjectManager>();
|
||||
|
||||
int option = HwSettings::GetInstance(objMngr)->getDSMxBind();
|
||||
int option = HwSettings::GetInstance(getObjectManager())->getDSMxBind();
|
||||
|
||||
if (m_ui->cbDSMxBind->count() == 0) {
|
||||
m_ui->cbDSMxBind->addItem(tr("None"), 0);
|
||||
@ -141,3 +141,31 @@ QComboBox *CommonHWSettingsWidget::USBVCPComboBox()
|
||||
{
|
||||
return m_ui->cbUSBVCP;
|
||||
}
|
||||
|
||||
bool CommonHWSettingsWidget::USBFunctionConflict()
|
||||
{
|
||||
return (getComboboxSelectedOption(m_ui->cbUSBHID) == HwSettings::USB_HIDPORT_USBTELEMETRY)
|
||||
&& (getComboboxSelectedOption(m_ui->cbUSBVCP) == HwSettings::USB_VCPPORT_USBTELEMETRY);
|
||||
}
|
||||
|
||||
void CommonHWSettingsWidget::USBHIDComboChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
|
||||
if (USBFunctionConflict()) {
|
||||
setComboboxSelectedOption(m_ui->cbUSBVCP, HwSettings::USB_VCPPORT_DISABLED);
|
||||
} else if (getComboboxSelectedOption(m_ui->cbUSBHID) != HwSettings::USB_HIDPORT_USBTELEMETRY) {
|
||||
setComboboxSelectedOption(m_ui->cbUSBVCP, HwSettings::USB_VCPPORT_USBTELEMETRY);
|
||||
}
|
||||
}
|
||||
|
||||
void CommonHWSettingsWidget::USBVCPComboChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
|
||||
if (USBFunctionConflict()) {
|
||||
setComboboxSelectedOption(m_ui->cbUSBHID, HwSettings::USB_HIDPORT_DISABLED);
|
||||
} else if (getComboboxSelectedOption(m_ui->cbUSBVCP) != HwSettings::USB_VCPPORT_USBTELEMETRY) {
|
||||
setComboboxSelectedOption(m_ui->cbUSBHID, HwSettings::USB_HIDPORT_USBTELEMETRY);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
class Ui_CommonHWSettingsWidget;
|
||||
|
||||
class CommonHWSettingsWidget : public QWidget {
|
||||
class CommonHWSettingsWidget : public ConfigTaskWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -56,8 +56,14 @@ signals:
|
||||
void USBHIDFunctionChanged(int index);
|
||||
void USBVCPFunctionChanged(int index);
|
||||
|
||||
private slots:
|
||||
void USBHIDComboChanged(int index);
|
||||
void USBVCPComboChanged(int index);
|
||||
|
||||
private:
|
||||
Ui_CommonHWSettingsWidget *m_ui;
|
||||
|
||||
bool USBFunctionConflict();
|
||||
};
|
||||
|
||||
#endif // COMMONHWSETTINGSWIDGET_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>604</width>
|
||||
<height>189</height>
|
||||
<width>746</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
@ -24,50 +24,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="6">
|
||||
<spacer name="horizontalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<spacer name="horizontalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="5">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="5">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4" rowspan="5" colspan="2">
|
||||
<item row="2" column="3" rowspan="5" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="verticalSpacing">
|
||||
<number>-1</number>
|
||||
@ -105,7 +62,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -183,6 +140,38 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1" rowspan="5" colspan="2">
|
||||
@ -282,7 +271,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -298,8 +287,70 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="5">
|
||||
<spacer name="horizontalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
Loading…
Reference in New Issue
Block a user