From f4a1b73af953df33f440fdfc022ecf8a5b4029dc Mon Sep 17 00:00:00 2001 From: oberion Date: Thu, 28 Jul 2011 09:33:04 +0200 Subject: [PATCH] Xbee window fixes --- src/ui/CommConfigurationWindow.cc | 29 +++++++++++++++++++++++++---- src/ui/MainWindow.cc | 4 ++++ src/ui/MainWindow.h | 4 ++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/ui/CommConfigurationWindow.cc b/src/ui/CommConfigurationWindow.cc index a000658df..9cb2370f9 100644 --- a/src/ui/CommConfigurationWindow.cc +++ b/src/ui/CommConfigurationWindow.cc @@ -210,21 +210,32 @@ QAction* CommConfigurationWindow::getAction() void CommConfigurationWindow::setLinkType(int linktype) { #ifdef XBEELINK - // close old configuration window - this->window()->close(); + if(link->isConnected()) + { + // close old configuration window + this->window()->close(); + } + else + { + // delete old configuration window + this->remove(); + } + LinkInterface *tmpLink(NULL); switch(linktype) { case 4: { XbeeLink *xbee = new XbeeLink(); - MainWindow::instance()->addLink(xbee); + tmpLink = xbee; + MainWindow::instance()->addLink(tmpLink); break; } case 0: { SerialLink *serial = new SerialLink(); - MainWindow::instance()->addLink(serial); + tmpLink = serial; + MainWindow::instance()->addLink(tmpLink); break; } default: @@ -233,6 +244,16 @@ void CommConfigurationWindow::setLinkType(int linktype) break; } } + // trigger new window + QList actions = MainWindow::instance()->listLinkMenuActions(); + foreach (QAction* act, actions) + { + if (act->data().toInt() == LinkManager::instance()->getLinks().indexOf(tmpLink)) + { + act->trigger(); + break; + } + } #endif // XBEELINK } diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 1f39e4a27..882a23fca 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -2002,3 +2002,7 @@ void MainWindow::loadDataView(QString fileName) } +QList MainWindow::listLinkMenuActions(void) +{ + return ui.menuNetwork->actions(); +} \ No newline at end of file diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 6b21e2f43..94098066b 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -35,6 +35,7 @@ This file is part of the QGROUNDCONTROL project #include #include #include +#include #include "ui_MainWindow.h" #include "LinkManager.h" @@ -215,6 +216,9 @@ public slots: /** @brief Updates a QDockWidget's location */ void updateLocationSettings (Qt::DockWidgetArea location); +public: + QList listLinkMenuActions(void); + protected: MainWindow(QWidget *parent = 0); -- 2.22.0