aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/guiutils.cpp
diff options
context:
space:
mode:
authorJarek Kobus <[email protected]>2023-10-16 21:29:43 +0200
committerJarek Kobus <[email protected]>2024-01-04 11:22:58 +0000
commit3a536482094e54a567fa4438c2c5a4c6405cadd2 (patch)
treece731b73f4043c9e5d67d67ace52cc72843319f3 /src/libs/utils/guiutils.cpp
parente928c19d2764481f2a5ab9a6a3d5784505fc2155 (diff)
GuiUtils: Make wheel blocker transitive
Instead of consuming the wheel event, pass it to the target widget's parent. This should allow for further scrolling the possible parent scroll area. Modify the focus policy only in case of WheelFocus. Change-Id: I00c628a9e3d7608222b0700e71469c6cef6dea88 Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/libs/utils/guiutils.cpp')
-rw-r--r--src/libs/utils/guiutils.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/libs/utils/guiutils.cpp b/src/libs/utils/guiutils.cpp
index bfafff677f7..7789f83993b 100644
--- a/src/libs/utils/guiutils.cpp
+++ b/src/libs/utils/guiutils.cpp
@@ -14,11 +14,15 @@ class WheelEventFilter : public QObject
{
public:
bool eventFilter(QObject *watched, QEvent *event) override {
- auto widget = qobject_cast<QWidget *>(watched);
- return event->type() == QEvent::Wheel
- && widget
- && widget->focusPolicy() != Qt::WheelFocus
- && !widget->hasFocus();
+ if (event->type() == QEvent::Wheel) {
+ QWidget *widget = qobject_cast<QWidget *>(watched);
+ if (widget && widget->focusPolicy() != Qt::WheelFocus && !widget->hasFocus()) {
+ QObject *parent = widget->parentWidget();
+ if (parent)
+ return parent->event(event);
+ }
+ }
+ return QObject::eventFilter(watched, event);
}
};
@@ -28,7 +32,8 @@ void QTCREATOR_UTILS_EXPORT attachWheelBlocker(QWidget *widget)
{
static Internal::WheelEventFilter instance;
widget->installEventFilter(&instance);
- widget->setFocusPolicy(Qt::StrongFocus);
+ if (widget->focusPolicy() == Qt::WheelFocus)
+ widget->setFocusPolicy(Qt::StrongFocus);
}
} // namespace Utils