From 3a9c5a3e7d59a575306603916b386463b71aceec Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 7 Dec 2023 14:29:14 +0100 Subject: [PATCH] ManhattanStyle: Remove a hack for QComboBox wheel scrolling Use Utils::setWheelScrollingWithoutFocusBlocked() explicitly when a QComboBox is placed inside a scroll area. The Utils::setWheelScrollingWithoutFocusBlocked() is more general and may be applied to other widgets, like QSpinBox. This patch brings back the wheel scrolling without a modifier key for combo boxes placed in dialogs. Keep the unconditional scroll wheel behavior when ctrl (meta on mac) modifier is pressed. Change-Id: Ieea0f228cea6b59e276bd3256eb6ea5ecc5b7d14 Reviewed-by: Reviewed-by: Eike Ziller --- src/libs/utils/guiutils.cpp | 10 +++++++++- src/plugins/coreplugin/manhattanstyle.cpp | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libs/utils/guiutils.cpp b/src/libs/utils/guiutils.cpp index 35830f1ca41..17cc9053002 100644 --- a/src/libs/utils/guiutils.cpp +++ b/src/libs/utils/guiutils.cpp @@ -2,19 +2,27 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "guiutils.h" +#include "hostosinfo.h" #include +#include #include namespace Utils { namespace Internal { +static bool isWheelModifier() +{ + return QGuiApplication::keyboardModifiers() + == (HostOsInfo::isMacHost() ? Qt::MetaModifier : Qt::ControlModifier); +} + class WheelEventFilter : public QObject { public: bool eventFilter(QObject *watched, QEvent *event) override { - if (event->type() == QEvent::Wheel) { + if (event->type() == QEvent::Wheel && !isWheelModifier()) { QWidget *widget = qobject_cast(watched); if (widget && widget->focusPolicy() != Qt::WheelFocus && !widget->hasFocus()) { QObject *parent = widget->parentWidget(); diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index 8a2e0b43584..4aa3c6464d5 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -436,12 +436,6 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const if (widget && widget->inherits("QTreeView")) ret = 0; break; - case QStyle::SH_ComboBox_AllowWheelScrolling: - // Turn this on only when simultaneously pressing Ctrl, to prevent accidental current - // index change, e.g. on a scroll view - ret = QGuiApplication::keyboardModifiers() - == (HostOsInfo::isMacHost() ? Qt::MetaModifier : Qt::ControlModifier); - break; case QStyle::SH_Slider_AbsoluteSetButtons: // Make QSlider jump on left mouse click ret = Qt::LeftButton | Qt::MiddleButton | Qt::RightButton;