fix: resolve touch screen scrolling and clicking issues in bluetooth …#437
Conversation
Reviewer's GuideReplaces the Bluetooth applet’s QScroller-based touch handling with a reusable TouchScrollFilter that manually scrolls on touch-drag and synthesizes mouse clicks on tap, improving touch scrolling and tap behavior in the scroll area. Sequence diagram for touch scroll and tap handling via TouchScrollFiltersequenceDiagram
actor User
participant TouchScreen
participant Viewport as ScrollAreaViewport
participant Filter as TouchScrollFilter
participant Area as QAbstractScrollArea
participant VBar as VerticalScrollBar
participant HBar as HorizontalScrollBar
participant Target as TargetWidget
User->>TouchScreen: Finger down
TouchScreen->>Viewport: QEvent TouchBegin
Viewport->>Filter: eventFilter(TouchBegin)
activate Filter
Filter->>Filter: store m_lastPos
deactivate Filter
loop drag to scroll
User->>TouchScreen: Move finger
TouchScreen->>Viewport: QEvent TouchUpdate
Viewport->>Filter: eventFilter(TouchUpdate)
activate Filter
Filter->>Filter: compute deltaX, deltaY
alt exceeds startDragDistance
Filter->>Filter: set m_isDrag = true
end
alt m_isDrag true
opt vertical scroll
Filter->>VBar: setValue(value - deltaY)
end
opt horizontal scroll
Filter->>HBar: setValue(value - deltaX)
end
Filter->>Filter: update m_lastPos
end
deactivate Filter
end
User->>TouchScreen: Finger up
TouchScreen->>Viewport: QEvent TouchEnd
Viewport->>Filter: eventFilter(TouchEnd)
activate Filter
alt m_isDrag true
Filter->>Filter: end gesture, no click
else m_isDrag false
Filter->>Viewport: childAt(touchPos)
Viewport-->>Filter: TargetWidget or viewport
Filter->>Target: synthesize QMouseEvent Press
Filter->>Target: synthesize QMouseEvent Release
end
deactivate Filter
Class diagram for TouchScrollFilter integration with BluetoothApplet scroll areaclassDiagram
class QObject
class QAbstractScrollArea
class QScrollArea
class QScrollBar
QScrollArea --|> QAbstractScrollArea
class BluetoothApplet {
- QScrollArea* m_scrollArea
+ void initUi()
}
class TouchScrollFilter {
+ TouchScrollFilter(area: QAbstractScrollArea*)
+ ~TouchScrollFilter()
+ bool eventFilter(watched: QObject*, event: QEvent*)
- QAbstractScrollArea* m_area
- QPointF m_lastPos
- bool m_isDrag
}
TouchScrollFilter --|> QObject
BluetoothApplet --> QScrollArea : owns
BluetoothApplet --> TouchScrollFilter : creates
TouchScrollFilter --> QAbstractScrollArea : scroll_target
TouchScrollFilter --> QScrollBar : updates
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
TouchScrollFilter::eventFilter, the finalreturn QObject::eventFilter(watched, event);afterreturn true;is unreachable and should be removed to avoid confusion. - For robustness, consider explicitly handling
QEvent::TouchCancelsimilarly toTouchEnd(at least resettingm_isDrag/state) instead of letting it fall through to the default case while stillaccept()-ing the event.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `TouchScrollFilter::eventFilter`, the final `return QObject::eventFilter(watched, event);` after `return true;` is unreachable and should be removed to avoid confusion.
- For robustness, consider explicitly handling `QEvent::TouchCancel` similarly to `TouchEnd` (at least resetting `m_isDrag`/state) instead of letting it fall through to the default case while still `accept()`-ing the event.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…applet - Issue background and cause: Touch screen operations such as scrolling and clicking did not work correctly with the native `QScroller`. - Specific changes: Replaced `QScroller` with a custom `TouchScrollFilter` for the bluetooth applet UI scroll area. - Technical details: Added `TouchScrollFilter` intercepting `QEvent::TouchUpdate` to offset the scroll area manually based on global coordinates differences, and on un-dragged `QEvent::TouchEnd`, simulating a click using QMouseEvent via core app dispatcher. - 问题背景和原因:原生的 `QScroller` 导致蓝牙插件面板的触屏滚动和无拖拽点击操作无法正常工作。 - 具体修改内容:移除了原有蓝牙插件面板滚动区域的 `QScroller` 实现,替换为系统性的 `TouchScrollFilter` 组件。 - 修改的技术细节:通过事件过滤器分析触控变化,基于全屏坐标增量手动控制滚动条数值实现触屏滚动。对于无明显拖拽的触摸抬起事件,通过查询子节点来直接模拟分发鼠标点击事件,从而保证点击的精准响应。 Log: fix: resolve touch screen scrolling and clicking issues in bluetooth applet Pms: BUG-352505
085efd1 to
1c7210d
Compare
deepin pr auto review这份代码主要实现了一个自定义的触摸滚动过滤器 以下是对代码的详细审查和改进建议: 1. 语法与逻辑审查
2. 代码质量
3. 代码性能
4. 代码安全
5. 具体改进建议修改
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
…applet
Issue background and cause: Touch screen operations such as scrolling and clicking did not work correctly with the native
QScroller.Specific changes: Replaced
QScrollerwith a customTouchScrollFilterfor the bluetooth applet UI scroll area.Technical details: Added
TouchScrollFilterinterceptingQEvent::TouchUpdateto offset the scroll area manually based on global coordinates differences, and on un-draggedQEvent::TouchEnd, simulating a click using QMouseEvent via core app dispatcher.问题背景和原因:原生的
QScroller导致蓝牙插件面板的触屏滚动和无拖拽点击操作无法正常工作。具体修改内容:移除了原有蓝牙插件面板滚动区域的
QScroller实现,替换为系统性的TouchScrollFilter组件。修改的技术细节:通过事件过滤器分析触控变化,基于全屏坐标增量手动控制滚动条数值实现触屏滚动。对于无明显拖拽的触摸抬起事件,通过查询子节点来直接模拟分发鼠标点击事件,从而保证点击的精准响应。
Log: fix: resolve touch screen scrolling and clicking issues in bluetooth applet
Pms: BUG-352505
Summary by Sourcery
Replace the bluetooth applet scroll handling with a custom touch event filter to fix touch scrolling and tapping behavior in the scroll area.
Bug Fixes:
Enhancements: