From 3325c27475501845f8293304f3040f8e4b0d9196 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 10 May 2013 18:49:19 +0200 Subject: [PATCH] Fixed visual state, fixed check state indication of main menu --- src/ui/QGCToolBar.cc | 11 +++++++++-- src/ui/QGCToolBar.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index 17e3dd863..46497667a 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -197,7 +197,7 @@ void QGCToolBar::setPerspectiveChangeActions(const QList &actions) first->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); first->setCheckable(true); connect(first, SIGNAL(clicked(bool)), actions.first(), SIGNAL(triggered(bool))); - first->setStyleSheet("QToolButton { min-width: 60px; color: #222222; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #A2A3A4, stop: 1 #B6B7B8); margin-left: 8px; margin-right: 0px; border-radius: 0px; border : 0px solid blue; border-bottom-left-radius: 6px; border-top-left-radius: 6px; border-left: 1px solid #484848; border-top: 1px solid #484848; border-bottom: 1px solid #484848; } QToolButton:checked { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #555555, stop: 1 #787878); color: #DDDDDD; }"); + first->setStyleSheet("QToolButton { min-width: 60px; color: #222222; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #A2A3A4, stop: 1 #B6B7B8); margin-left: 8px; margin-right: 0px; padding-left: 4px; padding-right: 8px; border-radius: 0px; border : 0px solid blue; border-bottom-left-radius: 6px; border-top-left-radius: 6px; border-left: 1px solid #484848; border-top: 1px solid #484848; border-bottom: 1px solid #484848; } QToolButton:checked { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #555555, stop: 1 #787878); color: #DDDDDD; }"); addWidget(first); group->addButton(first); @@ -247,15 +247,22 @@ void QGCToolBar::setPerspectiveChangeAdvancedActions(const QList &acti menu->addAction(actions.at(i)); } - menu->setStyleSheet("QMenu { font-weight: bold; min-width: 70px; color: #222222; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #A2A3A4, stop: 1 #B6B7B8); border: 1px solid #484848; } QMenu:checked { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #555555, stop: 1 #787878); color: #DDDDDD; }"); + menu->setStyleSheet("QMenu { font-weight: bold; min-width: 70px; color: #222222; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #A2A3A4, stop: 1 #B6B7B8); border: 1px solid #484848; } QMenu::item:checked { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #555555, stop: 1 #787878); color: #DDDDDD; }"); advancedButton->setMenu(menu); + connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(advancedActivityTriggered(QAction*))); } else { qDebug() << __FILE__ << __LINE__ << "Not enough perspective change actions provided"; } } +void QGCToolBar::advancedActivityTriggered(QAction* action) +{ + if (action->isChecked()) + advancedButton->setChecked(true); +} + void QGCToolBar::setActiveUAS(UASInterface* active) { // Do nothing if system is the same or NULL diff --git a/src/ui/QGCToolBar.h b/src/ui/QGCToolBar.h index a21f0c3cc..99a977038 100644 --- a/src/ui/QGCToolBar.h +++ b/src/ui/QGCToolBar.h @@ -78,6 +78,8 @@ public slots: void connectLink(bool connect); /** @brief Clear status string */ void clearStatusString(); + /** @brief Set an activity action as checked in menu */ + void advancedActivityTriggered(QAction* action); protected: void createCustomWidgets(); -- 2.22.0