Skip to content

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Feb 3, 2026

  1. Extracted icon scaling logic from keyboard shortcuts into reusable
    functions
  2. Added mouse wheel event handler with Ctrl modifier detection
  3. Implemented Ctrl+wheel up/down to increase/decrease icon scale
  4. Maintained existing keyboard shortcuts (Ctrl++/Ctrl+-) functionality
  5. Preserved normal wheel behavior for page switching when Ctrl is not
    pressed

Log: Added Ctrl+wheel support for adjusting icon size in fullscreen mode

Influence:

  1. Test Ctrl+wheel up increases icon size up to 100% maximum
  2. Test Ctrl+wheel down decreases icon size down to 50% minimum
  3. Verify existing keyboard shortcuts (Ctrl++ and Ctrl+-) still work
  4. Test normal wheel behavior without Ctrl modifier switches pages
  5. Verify icon scaling respects the 0.5-1.0 range limits
  6. Test smooth scaling with multiple wheel events
  7. Verify no interference with other wheel-based interactions

feat: 添加Ctrl+滚轮图标缩放支持

  1. 将图标缩放逻辑从键盘快捷键提取为可重用函数
  2. 添加鼠标滚轮事件处理程序,支持Ctrl修饰键检测
  3. 实现Ctrl+滚轮上/下滚动来增加/减少图标缩放比例
  4. 保持现有键盘快捷键(Ctrl++/Ctrl+-)功能不变
  5. 当未按下Ctrl键时,保留正常的滚轮翻页行为

Log: 在全屏模式下新增Ctrl+滚轮调整图标大小功能

Influence:

  1. 测试Ctrl+滚轮向上滚动可将图标大小增加到最大100%
  2. 测试Ctrl+滚轮向下滚动可将图标大小减少到最小50%
  3. 验证现有键盘快捷键(Ctrl++和Ctrl+-)仍然正常工作
  4. 测试无Ctrl修饰键时正常滚轮行为可切换页面
  5. 验证图标缩放遵守0.5-1.0的范围限制
  6. 测试多次滚轮事件的平滑缩放效果
  7. 验证不会干扰其他基于滚轮的交互功能

PMS: BUG-342077

Summary by Sourcery

Add reusable icon scaling helpers and support adjusting icon size with Ctrl+mouse wheel in fullscreen mode while preserving existing behaviors.

New Features:

  • Support changing icon scale in fullscreen mode using Ctrl+mouse wheel up/down.

Enhancements:

  • Extract icon scaling logic into reusable increase/decrease helper functions shared by keyboard shortcuts and wheel handling.

1. Extracted icon scaling logic from keyboard shortcuts into reusable
functions
2. Added mouse wheel event handler with Ctrl modifier detection
3. Implemented Ctrl+wheel up/down to increase/decrease icon scale
4. Maintained existing keyboard shortcuts (Ctrl++/Ctrl+-) functionality
5. Preserved normal wheel behavior for page switching when Ctrl is not
pressed

Log: Added Ctrl+wheel support for adjusting icon size in fullscreen mode

Influence:
1. Test Ctrl+wheel up increases icon size up to 100% maximum
2. Test Ctrl+wheel down decreases icon size down to 50% minimum
3. Verify existing keyboard shortcuts (Ctrl++ and Ctrl+-) still work
4. Test normal wheel behavior without Ctrl modifier switches pages
5. Verify icon scaling respects the 0.5-1.0 range limits
6. Test smooth scaling with multiple wheel events
7. Verify no interference with other wheel-based interactions

feat: 添加Ctrl+滚轮图标缩放支持

1. 将图标缩放逻辑从键盘快捷键提取为可重用函数
2. 添加鼠标滚轮事件处理程序,支持Ctrl修饰键检测
3. 实现Ctrl+滚轮上/下滚动来增加/减少图标缩放比例
4. 保持现有键盘快捷键(Ctrl++/Ctrl+-)功能不变
5. 当未按下Ctrl键时,保留正常的滚轮翻页行为

Log: 在全屏模式下新增Ctrl+滚轮调整图标大小功能

Influence:
1. 测试Ctrl+滚轮向上滚动可将图标大小增加到最大100%
2. 测试Ctrl+滚轮向下滚动可将图标大小减少到最小50%
3. 验证现有键盘快捷键(Ctrl++和Ctrl+-)仍然正常工作
4. 测试无Ctrl修饰键时正常滚轮行为可切换页面
5. 验证图标缩放遵守0.5-1.0的范围限制
6. 测试多次滚轮事件的平滑缩放效果
7. 验证不会干扰其他基于滚轮的交互功能

PMS: BUG-342077
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 3, 2026

Reviewer's Guide

Adds reusable icon scaling helpers and extends fullscreen icon zoom controls to support Ctrl+mouse wheel while preserving existing keyboard shortcuts and normal wheel-based page switching.

Sequence diagram for Ctrl+wheel based icon scaling

sequenceDiagram
  actor User
  participant InputEventItem
  participant FullscreenFrame as baseLayer
  participant DesktopIntegration

  User->>InputEventItem: wheelEvent(angleDelta, modifiers)
  InputEventItem->>InputEventItem: check modifiers for Qt_ControlModifier
  alt Ctrl_pressed
    InputEventItem->>InputEventItem: compute yDelta = angleDelta_y_div_8
    alt yDelta_greater_than_0
      InputEventItem->>FullscreenFrame: increaseIconScale()
      FullscreenFrame->>DesktopIntegration: read iconScaleFactor
      FullscreenFrame->>DesktopIntegration: set iconScaleFactor = min(iconScaleFactor_plus_0_1_1_0)
    else yDelta_less_than_0
      InputEventItem->>FullscreenFrame: decreaseIconScale()
      FullscreenFrame->>DesktopIntegration: read iconScaleFactor
      FullscreenFrame->>DesktopIntegration: set iconScaleFactor = max(iconScaleFactor_minus_0_1_0_5)
    end
    InputEventItem-->>User: wheelEvent_handled_no_page_switch
  else Ctrl_not_pressed
    InputEventItem->>InputEventItem: run_page_switching_logic
    InputEventItem-->>User: page_switched_icon_scale_unchanged
  end
Loading

Class diagram for extracted icon scaling helpers in FullscreenFrame

classDiagram
  class DesktopIntegration {
    <<singleton>>
    double iconScaleFactor
    int dockPosition
  }

  class FullscreenFrame_baseLayer {
    +bool isHorizontalDock
    +Palette textColor
    +increaseIconScale()
    +decreaseIconScale()
    +tryToRemoveEmptyPage()
  }

  class Shortcut_CtrlPlus {
    +context
    +sequences
    +onActivated()
  }

  class Shortcut_CtrlMinus {
    +context
    +sequences
    +onActivated()
  }

  FullscreenFrame_baseLayer --> DesktopIntegration : uses_iconScaleFactor
  Shortcut_CtrlPlus --> FullscreenFrame_baseLayer : calls_increaseIconScale
  Shortcut_CtrlMinus --> FullscreenFrame_baseLayer : calls_decreaseIconScale
Loading

File-Level Changes

Change Details Files
Refactor icon scaling logic into reusable helper functions on the fullscreen base layer
  • Replace inline Ctrl++/Ctrl+- handlers with calls to new helper functions
  • Introduce increaseIconScale() to increment iconScaleFactor up to a 1.0 maximum with 0.1 steps
  • Introduce decreaseIconScale() to decrement iconScaleFactor down to a 0.5 minimum with 0.1 steps
qml/FullscreenFrame.qml
Add Ctrl+mouse wheel handling for adjusting fullscreen icon size without affecting page switching
  • Extend wheel event handler to detect Ctrl modifier before normal wheel handling
  • On Ctrl+wheel up, call increaseIconScale(); on Ctrl+wheel down, call decreaseIconScale()
  • Ensure normal wheel behavior for page switching remains when Ctrl is not pressed and avoid interfering with existing interactions
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

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码主要实现了通过快捷键(Ctrl++ / Ctrl+-)和鼠标滚轮(Ctrl+滚轮)来调整图标缩放比例的功能。以下是对这段代码的详细审查和改进建议:

1. 语法逻辑

代码逻辑基本正确,能够实现预期的功能。将重复的缩放逻辑提取为 increaseIconScaledecreaseIconScale 函数是很好的重构,符合 DRY (Don't Repeat Yourself) 原则。

改进建议:

  • 代码复用性:目前的缩放逻辑虽然提取成了函数,但硬编码了步长(0.1)和范围(0.5-1.0)。如果未来需要调整这些参数,需要修改多处。建议将这些定义为常量或属性。
  • 函数命名increaseIconScaledecreaseIconScale 的命名是准确的,但可以考虑更通用的名称,如 adjustIconScale,并通过参数传递方向。

2. 代码质量

代码质量整体较好,但仍有提升空间。

改进建议:

  • 注释:虽然添加了一些注释,但可以更详细地说明函数的作用和参数的含义。
  • 魔法数字:代码中存在一些"魔法数字"(如 0.1, 0.5, 1.0),建议定义为有意义的常量,提高代码可读性。
  • 代码组织:新添加的函数可以放在更合适的位置,例如与图标缩放相关的属性或函数放在一起。

3. 代码性能

代码性能方面没有明显问题,但有一些优化空间。

改进建议:

  • 减少重复计算wheel.angleDelta.y / 8 被计算了两次,可以只计算一次并存储结果。
  • 事件处理:在 onWheel 中使用了 return 来提前退出,这是好的做法,可以避免不必要的计算。

4. 代码安全

代码安全方面没有明显的安全隐患,但有一些注意事项。

改进建议:

  • 输入验证:虽然目前 DesktopIntegration.iconScaleFactor 的值是受控的,但最好在函数中添加对输入值的验证,确保不会超出预期范围。
  • 边界检查:目前的边界检查是正确的,但可以考虑添加日志或警告,当缩放达到边界时提供反馈。

改进后的代码示例

// 在 baseLayer 中添加属性定义
readonly property real minIconScale: 0.5
readonly property real maxIconScale: 1.0
readonly property real iconScaleStep: 0.1

function increaseIconScale() {
    if (DesktopIntegration.iconScaleFactor < maxIconScale) {
        DesktopIntegration.iconScaleFactor = Math.min(DesktopIntegration.iconScaleFactor + iconScaleStep, maxIconScale)
    }
}

function decreaseIconScale() {
    if (DesktopIntegration.iconScaleFactor > minIconScale) {
        DesktopIntegration.iconScaleFactor = Math.max(DesktopIntegration.iconScaleFactor - iconScaleStep, minIconScale)
    }
}

// 在 onWheel 中优化计算
onWheel: function(wheel) {
    // Handle Ctrl+Wheel for icon scaling
    if (wheel.modifiers & Qt.ControlModifier) {
        let yDelta = wheel.angleDelta.y / 8
        if (yDelta > 0) {
            // Scroll up with Ctrl: increase icon size
            baseLayer.increaseIconScale()
        } else if (yDelta < 0) {
            // Scroll down with Ctrl: decrease icon size
            baseLayer.decreaseIconScale()
        }
        return
    }
    
    // Normal wheel behavior: page switching
    if (flipPageDelay.running) return
    let xDelta = wheel.angleDelta.x / 8
    let yDelta = wheel.angleDelta.y / 8
    // ... 其余代码保持不变
}

总结

这段代码实现了图标缩放功能,逻辑正确,但可以通过以下方式改进:

  1. 将魔法数字定义为常量,提高代码可读性
  2. 优化事件处理中的重复计算
  3. 添加更详细的注释和边界检查
  4. 考虑将缩放函数进一步通用化

这些改进将使代码更易于维护和扩展,同时保持良好的性能和安全性。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In the Ctrl+wheel handler you always return when Qt.ControlModifier is present even if angleDelta.y is 0 (e.g. horizontal wheel/trackpad scroll with Ctrl), which suppresses the normal page-switching behavior; consider only consuming the event (and returning) when yDelta !== 0 so unhandled Ctrl+wheel gestures still fall through.
  • The icon scaling limits (0.5, 1.0) and step size (0.1) are duplicated as magic numbers in both increaseIconScale and decreaseIconScale; consider extracting these into named properties or constants to keep the behavior consistent and easier to adjust.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the Ctrl+wheel handler you always `return` when `Qt.ControlModifier` is present even if `angleDelta.y` is 0 (e.g. horizontal wheel/trackpad scroll with Ctrl), which suppresses the normal page-switching behavior; consider only consuming the event (and returning) when `yDelta !== 0` so unhandled Ctrl+wheel gestures still fall through.
- The icon scaling limits (0.5, 1.0) and step size (0.1) are duplicated as magic numbers in both `increaseIconScale` and `decreaseIconScale`; consider extracting these into named properties or constants to keep the behavior consistent and easier to adjust.

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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@18202781743 18202781743 merged commit 2319772 into linuxdeepin:master Feb 3, 2026
9 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.

3 participants