diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 2ec5d95fc6acdfaea2acaaabd8f82a8729fa67ad..0d5525c8cd47dd457e67a1fbdfcd4d797fde42cf 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -553,11 +553,23 @@ void MainWindow::connectCommonActions() connect(_ui.actionFlight, &QAction::triggered, this, &MainWindow::showFlyView); connect(_ui.actionPlan, &QAction::triggered, this, &MainWindow::showPlanView); connect(_ui.actionSetup, &QAction::triggered, this, &MainWindow::showSetupView); + connect(_ui.actionFlight, &QAction::triggered, this, &MainWindow::handleActiveViewActionState); + connect(_ui.actionPlan, &QAction::triggered, this, &MainWindow::handleActiveViewActionState); + connect(_ui.actionSetup, &QAction::triggered, this, &MainWindow::handleActiveViewActionState); // Connect internal actions connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleAdded, this, &MainWindow::_vehicleAdded); } +void MainWindow::handleActiveViewActionState(bool triggered) +{ + Q_UNUSED(triggered); + QAction *triggeredAction = qobject_cast(sender()); + _ui.actionFlight->setChecked(triggeredAction == _ui.actionFlight); + _ui.actionPlan->setChecked(triggeredAction == _ui.actionPlan); + _ui.actionSetup->setChecked(triggeredAction == _ui.actionSetup); +} + void MainWindow::_openUrl(const QString& url, const QString& errorMessage) { if(!QDesktopServices::openUrl(QUrl(url))) { diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 6f8c9cba95cfa7263675a3ff114daedee5551d7c..dd2769ee80888048ba0e13ace036cee999ca25ce 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -134,6 +134,15 @@ protected slots: */ void showStatusBarCallback(bool checked); + /** + * @brief Disable the other QActions that trigger view mode changes + * + * When a user hits Ctrl+1, Ctrl+2, Ctrl+3 - only one view is set to active + * (and in the QML file for the MainWindow the others are set to have + * visibility = false), but on the Menu all of them would be selected making + * this incoherent. + */ + void handleActiveViewActionState(bool triggered); signals: // Signals the Qml to show the specified view void showFlyView(void); diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 53be8c499bd0f7ea6c0f1690fc4fa9cdb7e059e2..f31f096b304194c2b623e9e110ff1ba26f15be18 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -445,6 +445,13 @@ Rectangle { flyButton.repaintChevron = true; } } + Connections { + target:controller + onShowFlyView: { flyButton.checked = true } + onShowPlanView: { planButton.checked = true } + onShowSetupView:{ setupButton.checked = true } + } + ExclusiveGroup { id: mainActionGroup }