1 Star 0 Fork 18

xingwei-liu/qt5-qtbase

forked from src-anolis-os/qt5-qtbase 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001_fix-QDoubleSpinbox-and-QSpinbox-not-change-value-when-mouse-scroll.patch 3.60 KB
一键复制 编辑 原始数据 按行查看 历史
xingwei-liu 提交于 2022-10-12 16:54 . feature: add patchs for DDE
From 690fe8b7adc60eaf5867c692ebf517e35697c74b Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Tue, 5 Jul 2022 10:06:08 +0800
Subject: [PATCH]
0001_fix-QDoubleSpinbox-and-QSpinbox-not-change-value-when-mouse-scroll
---
src/widgets/kernel/qapplication.cpp | 10 ++++++-
src/widgets/widgets/qabstractspinbox.cpp | 34 +++++++++++++-----------
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 03e68217..1d5ad478 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -114,6 +114,9 @@
#include <algorithm>
#include <iterator>
+#include <QDoubleSpinBox>
+#include <QSpinBox>
+
//#define ALIEN_DEBUG
static void initResources()
@@ -4092,7 +4095,12 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven
if (focusWidget->isEnabled()
&& focusWidget->rect().contains(localPos)
&& QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
- focusWidget->setFocus(Qt::MouseFocusReason);
+ if ((qobject_cast<QDoubleSpinBox *>(focusWidget) != nullptr || qobject_cast<QSpinBox *>(focusWidget) != nullptr)
+ && event->type() == QEvent::Wheel) {
+ return;
+ }else{
+ focusWidget->setFocus(Qt::MouseFocusReason);
+ }
break;
}
if (focusWidget->isWindow())
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index bdceb91f..37479b4d 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -1167,25 +1167,27 @@ void QAbstractSpinBox::keyReleaseEvent(QKeyEvent *event)
void QAbstractSpinBox::wheelEvent(QWheelEvent *event)
{
Q_D(QAbstractSpinBox);
+ if (this->hasFocus()) {
#ifdef Q_OS_MACOS
- // If the event comes from a real mouse wheel, rather than a track pad
- // (Qt::MouseEventSynthesizedBySystem), the shift modifier changes the
- // scroll orientation to horizontal.
- // Convert horizontal events back to vertical whilst shift is held.
- if ((event->modifiers() & Qt::ShiftModifier)
- && event->source() == Qt::MouseEventNotSynthesized) {
- d->wheelDeltaRemainder += event->angleDelta().x();
- } else {
- d->wheelDeltaRemainder += event->angleDelta().y();
- }
+ // If the event comes from a real mouse wheel, rather than a track pad
+ // (Qt::MouseEventSynthesizedBySystem), the shift modifier changes the
+ // scroll orientation to horizontal.
+ // Convert horizontal events back to vertical whilst shift is held.
+ if ((event->modifiers() & Qt::ShiftModifier)
+ && event->source() == Qt::MouseEventNotSynthesized) {
+ d->wheelDeltaRemainder += event->angleDelta().x();
+ } else {
+ d->wheelDeltaRemainder += event->angleDelta().y();
+ }
#else
- d->wheelDeltaRemainder += event->angleDelta().y();
+ d->wheelDeltaRemainder += event->angleDelta().y();
#endif
- const int steps = d->wheelDeltaRemainder / 120;
- d->wheelDeltaRemainder -= steps * 120;
- if (stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled))
- stepBy(event->modifiers() & d->stepModifier ? steps * 10 : steps);
- event->accept();
+ const int steps = d->wheelDeltaRemainder / 120;
+ d->wheelDeltaRemainder -= steps * 120;
+ if (stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled))
+ stepBy(event->modifiers() & d->stepModifier ? steps * 10 : steps);
+ event->accept();
+ }
}
#endif
--
2.31.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xingwei-liu/qt5-qtbase.git
git@gitee.com:xingwei-liu/qt5-qtbase.git
xingwei-liu
qt5-qtbase
qt5-qtbase
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385