diff --git a/src/Core.cc b/src/Core.cc index d63bd0d919bda5645fbcd3f87a9e27aac3a393a5..d35e3cebe08ab650789574385f7fb24cc63bf088 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -157,6 +157,9 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) **/ Core::~Core() { + mainWindow->storeSettings(); + mainWindow->hide(); + mainWindow->deleteLater(); // Delete singletons delete LinkManager::instance(); delete UASManager::instance(); diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index d4b48cdc1143beda514fabbeb9dcd5e77eb693de..d96320b0b24f887f98608ad6b7b85e65a83cd12c 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -30,9 +30,11 @@ This file is part of the QGROUNDCONTROL project #include #include +#include #include #include "SerialLink.h" #include "LinkManager.h" +#include "QGC.h" #include #ifdef _WIN32 #include "windows.h" @@ -54,12 +56,26 @@ SerialLink::SerialLink(QString portname, BaudRateType baudrate, FlowType flow, P #endif // Set unique ID and add link to the list of links this->id = getNextLinkId(); - this->baudrate = baudrate; - this->flow = flow; - this->parity = parity; - this->dataBits = dataBits; - this->stopBits = stopBits; - this->timeout = 1; ///< The timeout controls how long the program flow should wait for new serial bytes. As we're polling, we don't want to wait at all. + + // Load defaults from settings + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + if (settings.contains("SERIALLINK_COMM_PORT")) + { + this->porthandle = settings.value("SERIALLINK_COMM_PORT").toString(); + setBaudRate(settings.value("SERIALLINK_COMM_BAUD").toInt()); + setParityType(settings.value("SERIALLINK_COMM_PARITY").toInt()); + setStopBitsType(settings.value("SERIALLINK_COMM_STOPBITS").toInt()); + setDataBitsType(settings.value("SERIALLINK_COMM_DATABITS").toInt()); + } + else + { + this->baudrate = baudrate; + this->flow = flow; + this->parity = parity; + this->dataBits = dataBits; + this->stopBits = stopBits; + this->timeout = 1; ///< The timeout controls how long the program flow should wait for new serial bytes. As we're polling, we don't want to wait at all. + } // Set the port name if (porthandle == "") @@ -282,6 +298,15 @@ bool SerialLink::connect() **/ bool SerialLink::hardwareConnect() { + // Store settings + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + settings.setValue("SERIALLINK_COMM_PORT", this->porthandle); + settings.setValue("SERIALLINK_COMM_BAUD", this->baudrate); + settings.setValue("SERIALLINK_COMM_PARITY", this->parity); + settings.setValue("SERIALLINK_COMM_STOPBITS", this->stopBits); + settings.setValue("SERIALLINK_COMM_DATABITS", this->dataBits); + settings.sync(); + QObject::connect(port, SIGNAL(aboutToClose()), this, SIGNAL(disconnected())); port->open(QIODevice::ReadWrite); diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 69af7a9d1b56ef76563d197614f603b6e21837fa..3f42d6f8ebb9504f73359de23e20654d86e4eeca 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -365,9 +365,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) positionLock = true; // Send to patch antenna - mavlink_message_t msg; - mavlink_msg_global_position_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, pos.usec, pos.lat, pos.lon, pos.alt, pos.vx, pos.vy, pos.vz); - sendMessage(msg); + // FIXME Message re-routing should be implemented differently + //mavlink_message_t msg; + //mavlink_msg_global_position_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, pos.usec, pos.lat, pos.lon, pos.alt, pos.vx, pos.vy, pos.vz); + //sendMessage(msg); } break; case MAVLINK_MSG_ID_GPS_RAW: diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index ff2c9a4992279dd8448d740142455f275cbc8214..ece981abe1efdf059fd2158a7ffbacb4eaa46059 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -16,6 +16,7 @@ #include #include "MG.h" +#include "QGC.h" #include "MAVLinkSimulationLink.h" #include "SerialLink.h" #include "UDPLink.h" @@ -89,6 +90,32 @@ MainWindow::MainWindow(QWidget *parent) : // QMenu* centerMenu = createCenterWidgetMenu(); // centerMenu->setTitle("Center"); // ui.menuBar->addMenu(centerMenu); + + // Load previous widget setup + + // FIXME WORK IN PROGRESS + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + + QList dockwidgets = qFindChildren(this); + if (dockwidgets.size()) + { + settings.beginGroup("mainwindow/dockwidgets"); + for (int i = 0; i < dockwidgets.size(); ++i) + { + QDockWidget *dockWidget = dockwidgets.at(i); + if (dockWidget->parentWidget() == this) + { + if (settings.contains(dockWidget->windowTitle())) + { + dockWidget->setVisible(settings.value(dockWidget->windowTitle(), dockWidget->isVisible()).toBool()); + } + } + } + settings.endGroup(); + } + + + this->show(); } @@ -98,6 +125,27 @@ MainWindow::~MainWindow() statusBar = NULL; } +void MainWindow::storeSettings() +{ + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + + QList dockwidgets = qFindChildren(this); + if (dockwidgets.size()) + { + settings.beginGroup("mainwindow/dockwidgets"); + for (int i = 0; i < dockwidgets.size(); ++i) + { + QDockWidget *dockWidget = dockwidgets.at(i); + if (dockWidget->parentWidget() == this) + { + settings.setValue(dockWidget->windowTitle(), QVariant(dockWidget->isVisible())); + } + } + settings.endGroup(); + } + settings.sync(); +} + QMenu* MainWindow::createCenterWidgetMenu() { QMenu* menu = NULL; diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 47a7995151cffc7fe1a71f0736453b779ee6dce9..54304558b1440af63ef71fe54d3dc33f605ad74f 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -87,6 +87,9 @@ public: ~MainWindow(); public slots: + /** @brief Store the mainwindow settings */ + void storeSettings(); + /** * @brief Shows a status message on the bottom status bar * diff --git a/src/ui/SerialConfigurationWindow.cc b/src/ui/SerialConfigurationWindow.cc index 5542bc93bd382ec0971c464a00c644c7e3303c9b..68674336d2381b8ffb5f3d4170e1cd24aae3f87f 100644 --- a/src/ui/SerialConfigurationWindow.cc +++ b/src/ui/SerialConfigurationWindow.cc @@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project #include #include #include +#include #include #ifdef _WIN32 #include diff --git a/src/ui/XMLCommProtocolWidget.cc b/src/ui/XMLCommProtocolWidget.cc index d472828bf4a01493bd3fba0d043b623edc634c7b..c2ea91ea47901f644dedbb4b0cad98b76160ff8f 100644 --- a/src/ui/XMLCommProtocolWidget.cc +++ b/src/ui/XMLCommProtocolWidget.cc @@ -57,6 +57,7 @@ void XMLCommProtocolWidget::selectXMLFile() setXML(instanceText); // Store filename for next time settings.setValue(mavlinkXML, QFileInfo(file).absoluteFilePath()); + settings.sync(); } else { @@ -112,6 +113,7 @@ void XMLCommProtocolWidget::selectOutputDirectory() m_ui->outputDirNameLabel->setText(fileNames.first()); // Store directory for next time settings.setValue(mavlinkOutputDir, QFileInfo(fileNames.first()).absoluteFilePath()); + settings.sync(); //QFile file(fileName); } }