From e10ca000cd2602cc093e77ae405bb090768bcf95 Mon Sep 17 00:00:00 2001 From: lm Date: Mon, 19 Sep 2011 07:30:23 +0200 Subject: [PATCH] Re-enabled custom widget loading --- src/uas/UAS.cc | 11 ++++--- src/ui/MainWindow.cc | 70 +++++++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 679083fdd..97487f12e 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -1766,10 +1766,13 @@ void UAS::setSystemType(int systemType) void UAS::setUASName(const QString& name) { - this->name = name; - writeSettings(); - emit nameChanged(name); - emit systemSpecsChanged(uasId); + if (name != "") + { + this->name = name; + writeSettings(); + emit nameChanged(name); + emit systemSpecsChanged(uasId); + } } void UAS::executeCommand(MAV_CMD command) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 5896f3577..124b0e11d 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -146,6 +146,8 @@ MainWindow::MainWindow(QWidget *parent): // Create actions connectCommonActions(); + buildCustomWidget(); + // Restore the window setup @@ -268,40 +270,36 @@ QString MainWindow::getWindowGeometryKey() void MainWindow::buildCustomWidget() { - // Show custom widgets only if UAS is connected - if (UASManager::instance()->getActiveUAS() != NULL) - { - // Create custom widgets - QList widgets = QGCToolWidget::createWidgetsFromSettings(this); + // Create custom widgets + QList widgets = QGCToolWidget::createWidgetsFromSettings(this); - if (widgets.size() > 0) - { - ui.menuTools->addSeparator(); - } + if (widgets.size() > 0) + { + ui.menuTools->addSeparator(); + } - for(int i = 0; i < widgets.size(); ++i) + for(int i = 0; i < widgets.size(); ++i) + { + // Check if this widget already has a parent, do not create it in this case + QGCToolWidget* tool = widgets.at(i); + QDockWidget* dock = dynamic_cast(tool->parentWidget()); + if (!dock) { - // Check if this widget already has a parent, do not create it in this case - QGCToolWidget* tool = widgets.at(i); - QDockWidget* dock = dynamic_cast(tool->parentWidget()); - if (!dock) - { - QDockWidget* dock = new QDockWidget(tool->windowTitle(), this); - dock->setObjectName(tool->objectName()+"_DOCK"); - dock->setWidget(tool); - connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater())); - QAction* showAction = new QAction(widgets.at(i)->windowTitle(), this); - showAction->setCheckable(true); - connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool))); - connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool))); - widgets.at(i)->setMainMenuAction(showAction); - ui.menuTools->addAction(showAction); - - // Load dock widget location (default is bottom) - Qt::DockWidgetArea location = static_cast (tool->getDockWidgetArea(currentView)); - - addDockWidget(location, dock); - } + QDockWidget* dock = new QDockWidget(tool->windowTitle(), this); + dock->setObjectName(tool->objectName()+"_DOCK"); + dock->setWidget(tool); + connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater())); + QAction* showAction = new QAction(widgets.at(i)->windowTitle(), this); + showAction->setCheckable(true); + connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool))); + connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool))); + widgets.at(i)->setMainMenuAction(showAction); + ui.menuTools->addAction(showAction); + + // Load dock widget location (default is bottom) + Qt::DockWidgetArea location = static_cast (tool->getDockWidgetArea(currentView)); + + addDockWidget(location, dock); } } } @@ -1251,11 +1249,11 @@ void MainWindow::UASCreated(UASInterface* uas) if (!ui.menuConnected_Systems->isEnabled()) ui.menuConnected_Systems->setEnabled(true); - // Restore the mainwindow size - if (settings.contains(getWindowGeometryKey())) - { - restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray()); - } +// // Restore the mainwindow size +// if (settings.contains(getWindowGeometryKey())) +// { +// restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray()); +// } } /** -- 2.22.0