TabBar: Move + tab to beginning.

This commit is contained in:
PaddleStroke
2024-04-17 14:19:08 +02:00
committed by Chris Hennes
parent 418219330f
commit 7e0cf657f4

View File

@@ -149,12 +149,12 @@ WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent)
setCurrentIndex(index);
});
connect(this, qOverload<int>(&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<QAction*> 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<QAction*> 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();
}