From 7a25f8f6a7c7eb1e0f43710ceb9292b882fb797e Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 8 Sep 2015 14:19:36 -0700 Subject: [PATCH] Add switch for using old/new mission editor --- src/QGCApplication.cc | 12 +++++++++++ src/QGCApplication.h | 5 +++++ src/ui/MainWindow.cc | 50 +++++++++++++++++++++---------------------- src/ui/MainWindow.h | 3 ++- src/ui/MainWindow.ui | 13 ++++++++++- 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 7ecc0e54b..346bdb739 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -158,6 +158,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) , _runningUnitTests(unitTesting) , _styleIsDark(true) , _fakeMobile(false) + , _useNewMissionEditor(false) { Q_ASSERT(_app == NULL); _app = this; @@ -419,6 +420,9 @@ bool QGCApplication::_initForNormalAppBoot(void) _styleIsDark = settings.value(_styleKey, _styleIsDark).toBool(); _loadCurrentStyle(); + // Temp hack for new mission editor + _useNewMissionEditor = settings.value("UseNewMissionEditor", false).toBool(); + // Show splash screen QPixmap splashImage(":/res/SplashScreen"); QSplashScreen* splashScreen = new QSplashScreen(splashImage); @@ -801,3 +805,11 @@ void QGCApplication::showToolBarMessage(const QString& message) QGCMessageBox::information("", message); } } + +void QGCApplication::setUseNewMissionEditor(bool use) +{ + // Temp hack for new mission editor + QSettings settings; + + settings.setValue("UseNewMissionEditor", use); +} diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 9c18443f6..7097e7d67 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -106,6 +106,9 @@ public: /// @return true: Fake ui into showing mobile interface bool fakeMobile(void) { return _fakeMobile; } + bool useNewMissionEditor(void) { return _useNewMissionEditor; } + void setUseNewMissionEditor(bool use); + public slots: /// You can connect to this slot to show an information message box from a different thread. void informationMessageBoxOnMainThread(const QString& title, const QString& msg); @@ -175,6 +178,8 @@ private: bool _fakeMobile; ///< true: Fake ui into displaying mobile interface + bool _useNewMissionEditor; ///< true: Use new Mission Editor + /// Unit Test have access to creating and destroying singletons friend class UnitTest; }; diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index afe26d8b1..18097f521 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -709,7 +709,6 @@ void MainWindow::connectCommonActions() perspectives->addAction(_ui.actionFlight); perspectives->addAction(_ui.actionSimulationView); perspectives->addAction(_ui.actionPlan); - perspectives->addAction(_ui.actionMissionEditor); perspectives->addAction(_ui.actionSetup); perspectives->setExclusive(true); @@ -729,16 +728,11 @@ void MainWindow::connectCommonActions() _ui.actionSimulationView->setChecked(true); _ui.actionSimulationView->activate(QAction::Trigger); } - if (_currentView == VIEW_PLAN) + if (_currentView == VIEW_PLAN || _currentView == VIEW_MISSIONEDITOR) { _ui.actionPlan->setChecked(true); _ui.actionPlan->activate(QAction::Trigger); } - if (_currentView == VIEW_MISSIONEDITOR) - { - _ui.actionMissionEditor->setChecked(true); - _ui.actionMissionEditor->activate(QAction::Trigger); - } if (_currentView == VIEW_SETUP) { _ui.actionSetup->setChecked(true); @@ -757,7 +751,9 @@ void MainWindow::connectCommonActions() connect(_ui.actionSimulationView, SIGNAL(triggered()), this, SLOT(loadSimulationView())); connect(_ui.actionAnalyze, SIGNAL(triggered()), this, SLOT(loadAnalyzeView())); connect(_ui.actionPlan, SIGNAL(triggered()), this, SLOT(loadPlanView())); - connect(_ui.actionMissionEditor, SIGNAL(triggered()), this, SLOT(loadMissionEditorView())); + + _ui.actionUseMissionEditor->setChecked(qgcApp()->useNewMissionEditor()); + connect(_ui.actionUseMissionEditor, &QAction::triggered, this, &MainWindow::_setUseMissionEditor); // Help Actions connect(_ui.actionOnline_Documentation, SIGNAL(triggered()), this, SLOT(showHelp())); @@ -1005,23 +1001,22 @@ void MainWindow::loadAnalyzeView() void MainWindow::loadPlanView() { - if (_currentView != VIEW_PLAN) - { - _storeCurrentViewState(); - _currentView = VIEW_PLAN; - _ui.actionPlan->setChecked(true); - _loadCurrentViewState(); - } -} - -void MainWindow::loadMissionEditorView() -{ - if (_currentView != VIEW_MISSIONEDITOR) - { - _storeCurrentViewState(); - _currentView = VIEW_MISSIONEDITOR; - _ui.actionMissionEditor->setChecked(true); - _loadCurrentViewState(); + if (qgcApp()->useNewMissionEditor()) { + if (_currentView != VIEW_MISSIONEDITOR) + { + _storeCurrentViewState(); + _currentView = VIEW_MISSIONEDITOR; + _ui.actionPlan->setChecked(true); + _loadCurrentViewState(); + } + } else { + if (_currentView != VIEW_PLAN) + { + _storeCurrentViewState(); + _currentView = VIEW_PLAN; + _ui.actionPlan->setChecked(true); + _loadCurrentViewState(); + } } } @@ -1118,3 +1113,8 @@ void MainWindow::_showQmlTestWidget(void) new QmlTestWidget(); } #endif + +void MainWindow::_setUseMissionEditor(bool checked) +{ + qgcApp()->setUseNewMissionEditor(checked); +} diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 00ec87b41..6e1bbf34d 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -135,7 +135,6 @@ public slots: void loadSimulationView(); void loadAnalyzeView(); void loadPlanView(); - void loadMissionEditorView(); void manageLinks(); @@ -176,6 +175,8 @@ protected slots: * @brief Enable/Disable Status Bar */ void showStatusBarCallback(bool checked); + + void _setUseMissionEditor(bool checked); signals: void initStatusChanged(const QString& message, int alignment, const QColor &color); diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index 05fbb5134..3132ca0f0 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -62,6 +62,7 @@ + @@ -79,7 +80,6 @@ - @@ -254,6 +254,17 @@ Mission Editor + + + true + + + Use new mission editor (reboot required) + + + Mission Editor + + -- 2.22.0