From 96ab4dc87d428348b0588037167bccf053978b43 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 9 Oct 2013 00:18:47 +0100 Subject: [PATCH] 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. --- src/ui/CommConfigurationWindow.cc | 38 +++++++++----- src/ui/CommConfigurationWindow.h | 7 ++- src/ui/CommSettings.ui | 87 +++++++++++++++++++++++-------- 3 files changed, 94 insertions(+), 38 deletions(-) diff --git a/src/ui/CommConfigurationWindow.cc b/src/ui/CommConfigurationWindow.cc index 81bb4b648..462f1c42c 100644 --- a/src/ui/CommConfigurationWindow.cc +++ b/src/ui/CommConfigurationWindow.cc @@ -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(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(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(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(protocol); @@ -213,7 +218,12 @@ QAction* CommConfigurationWindow::getAction() return action; } -void CommConfigurationWindow::setLinkType(int linktype) +void CommConfigurationWindow::linkCurrentIndexChanged(int currentIndex) +{ + setLinkType(static_cast(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; diff --git a/src/ui/CommConfigurationWindow.h b/src/ui/CommConfigurationWindow.h index 65912b03b..47e2b4c8f 100644 --- a/src/ui/CommConfigurationWindow.h +++ b/src/ui/CommConfigurationWindow.h @@ -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(); diff --git a/src/ui/CommSettings.ui b/src/ui/CommSettings.ui index 73b4d76ef..e04678c17 100644 --- a/src/ui/CommSettings.ui +++ b/src/ui/CommSettings.ui @@ -14,6 +14,23 @@ Form + + + + + + Link &Type: + + + linkType + + + + + + + + @@ -23,7 +40,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -36,8 +62,8 @@ 0 0 - 292 - 81 + 298 + 90 @@ -49,7 +75,7 @@ - Show Advanced Protocol Options + &Show Advanced Protocol Options @@ -61,34 +87,27 @@ - - - - Link Type - - - - - - -1 - - + + - Advanced Options + &Protocol: + + + connectionType - - + + - Protocol + &Advanced Options @@ -113,7 +132,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -126,8 +154,8 @@ 0 0 - 292 - 81 + 298 + 90 @@ -217,7 +245,20 @@ connectionStatusLabel advCheckBox protocolTypeGroupBox + linkType + label + + linkType + linkScrollArea + advCheckBox + connectionType + advancedOptionsCheckBox + protocolScrollArea + connectButton + deleteButton + closeButton + -- 2.22.0