Commit 96ab4dc8 authored by John Tapsell's avatar John Tapsell

Comm Settings - move the "link type" combobox to the top, and clean it up

* The "Simulation" option is now not selectable.
* If the link is a simulation, then you can't change it to a different link type.
* The OPAL option is not shown if support is not compiled in.
* Fix the buddy, tab order and accelerators in the GUI.
parent 6f8802da
......@@ -66,7 +66,6 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
// Do not allow changes here unless advanced is checked
ui.connectionType->setEnabled(false);
ui.linkType->setEnabled(false);
ui.protocolGroupBox->setVisible(false);
ui.protocolTypeGroupBox->setVisible(false);
......@@ -78,14 +77,19 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
//connect(ui.advCheckBox,SIGNAL(clicked(bool)),ui.advancedOptionsCheckBox,SLOT(setChecked(bool)));
connect(ui.advCheckBox,SIGNAL(clicked(bool)),ui.protocolTypeGroupBox,SLOT(setVisible(bool)));
connect(ui.advCheckBox, SIGNAL(clicked(bool)), ui.connectionType, SLOT(setEnabled(bool)));
connect(ui.advCheckBox, SIGNAL(clicked(bool)), ui.linkType, SLOT(setEnabled(bool)));
connect(ui.advCheckBox, SIGNAL(clicked(bool)), ui.protocolGroupBox, SLOT(setVisible(bool)));
// add link types
ui.linkType->addItem(tr("Serial"), QGC_LINK_SERIAL);
ui.linkType->addItem(tr("UDP"), QGC_LINK_UDP);
ui.linkType->addItem(tr("Simulation"), QGC_LINK_SIMULATION);
if(dynamic_cast<MAVLinkSimulationLink*>(link)) {
//Only show simulation option if already setup elsewhere as a simulation
ui.linkType->addItem(tr("Simulation"), QGC_LINK_SIMULATION);
}
#ifdef OPAL_RT
ui.linkType->addItem(tr("Opal-RT Link"), QGC_LINK_OPAL);
#endif
#ifdef XBEELINK
ui.linkType->addItem(tr("Xbee API"),QGC_LINK_XBEE);
#endif // XBEELINK
......@@ -135,18 +139,19 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
QWidget* conf = new SerialConfigurationWindow(serial, this);
ui.linkScrollArea->setWidget(conf);
ui.linkGroupBox->setTitle(tr("Serial Link"));
ui.linkType->setCurrentIndex(0);
ui.linkType->setCurrentIndex(ui.linkType->findData(QGC_LINK_SERIAL));
}
UDPLink* udp = dynamic_cast<UDPLink*>(link);
if (udp != 0) {
QWidget* conf = new QGCUDPLinkConfiguration(udp, this);
ui.linkScrollArea->setWidget(conf);
ui.linkGroupBox->setTitle(tr("UDP Link"));
ui.linkType->setCurrentIndex(1);
ui.linkType->setCurrentIndex(ui.linkType->findData(QGC_LINK_UDP));
}
MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
if (sim != 0) {
ui.linkType->setCurrentIndex(2);
ui.linkType->setCurrentIndex(ui.linkType->findData(QGC_LINK_SIMULATION));
ui.linkType->setEnabled(false); //Don't allow the user to change to a non-simulation
ui.linkGroupBox->setTitle(tr("MAVLink Simulation Link"));
}
#ifdef OPAL_RT
......@@ -156,7 +161,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, ui.linkGroupBox);
layout->addWidget(conf);
ui.linkGroupBox->setLayout(layout);
ui.linkType->setCurrentIndex(3);
ui.linkType->setCurrentIndex(ui.linkType->findData(QGC_LINK_OPAL));
ui.linkGroupBox->setTitle(tr("Opal-RT Link"));
}
#endif
......@@ -167,7 +172,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
QWidget* conf = new XbeeConfigurationWindow(xbee,this);
ui.linkScrollArea->setWidget(conf);
ui.linkGroupBox->setTitle(tr("Xbee Link"));
ui.linkType->setCurrentIndex(4);
ui.linkType->setCurrentIndex(ui.linkType->findData(QGC_LINK_XBEE));
connect(xbee,SIGNAL(tryConnectBegin(bool)),ui.actionConnect,SLOT(setDisabled(bool)));
connect(xbee,SIGNAL(tryConnectEnd(bool)),ui.actionConnect,SLOT(setEnabled(bool)));
}
......@@ -183,7 +188,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
qDebug() << "Link is NOT a known link, can't open configuration window";
}
connect(ui.linkType,SIGNAL(currentIndexChanged(int)),this,SLOT(setLinkType(int)));
connect(ui.linkType,SIGNAL(currentIndexChanged(int)),this,SLOT(linkCurrentIndexChanged(int)));
// Open details pane for MAVLink if necessary
MAVLinkProtocol* mavlink = dynamic_cast<MAVLinkProtocol*>(protocol);
......@@ -213,7 +218,12 @@ QAction* CommConfigurationWindow::getAction()
return action;
}
void CommConfigurationWindow::setLinkType(int linktype)
void CommConfigurationWindow::linkCurrentIndexChanged(int currentIndex)
{
setLinkType(static_cast<qgc_link_t>(ui.linkType->itemData(currentIndex).toInt()));
}
void CommConfigurationWindow::setLinkType(qgc_link_t linktype)
{
if(link->isConnected())
{
......@@ -230,7 +240,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
switch(linktype)
{
#ifdef XBEELINK
case 4:
case QGC_LINK_XBEE:
{
XbeeLink *xbee = new XbeeLink();
tmpLink = xbee;
......@@ -238,7 +248,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
break;
}
#endif // XBEELINK
case 1:
case QGC_LINK_UDP:
{
UDPLink *udp = new UDPLink();
tmpLink = udp;
......@@ -247,7 +257,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
}
#ifdef OPAL_RT
case 3:
case QGC_LINK_OPAL:
{
OpalLink* opal = new OpalLink();
tmpLink = opal;
......@@ -258,7 +268,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
default:
{
}
case 0:
case QGC_LINK_SERIAL:
{
SerialLink *serial = new SerialLink();
tmpLink = serial;
......
......@@ -47,7 +47,9 @@ enum qgc_link_t {
#ifdef XBEELINK
QGC_LINK_XBEE,
#endif
#ifdef OPAL_RT
QGC_LINK_OPAL
#endif
};
enum qgc_protocol_t {
......@@ -71,9 +73,12 @@ public:
~CommConfigurationWindow();
QAction* getAction();
void setLinkType(qgc_link_t linktype);
private slots:
void linkCurrentIndexChanged(int currentIndex);
public slots:
void setLinkType(int linktype);
/** @brief Set the protocol for this link */
void setProtocol(int protocol);
void setConnection();
......
......@@ -14,6 +14,23 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Link &amp;Type:</string>
</property>
<property name="buddy">
<cstring>linkType</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="linkType"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="linkGroupBox">
<property name="title">
......@@ -23,7 +40,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<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>
......@@ -36,8 +62,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>292</width>
<height>81</height>
<width>298</width>
<height>90</height>
</rect>
</property>
</widget>
......@@ -49,7 +75,7 @@
<item>
<widget class="QCheckBox" name="advCheckBox">
<property name="text">
<string>Show Advanced Protocol Options</string>
<string>&amp;Show Advanced Protocol Options</string>
</property>
</widget>
</item>
......@@ -61,34 +87,27 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Link Type</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="linkType"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="connectionType">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="advancedOptionsCheckBox">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Advanced Options</string>
<string>&amp;Protocol:</string>
</property>
<property name="buddy">
<cstring>connectionType</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<item row="1" column="1">
<widget class="QCheckBox" name="advancedOptionsCheckBox">
<property name="text">
<string>Protocol</string>
<string>&amp;Advanced Options</string>
</property>
</widget>
</item>
......@@ -113,7 +132,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<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>
......@@ -126,8 +154,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>292</width>
<height>81</height>
<width>298</width>
<height>90</height>
</rect>
</property>
</widget>
......@@ -217,7 +245,20 @@
<zorder>connectionStatusLabel</zorder>
<zorder>advCheckBox</zorder>
<zorder>protocolTypeGroupBox</zorder>
<zorder>linkType</zorder>
<zorder>label</zorder>
</widget>
<tabstops>
<tabstop>linkType</tabstop>
<tabstop>linkScrollArea</tabstop>
<tabstop>advCheckBox</tabstop>
<tabstop>connectionType</tabstop>
<tabstop>advancedOptionsCheckBox</tabstop>
<tabstop>protocolScrollArea</tabstop>
<tabstop>connectButton</tabstop>
<tabstop>deleteButton</tabstop>
<tabstop>closeButton</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment