Commit 2ab0357e authored by Don Gagne's avatar Don Gagne

Merge pull request #2156 from tcanabrava/fixButtonActivation

Fix state of buttons (menu, toolbar)
parents 68451354 848938f1
......@@ -557,11 +557,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(qgcApp()->toolbox()->multiVehicleManager(), &MultiVehicleManager::vehicleAdded, this, &MainWindow::_vehicleAdded);
}
void MainWindow::handleActiveViewActionState(bool triggered)
{
Q_UNUSED(triggered);
QAction *triggeredAction = qobject_cast<QAction*>(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))) {
......
......@@ -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);
......
......@@ -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 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment