From e2a2f6cec9470b59d9044a0e9dded0134dc65518 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Sat, 18 Mar 2023 21:03:40 +0100 Subject: [PATCH] Gui: use QActionGroup signal for dimension indicator change handling --- src/Gui/MainWindow.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 05eed66704..f1e49e145f 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -174,16 +174,16 @@ public: QAction* action = menu->addAction(QStringLiteral("UnitSchema%1").arg(i)); actionGrp->addAction(action); action->setCheckable(true); - QObject::connect(action, &QAction::toggled, this, [this,i](bool checked) { - if(checked) { - // Set and save the Unit System - Base::UnitsApi::setSchema(static_cast(i)); - getWindowParameter()->SetInt("UserSchema", i); - // Update the application to show the unit change - Gui::Application::Instance->onUpdate(); - } - } ); + action->setData(i); } + QObject::connect(actionGrp, &QActionGroup::triggered, this, [this](QAction* action) { + int userSchema = action->data().toInt(); + // Set and save the Unit System + Base::UnitsApi::setSchema(static_cast(userSchema)); + getWindowParameter()->SetInt("UserSchema", userSchema); + // Update the application to show the unit change + Gui::Application::Instance->onUpdate(); + } ); setMenu(menu); retranslateUi(); unitChanged(); @@ -221,10 +221,7 @@ private: if(Q_UNLIKELY(userSchema < 0 || userSchema >= actions.size())) { userSchema = 0; } - auto action = actions[userSchema]; - if(!action->isChecked()) { // Using a QSignalBlocker leads to issue - action->setChecked(true); - } + actions[userSchema]->setChecked(true); } void retranslateUi() {