Gui: Disable changing workbench on tab bar scroll

Fixes: #14164
This commit is contained in:
Kacper Donat
2024-06-10 16:36:20 +02:00
committed by Chris Hennes
parent 3684dc6560
commit d1535e7827
2 changed files with 21 additions and 1 deletions

View File

@@ -428,3 +428,5 @@ void WorkbenchTabWidget::adjustSize()
parentWidget()->adjustSize();
}
#include "moc_WorkbenchSelector.cpp"

View File

@@ -29,6 +29,8 @@
#include <QMenu>
#include <QToolButton>
#include <QLayout>
#include <QWheelEvent>
#include <FCGlobal.h>
#include <Gui/ToolBarManager.h>
#include <map>
@@ -101,7 +103,23 @@ class GuiExport WorkbenchTabWidget : public QWidget
return size;
}
void wheelEvent(QWheelEvent* wheelEvent) override
{
// Qt does not expose any way to programmatically control scroll of QTabBar hence
// we need to use a bit hacky solution of simulating clicks on the scroll buttons
auto left = findChild<QAbstractButton*>(QString::fromUtf8("ScrollLeftButton"));
auto right = findChild<QAbstractButton*>(QString::fromUtf8("ScrollRightButton"));
if (wheelEvent->angleDelta().y() > 0) {
right->click();
} else {
left->click();
}
}
WorkbenchItemStyle itemStyle() const { return _itemStyle; }
void setItemStyle(WorkbenchItemStyle itemStyle) {
_itemStyle = itemStyle;
setProperty("style", QString::fromUtf8(workbenchItemStyleToString(itemStyle)));
@@ -122,7 +140,7 @@ class GuiExport WorkbenchTabWidget : public QWidget
public:
explicit WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent = nullptr);
void setToolBarArea(Gui::ToolBarArea area);
void buildPrefMenu();