From 7e0cf657f4d9bbfd451f077d653e8338378d89ac Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Wed, 17 Apr 2024 14:19:08 +0200 Subject: [PATCH] TabBar: Move + tab to beginning. --- src/Gui/WorkbenchSelector.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Gui/WorkbenchSelector.cpp b/src/Gui/WorkbenchSelector.cpp index 3b1eca1e92..8d9b395edb 100644 --- a/src/Gui/WorkbenchSelector.cpp +++ b/src/Gui/WorkbenchSelector.cpp @@ -149,12 +149,12 @@ WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent) setCurrentIndex(index); }); connect(this, qOverload(&QTabBar::tabBarClicked), aGroup, [aGroup, moreAction](int index) { - if (index < aGroup->getEnabledWbActions().size()) { - aGroup->actions()[index]->trigger(); - } - else { + if(index == 0) { moreAction->trigger(); } + else if (index <= aGroup->getEnabledWbActions().size()) { + aGroup->actions()[index - 1]->trigger(); + } }); if (parent->inherits("QToolBar")) { @@ -175,6 +175,14 @@ void WorkbenchTabWidget::refreshList(QList actionList) hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches"); int itemStyleIndex = hGrp->GetInt("WorkbenchSelectorItem", 0); + QIcon icon = Gui::BitmapFactory().iconFromTheme("list-add"); + if (itemStyleIndex == 2) { + addTab(QString::fromLatin1("+")); + } + else { + addTab(icon, QString::fromLatin1("")); + } + for (QAction* action : actionList) { QIcon icon = action->icon(); if (icon.isNull() || itemStyleIndex == 2) { @@ -192,17 +200,6 @@ void WorkbenchTabWidget::refreshList(QList actionList) } } - QIcon icon = Gui::BitmapFactory().iconFromTheme("list-add"); - if (itemStyleIndex == 2) { - addTab(tr("More")); - } - else if (itemStyleIndex == 1) { - addTab(icon, QString::fromLatin1("")); - } - else { - addTab(icon, tr("More")); - } - buildPrefMenu(); }