Skip to content

feat: add tap handler to hide launcher#658

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-324421
Oct 11, 2025
Merged

feat: add tap handler to hide launcher#658
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-324421

Conversation

@wjyrich

@wjyrich wjyrich commented Oct 11, 2025

Copy link
Copy Markdown
Contributor

feat: add tap handler to hide launcher

  1. Add TapHandler to GridViewContainer to hide launcher when tapped
  2. This provides better user experience by allowing users to dismiss the
    launcher with a simple tap
  3. The handler sets LauncherController.visible to false when any area
    within the grid view is tapped
  4. Improves navigation flow by giving users intuitive way to close the
    launcher interface

feat: 添加点击处理器以隐藏启动器

  1. 在 GridViewContainer 中添加 TapHandler 以便点击时隐藏启动器
  2. 通过允许用户简单点击即可关闭启动器来提供更好的用户体验
  3. 当网格视图内的任何区域被点击时,处理器将 LauncherController.visible
    设置为 false
  4. 通过为用户提供直观的关闭启动器界面方式来改进导航流程

PMS: BUG-324421

@sourcery-ai

sourcery-ai Bot commented Oct 11, 2025

Copy link
Copy Markdown

Reviewer's Guide

The PR refactors the search results grid by wrapping the existing GridViewContainer in an Item, disables its built-in interactivity to fix click-through issues, and adds a custom MouseArea that captures wheel events and manually adjusts the scrollbar position with proper bounds checking, all while preserving the original look and behavior.

Sequence diagram for custom scroll interaction in search result grid

sequenceDiagram
participant User as actor User
participant MouseArea
participant ScrollBar
participant GridViewContainer

User->>MouseArea: Wheel event
MouseArea->>ScrollBar: Check if visible
alt ScrollBar visible
    MouseArea->>ScrollBar: Adjust position (with bounds)
end
Loading

Class diagram for updated search result grid structure

classDiagram
class Item {
}
class GridViewContainer {
  - interactive: bool
  - vScrollBar: ScrollBar
}
class MouseArea {
  + onWheel(wheel)
}
class ScrollBar {
  - position: float
  - size: float
  - visible: bool
  - active: bool
}
Item "1" *-- "1" GridViewContainer
Item "1" *-- "1" MouseArea
GridViewContainer "1" *-- "1" ScrollBar
MouseArea ..> ScrollBar: adjusts position
Loading

File-Level Changes

Change Details Files
Wrap GridViewContainer in an Item container
  • Added an Item wrapper with anchors.fill and visibility bound to search text
  • Moved GridViewContainer definition inside this new wrapper
qml/FullscreenFrame.qml
Disable interactive property on GridViewContainer
  • Changed interactive from true to false to prevent click-through issues
  • Retained focus and highlighting settings
qml/FullscreenFrame.qml
Implement custom scroll-wheel handling
  • Added a full-area MouseArea to capture onWheel events
  • Computed scrollStep and adjusted scrollbar.position within min/max bounds
qml/FullscreenFrame.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `qml/FullscreenFrame.qml:643-651` </location>
<code_context>
+                            if (!searchResultGridViewContainer.vScrollBar.visible) return
+                            
+                            let delta = wheel.angleDelta.y
+                            let scrollStep = 0.1
+                            
+                            if (delta > 0) {
+                                searchScrollBar.position = Math.max(0, searchScrollBar.position - scrollStep)
+                            } else if (delta < 0) {
</code_context>

<issue_to_address>
**suggestion:** Fixed scrollStep value may not scale well for different grid sizes.

Hardcoding scrollStep to 0.1 can cause inconsistent scrolling across different grid sizes. Dynamically calculate scrollStep based on grid dimensions or item count for more consistent behavior.

```suggestion
                            let delta = wheel.angleDelta.y
                            // Dynamically calculate scrollStep based on grid size
                            // For example, scroll by one visible item per wheel event
                            let gridView = searchResultGridViewContainer
                            let visibleItems = Math.max(1, Math.floor(gridView.height / gridView.cellHeight))
                            let totalItems = gridView.count > 0 ? gridView.count : 1
                            let scrollStep = visibleItems / totalItems

                            if (delta > 0) {
                                searchScrollBar.position = Math.max(0, searchScrollBar.position - scrollStep)
                            } else if (delta < 0) {
                                let maxPosition = 1.0 - searchScrollBar.size
                                searchScrollBar.position = Math.min(maxPosition, searchScrollBar.position + scrollStep)
                            }
```
</issue_to_address>

### Comment 2
<location> `qml/FullscreenFrame.qml:649-650` </location>
<code_context>
+                            if (delta > 0) {
+                                searchScrollBar.position = Math.max(0, searchScrollBar.position - scrollStep)
+                            } else if (delta < 0) {
+                                let maxPosition = 1.0 - searchScrollBar.size
+                                searchScrollBar.position = Math.min(maxPosition, searchScrollBar.position + scrollStep)
+                            }
+                        }
</code_context>

<issue_to_address>
**issue:** Potential edge case if searchScrollBar.size is undefined or zero.

If searchScrollBar.size is missing or zero, maxPosition may be incorrect, causing the scrollbar to exceed its intended range. Please validate that searchScrollBar.size is always set to a positive value when the scrollbar is shown.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread qml/FullscreenFrame.qml Outdated
Comment on lines +643 to +651
let delta = wheel.angleDelta.y
let scrollStep = 0.1

if (delta > 0) {
searchScrollBar.position = Math.max(0, searchScrollBar.position - scrollStep)
} else if (delta < 0) {
let maxPosition = 1.0 - searchScrollBar.size
searchScrollBar.position = Math.min(maxPosition, searchScrollBar.position + scrollStep)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Fixed scrollStep value may not scale well for different grid sizes.

Hardcoding scrollStep to 0.1 can cause inconsistent scrolling across different grid sizes. Dynamically calculate scrollStep based on grid dimensions or item count for more consistent behavior.

Suggested change
let delta = wheel.angleDelta.y
let scrollStep = 0.1
if (delta > 0) {
searchScrollBar.position = Math.max(0, searchScrollBar.position - scrollStep)
} else if (delta < 0) {
let maxPosition = 1.0 - searchScrollBar.size
searchScrollBar.position = Math.min(maxPosition, searchScrollBar.position + scrollStep)
}
let delta = wheel.angleDelta.y
// Dynamically calculate scrollStep based on grid size
// For example, scroll by one visible item per wheel event
let gridView = searchResultGridViewContainer
let visibleItems = Math.max(1, Math.floor(gridView.height / gridView.cellHeight))
let totalItems = gridView.count > 0 ? gridView.count : 1
let scrollStep = visibleItems / totalItems
if (delta > 0) {
searchScrollBar.position = Math.max(0, searchScrollBar.position - scrollStep)
} else if (delta < 0) {
let maxPosition = 1.0 - searchScrollBar.size
searchScrollBar.position = Math.min(maxPosition, searchScrollBar.position + scrollStep)
}

Comment thread qml/FullscreenFrame.qml Outdated
Comment on lines +649 to +650
let maxPosition = 1.0 - searchScrollBar.size
searchScrollBar.position = Math.min(maxPosition, searchScrollBar.position + scrollStep)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Potential edge case if searchScrollBar.size is undefined or zero.

If searchScrollBar.size is missing or zero, maxPosition may be incorrect, causing the scrollbar to exceed its intended range. Please validate that searchScrollBar.size is always set to a positive value when the scrollbar is shown.

Comment thread qml/FullscreenFrame.qml Outdated
1. Add TapHandler to GridViewContainer to hide launcher when tapped
2. This provides better user experience by allowing users to dismiss the
launcher with a simple tap
3. The handler sets LauncherController.visible to false when any area
within the grid view is tapped
4. Improves navigation flow by giving users intuitive way to close the
launcher interface

feat: 添加点击处理器以隐藏启动器

1. 在 GridViewContainer 中添加 TapHandler 以便点击时隐藏启动器
2. 通过允许用户简单点击即可关闭启动器来提供更好的用户体验
3. 当网格视图内的任何区域被点击时,处理器将 LauncherController.visible
设置为 false
4. 通过为用户提供直观的关闭启动器界面方式来改进导航流程

PMS: BUG-324421
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我对这段代码进行审查,并提出以下改进意见:

  1. 代码逻辑和功能:
  • 添加的TapHandler用于在点击GridViewContainer时隐藏LauncherController,这个功能本身是合理的,但缺乏上下文判断。
  • 没有判断是否已经在其他界面或是否已经隐藏,可能导致不必要的操作。
  1. 代码质量:
  • 代码缩进和格式正确,符合QML规范。
  • 添加的TapHandler位置合适,放在GridView内部可以确保点击整个区域都能触发。
  1. 代码性能:
  • 每次点击都会直接修改LauncherController.visible属性,没有性能问题,因为这是一个简单的布尔值操作。
  • 如果LauncherController的隐藏操作涉及更复杂的计算或动画,可能需要考虑防抖处理。
  1. 代码安全:
  • 直接访问LauncherController.visible属性需要确保LauncherController已经正确初始化。
  • 如果LauncherController是单例模式,这种直接访问是安全的,但最好添加一些防护措施。

改进建议:

TapHandler {
    onTapped: {
        // 添加防护措施,确保LauncherController存在
        if (typeof(LauncherController) !== 'undefined' && LauncherController) {
            // 只有在当前可见时才执行隐藏操作,避免不必要的操作
            if (LauncherController.visible) {
                LauncherController.visible = false;
            }
        }
    }
}

或者,如果项目使用了Qt 5.15+,可以考虑使用更现代的事件处理方式:

TapHandler {
    target: parent
    onTapped: {
        if (LauncherController?.visible) {
            LauncherController.visible = false;
        }
    }
}

这些改进可以增加代码的健壮性,避免潜在的错误,同时保持原有的功能不变。

@wjyrich wjyrich changed the title fix: fix search result grid scroll interaction feat: add tap handler to hide launcher Oct 11, 2025

@BLumia BLumia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

清真多了(

Comment thread qml/FullscreenFrame.qml Outdated
interactive: false
vScrollBar: ScrollBar {
id: searchScrollBar
visible: parent.model.count > 4 * 8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样处理后,控制中心设置的滚动条策略是不是有问题了,

Comment thread qml/FullscreenFrame.qml Outdated
active: parent.model.count > 4 * 8
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以直接给GridView挂一个TapHandler,来接收点击事件吧,

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia, wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wjyrich

wjyrich commented Oct 11, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 11, 2025

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 4c52e66 into linuxdeepin:master Oct 11, 2025
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants