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 ...@@ -66,7 +66,6 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
// Do not allow changes here unless advanced is checked // Do not allow changes here unless advanced is checked
ui.connectionType->setEnabled(false); ui.connectionType->setEnabled(false);
ui.linkType->setEnabled(false);
ui.protocolGroupBox->setVisible(false); ui.protocolGroupBox->setVisible(false);
ui.protocolTypeGroupBox->setVisible(false); ui.protocolTypeGroupBox->setVisible(false);
...@@ -78,14 +77,19 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn ...@@ -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.advancedOptionsCheckBox,SLOT(setChecked(bool)));
connect(ui.advCheckBox,SIGNAL(clicked(bool)),ui.protocolTypeGroupBox,SLOT(setVisible(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.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))); connect(ui.advCheckBox, SIGNAL(clicked(bool)), ui.protocolGroupBox, SLOT(setVisible(bool)));
// add link types // add link types
ui.linkType->addItem(tr("Serial"), QGC_LINK_SERIAL); ui.linkType->addItem(tr("Serial"), QGC_LINK_SERIAL);
ui.linkType->addItem(tr("UDP"), QGC_LINK_UDP); 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); ui.linkType->addItem(tr("Opal-RT Link"), QGC_LINK_OPAL);
#endif
#ifdef XBEELINK #ifdef XBEELINK
ui.linkType->addItem(tr("Xbee API"),QGC_LINK_XBEE); ui.linkType->addItem(tr("Xbee API"),QGC_LINK_XBEE);
#endif // XBEELINK #endif // XBEELINK
...@@ -135,18 +139,19 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn ...@@ -135,18 +139,19 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
QWidget* conf = new SerialConfigurationWindow(serial, this); QWidget* conf = new SerialConfigurationWindow(serial, this);
ui.linkScrollArea->setWidget(conf); ui.linkScrollArea->setWidget(conf);
ui.linkGroupBox->setTitle(tr("Serial Link")); 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); UDPLink* udp = dynamic_cast<UDPLink*>(link);
if (udp != 0) { if (udp != 0) {
QWidget* conf = new QGCUDPLinkConfiguration(udp, this); QWidget* conf = new QGCUDPLinkConfiguration(udp, this);
ui.linkScrollArea->setWidget(conf); ui.linkScrollArea->setWidget(conf);
ui.linkGroupBox->setTitle(tr("UDP Link")); 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); MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
if (sim != 0) { 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")); ui.linkGroupBox->setTitle(tr("MAVLink Simulation Link"));
} }
#ifdef OPAL_RT #ifdef OPAL_RT
...@@ -156,7 +161,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn ...@@ -156,7 +161,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, ui.linkGroupBox); QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, ui.linkGroupBox);
layout->addWidget(conf); layout->addWidget(conf);
ui.linkGroupBox->setLayout(layout); ui.linkGroupBox->setLayout(layout);
ui.linkType->setCurrentIndex(3); ui.linkType->setCurrentIndex(ui.linkType->findData(QGC_LINK_OPAL));
ui.linkGroupBox->setTitle(tr("Opal-RT Link")); ui.linkGroupBox->setTitle(tr("Opal-RT Link"));
} }
#endif #endif
...@@ -167,7 +172,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn ...@@ -167,7 +172,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
QWidget* conf = new XbeeConfigurationWindow(xbee,this); QWidget* conf = new XbeeConfigurationWindow(xbee,this);
ui.linkScrollArea->setWidget(conf); ui.linkScrollArea->setWidget(conf);
ui.linkGroupBox->setTitle(tr("Xbee Link")); 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(tryConnectBegin(bool)),ui.actionConnect,SLOT(setDisabled(bool)));
connect(xbee,SIGNAL(tryConnectEnd(bool)),ui.actionConnect,SLOT(setEnabled(bool))); connect(xbee,SIGNAL(tryConnectEnd(bool)),ui.actionConnect,SLOT(setEnabled(bool)));
} }
...@@ -183,7 +188,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn ...@@ -183,7 +188,7 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn
qDebug() << "Link is NOT a known link, can't open configuration window"; 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 // Open details pane for MAVLink if necessary
MAVLinkProtocol* mavlink = dynamic_cast<MAVLinkProtocol*>(protocol); MAVLinkProtocol* mavlink = dynamic_cast<MAVLinkProtocol*>(protocol);
...@@ -213,7 +218,12 @@ QAction* CommConfigurationWindow::getAction() ...@@ -213,7 +218,12 @@ QAction* CommConfigurationWindow::getAction()
return action; 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()) if(link->isConnected())
{ {
...@@ -230,7 +240,7 @@ void CommConfigurationWindow::setLinkType(int linktype) ...@@ -230,7 +240,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
switch(linktype) switch(linktype)
{ {
#ifdef XBEELINK #ifdef XBEELINK
case 4: case QGC_LINK_XBEE:
{ {
XbeeLink *xbee = new XbeeLink(); XbeeLink *xbee = new XbeeLink();
tmpLink = xbee; tmpLink = xbee;
...@@ -238,7 +248,7 @@ void CommConfigurationWindow::setLinkType(int linktype) ...@@ -238,7 +248,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
break; break;
} }
#endif // XBEELINK #endif // XBEELINK
case 1: case QGC_LINK_UDP:
{ {
UDPLink *udp = new UDPLink(); UDPLink *udp = new UDPLink();
tmpLink = udp; tmpLink = udp;
...@@ -247,7 +257,7 @@ void CommConfigurationWindow::setLinkType(int linktype) ...@@ -247,7 +257,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
} }
#ifdef OPAL_RT #ifdef OPAL_RT
case 3: case QGC_LINK_OPAL:
{ {
OpalLink* opal = new OpalLink(); OpalLink* opal = new OpalLink();
tmpLink = opal; tmpLink = opal;
...@@ -258,7 +268,7 @@ void CommConfigurationWindow::setLinkType(int linktype) ...@@ -258,7 +268,7 @@ void CommConfigurationWindow::setLinkType(int linktype)
default: default:
{ {
} }
case 0: case QGC_LINK_SERIAL:
{ {
SerialLink *serial = new SerialLink(); SerialLink *serial = new SerialLink();
tmpLink = serial; tmpLink = serial;
......
...@@ -47,7 +47,9 @@ enum qgc_link_t { ...@@ -47,7 +47,9 @@ enum qgc_link_t {
#ifdef XBEELINK #ifdef XBEELINK
QGC_LINK_XBEE, QGC_LINK_XBEE,
#endif #endif
#ifdef OPAL_RT
QGC_LINK_OPAL QGC_LINK_OPAL
#endif
}; };
enum qgc_protocol_t { enum qgc_protocol_t {
...@@ -71,9 +73,12 @@ public: ...@@ -71,9 +73,12 @@ public:
~CommConfigurationWindow(); ~CommConfigurationWindow();
QAction* getAction(); QAction* getAction();
void setLinkType(qgc_link_t linktype);
private slots:
void linkCurrentIndexChanged(int currentIndex);
public slots: public slots:
void setLinkType(int linktype);
/** @brief Set the protocol for this link */ /** @brief Set the protocol for this link */
void setProtocol(int protocol); void setProtocol(int protocol);
void setConnection(); void setConnection();
......
...@@ -14,6 +14,23 @@ ...@@ -14,6 +14,23 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <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> <item>
<widget class="QGroupBox" name="linkGroupBox"> <widget class="QGroupBox" name="linkGroupBox">
<property name="title"> <property name="title">
...@@ -23,7 +40,16 @@ ...@@ -23,7 +40,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </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> <number>0</number>
</property> </property>
<item> <item>
...@@ -36,8 +62,8 @@ ...@@ -36,8 +62,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>292</width> <width>298</width>
<height>81</height> <height>90</height>
</rect> </rect>
</property> </property>
</widget> </widget>
...@@ -49,7 +75,7 @@ ...@@ -49,7 +75,7 @@
<item> <item>
<widget class="QCheckBox" name="advCheckBox"> <widget class="QCheckBox" name="advCheckBox">
<property name="text"> <property name="text">
<string>Show Advanced Protocol Options</string> <string>&amp;Show Advanced Protocol Options</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -61,34 +87,27 @@ ...@@ -61,34 +87,27 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <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"> <item row="0" column="1">
<widget class="QComboBox" name="linkType"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="connectionType"> <widget class="QComboBox" name="connectionType">
<property name="currentIndex"> <property name="currentIndex">
<number>-1</number> <number>-1</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="0" column="0">
<widget class="QCheckBox" name="advancedOptionsCheckBox"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Advanced Options</string> <string>&amp;Protocol:</string>
</property>
<property name="buddy">
<cstring>connectionType</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="1">
<widget class="QLabel" name="label_5"> <widget class="QCheckBox" name="advancedOptionsCheckBox">
<property name="text"> <property name="text">
<string>Protocol</string> <string>&amp;Advanced Options</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -113,7 +132,16 @@ ...@@ -113,7 +132,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </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> <number>0</number>
</property> </property>
<item> <item>
...@@ -126,8 +154,8 @@ ...@@ -126,8 +154,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>292</width> <width>298</width>
<height>81</height> <height>90</height>
</rect> </rect>
</property> </property>
</widget> </widget>
...@@ -217,7 +245,20 @@ ...@@ -217,7 +245,20 @@
<zorder>connectionStatusLabel</zorder> <zorder>connectionStatusLabel</zorder>
<zorder>advCheckBox</zorder> <zorder>advCheckBox</zorder>
<zorder>protocolTypeGroupBox</zorder> <zorder>protocolTypeGroupBox</zorder>
<zorder>linkType</zorder>
<zorder>label</zorder>
</widget> </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/> <resources/>
<connections> <connections>
<connection> <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