From 136c06dc7f16bb8b819ac2ed9dfc019334e4e6da Mon Sep 17 00:00:00 2001 From: Bryant Date: Mon, 1 Dec 2014 13:46:56 -0800 Subject: [PATCH] Remove the DEFAULT view from QGC's perspectives logic. It was a poor proxy for better coding around the problem of bad settings or the lack of settings on first-run. --- src/ui/MainWindow.cc | 64 +++++++++++++++++++------------------------- src/ui/MainWindow.h | 5 ++-- 2 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index d21b25ad5..766b9ef6c 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -148,21 +148,36 @@ MainWindow::MainWindow(QSplashScreen* splashScreen, enum MainWindow::CUSTOM_MODE menuActionHelper->setAdvancedMode(settings.value("ADVANCED_MODE").toBool()); } + // Select the proper view. Default to the flight view or load the last one used if it's supported. if (!settings.contains("CURRENT_VIEW")) { - // Set this view as default view settings.setValue("CURRENT_VIEW", currentView); } else { - // LOAD THE LAST VIEW VIEW_SECTIONS currentViewCandidate = (VIEW_SECTIONS) settings.value("CURRENT_VIEW", currentView).toInt(); - if (currentViewCandidate != VIEW_ENGINEER && - currentViewCandidate != VIEW_MISSION && - currentViewCandidate != VIEW_FLIGHT && - currentViewCandidate != VIEW_DEFAULT) - { - currentView = currentViewCandidate; + switch (currentViewCandidate) { + case VIEW_ENGINEER: + case VIEW_MISSION: + case VIEW_FLIGHT: + case VIEW_SIMULATION: + case VIEW_SETUP: + case VIEW_SOFTWARE_CONFIG: + case VIEW_TERMINAL: + +// And only re-load views if they're supported with the current QGC build +#ifdef QGC_OSG_ENABLED + case VIEW_LOCAL3D: +#endif +#ifdef QGC_GOOGLE_EARTH_ENABLED + case VIEW_GOOGLEEARTH: +#endif + + currentView = currentViewCandidate; + default: + // If an invalid view candidate was found in the settings file, just use the default view and re-save. + settings.setValue("CURRENT_VIEW", currentView); + break; } } @@ -466,6 +481,7 @@ void MainWindow::buildCustomWidget() case VIEW_ENGINEER: dock = createDockWidget(engineeringView,tool,tool->getTitle(),tool->objectName(),(VIEW_SECTIONS)view,location); break; + default: // Flight view is the default. case VIEW_FLIGHT: dock = createDockWidget(pilotView,tool,tool->getTitle(),tool->objectName(),(VIEW_SECTIONS)view,location); break; @@ -481,7 +497,6 @@ void MainWindow::buildCustomWidget() case VIEW_LOCAL3D: dock = createDockWidget(local3DView,tool,tool->getTitle(),tool->objectName(),(VIEW_SECTIONS)view,location); break; - default: dock = createDockWidget(centerStack->currentWidget(),tool,tool->getTitle(),tool->objectName(),(VIEW_SECTIONS)view,location); break; } @@ -838,6 +853,7 @@ void MainWindow::loadCustomWidget(const QString& fileName, int view) case VIEW_ENGINEER: createDockWidget(engineeringView,tool,tool->getTitle(),tool->objectName()+"DOCK",(VIEW_SECTIONS)view,Qt::LeftDockWidgetArea); break; + default: // Flight view is the default. case VIEW_FLIGHT: createDockWidget(pilotView,tool,tool->getTitle(),tool->objectName()+"DOCK",(VIEW_SECTIONS)view,Qt::LeftDockWidgetArea); break; @@ -847,14 +863,6 @@ void MainWindow::loadCustomWidget(const QString& fileName, int view) case VIEW_MISSION: createDockWidget(plannerView,tool,tool->getTitle(),tool->objectName()+"DOCK",(VIEW_SECTIONS)view,Qt::LeftDockWidgetArea); break; - default: - { - //Delete tool, create menu item to tie it to. - customWidgetNameToFilenameMap[tool->objectName()+"DOCK"] = fileName; - menuActionHelper->createToolAction(tool->getTitle(), tool->objectName()+"DOCK"); - tool->deleteLater(); - } - break; } } else @@ -878,6 +886,7 @@ void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance) case VIEW_ENGINEER: createDockWidget(engineeringView,tool,tool->getTitle(),tool->objectName()+"DOCK",(VIEW_SECTIONS)view,Qt::LeftDockWidgetArea); break; + default: // Flight view is the default. case VIEW_FLIGHT: createDockWidget(pilotView,tool,tool->getTitle(),tool->objectName()+"DOCK",(VIEW_SECTIONS)view,Qt::LeftDockWidgetArea); break; @@ -887,15 +896,6 @@ void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance) case VIEW_MISSION: createDockWidget(plannerView,tool,tool->getTitle(),tool->objectName()+"DOCK",(VIEW_SECTIONS)view,Qt::LeftDockWidgetArea); break; - default: - { - //Delete tool, create menu item to tie it to. - customWidgetNameToFilenameMap[tool->objectName()+"DOCK"] = fileName; - QAction *action = menuActionHelper->createToolAction(tool->getTitle(), tool->objectName()+"DOCK"); - ui.menuTools->addAction(action); - tool->deleteLater(); - } - break; } @@ -1587,6 +1587,7 @@ void MainWindow::loadViewState() case VIEW_ENGINEER: centerStack->setCurrentWidget(engineeringView); break; + default: // Default to the flight view case VIEW_FLIGHT: centerStack->setCurrentWidget(pilotView); break; @@ -1607,17 +1608,6 @@ void MainWindow::loadViewState() case VIEW_LOCAL3D: centerStack->setCurrentWidget(local3DView); break; - case VIEW_DEFAULT: - default: - if (controlDockWidget) - { - controlDockWidget->hide(); - } - if (listDockWidget) - { - listDockWidget->show(); - } - break; } } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 3981d36df..cd8266c26 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -305,13 +305,12 @@ protected: VIEW_MISSION, // Mission/Map/Plan view mode. Used for setting mission waypoints and high-level system commands. VIEW_FLIGHT, // Flight/Fly/Operate view mode. Used for 1st-person observation of the vehicle VIEW_SIMULATION, // Simulation view. Useful overview of the entire system for simulation. - VIEW_FIRMWAREUPDATE, // Firmware Update view. Used for modifying the onboard vehicle firmware. UNUSED. + VIEW_FIRMWAREUPDATE, // UNUSED, left for backwards compatibility with existing saved settings. VIEW_SETUP, // Setup view. Used for initializing the system for operation. Includes UI for calibration, firmware updating/checking, and parameter modifcation. VIEW_SOFTWARE_CONFIG, // Software view. Used for configuring the onboard software/firmware. VIEW_TERMINAL, // Terminal interface. Used for communicating with the remote system, usually in a special configuration input mode. VIEW_LOCAL3D, // A local 3D view. Provides a local 3D view that makes visualizing 3D attitude/orientation/pose easy while in operation. - VIEW_GOOGLEEARTH, // 3D Google Earth view. A 3D terrain view, though the vehicle is still 2D. - VIEW_DEFAULT // Not a real view. Merely a programming abstraction to simplify the code. + VIEW_GOOGLEEARTH // 3D Google Earth view. A 3D terrain view, though the vehicle is still 2D. } VIEW_SECTIONS; /** -- 2.22.0