From fd8f919564a0610f7414e3db8b8e97e7bc5accdf Mon Sep 17 00:00:00 2001 From: Paddle Date: Mon, 22 May 2023 15:21:40 +0200 Subject: [PATCH] Wb group fixes --- src/Gui/Action.cpp | 13 ++++++++----- src/Gui/Action.h | 6 +----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index fa85f145d6..3105ad1ca7 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -603,7 +603,7 @@ void ActionGroup::onHovered (QAction *act) // -------------------------------------------------------------------- -WorkbenchComboBox::WorkbenchComboBox(WorkbenchGroup* wb, QWidget* parent) : QComboBox(parent), group(wb) +WorkbenchComboBox::WorkbenchComboBox(QWidget* parent) : QComboBox(parent) { } @@ -667,13 +667,13 @@ void WorkbenchGroup::addTo(QWidget *widget) }); }; if (widget->inherits("QToolBar")) { - auto* box = new WorkbenchComboBox(this, widget); + auto* box = new WorkbenchComboBox(widget); setupBox(box); qobject_cast(widget)->addWidget(box); } else if (widget->inherits("QMenuBar")) { - auto* box = new WorkbenchComboBox(this, widget); + auto* box = new WorkbenchComboBox(widget); setupBox(box); bool left = WorkbenchSwitcher::isLeftCorner(WorkbenchSwitcher::getValue()); @@ -684,7 +684,7 @@ void WorkbenchGroup::addTo(QWidget *widget) menu = menu->addMenu(action()->text()); menu->addActions(actions()); - connect(this, &WorkbenchGroup::workbenchListRefreshed, this, [this, menu](QList actions) { + connect(this, &WorkbenchGroup::workbenchListRefreshed, this, [menu](QList actions) { menu->clear(); menu->addActions(actions); }); @@ -701,7 +701,10 @@ void WorkbenchGroup::refreshWorkbenchList() delete action; } + std::string activeWbName = ""; Workbench* activeWB = WorkbenchManager::instance()->active(); + if (activeWB) + activeWbName = activeWB->name(); // Create action list of enabled wb int index = 0; @@ -720,7 +723,7 @@ void WorkbenchGroup::refreshWorkbenchList() if (index < 9) { action->setShortcut(QKeySequence(QString::fromUtf8("W,%1").arg(index + 1))); } - if (wbName.toStdString() == activeWB->name()) { + if (wbName.toStdString() == activeWbName) { action->setChecked(true); } diff --git a/src/Gui/Action.h b/src/Gui/Action.h index 06c00ac610..4be36fa8e7 100644 --- a/src/Gui/Action.h +++ b/src/Gui/Action.h @@ -177,22 +177,18 @@ private: }; // -------------------------------------------------------------------- - -class WorkbenchGroup; class GuiExport WorkbenchComboBox : public QComboBox { Q_OBJECT public: - explicit WorkbenchComboBox(WorkbenchGroup* wb, QWidget* parent=nullptr); + explicit WorkbenchComboBox(QWidget* parent=nullptr); void showPopup() override; public Q_SLOTS: void refreshList(QList); private: - WorkbenchGroup* group; - Q_DISABLE_COPY(WorkbenchComboBox) };