-
Notifications
You must be signed in to change notification settings - Fork 37
feat: add Ctrl+wheel icon scaling support #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
Reviewer's GuideAdds 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 scalingsequenceDiagram
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
Class diagram for extracted icon scaling helpers in FullscreenFrameclassDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这段代码主要实现了通过快捷键(Ctrl++ / Ctrl+-)和鼠标滚轮(Ctrl+滚轮)来调整图标缩放比例的功能。以下是对这段代码的详细审查和改进建议: 1. 语法逻辑代码逻辑基本正确,能够实现预期的功能。将重复的缩放逻辑提取为 改进建议:
2. 代码质量代码质量整体较好,但仍有提升空间。 改进建议:
3. 代码性能代码性能方面没有明显问题,但有一些优化空间。 改进建议:
4. 代码安全代码安全方面没有明显的安全隐患,但有一些注意事项。 改进建议:
改进后的代码示例// 在 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
// ... 其余代码保持不变
}总结这段代码实现了图标缩放功能,逻辑正确,但可以通过以下方式改进:
这些改进将使代码更易于维护和扩展,同时保持良好的性能和安全性。 |
There was a problem hiding this 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
returnwhenQt.ControlModifieris present even ifangleDelta.yis 0 (e.g. horizontal wheel/trackpad scroll with Ctrl), which suppresses the normal page-switching behavior; consider only consuming the event (and returning) whenyDelta !== 0so 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
increaseIconScaleanddecreaseIconScale; 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
functions
pressed
Log: Added Ctrl+wheel support for adjusting icon size in fullscreen mode
Influence:
feat: 添加Ctrl+滚轮图标缩放支持
Log: 在全屏模式下新增Ctrl+滚轮调整图标大小功能
Influence:
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:
Enhancements: