fix: block keyboard shortcuts during drag-and-drop operations#348
Merged
pengfeixx merged 1 commit intoMay 27, 2026
Merged
Conversation
Expose isDragging state from ItemListView and FolderListView, disable all Shortcut elements and Delete key during drag. 拖拽记事本或文件夹时屏蔽所有快捷键操作(Delete、Ctrl+N、 Ctrl+B、F2、F3、Ctrl+R、Ctrl+S 等),避免误触。 Log: 拖拽过程中屏蔽快捷键操作 PMS: BUG-361629 Influence: 拖拽过程中所有快捷键和Delete键被禁用,松手后自动恢复。
d91cf2e to
be412e9
Compare
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff。本次代码变更的核心目的是在拖拽状态下禁用快捷键和删除操作,以防止拖拽过程中误触发其他功能。 整体来看,这个修改的逻辑是清晰且合理的,但在语法逻辑、代码质量、代码性能和代码安全方面,我有一些改进建议供你参考: 一、 语法与逻辑
二、 代码质量
三、 代码性能
四、 代码安全
综合改进建议代码示例基于以上分析,我建议对 1. FolderListView.qml / ItemListView.qml (优化状态绑定) // 建议使用 drag.active 替代 held,语义更准确
property bool isDragging: delegateDrag.drag.active
// 如果必须用 held,确保有取消机制
// onHeldChanged: root.isDragging = held
// Keys.onPressed: (event) => { if (event.key === Qt.Key_Escape) root.isDragging = false; }2. Shortcuts.qml (消除冗余代码) Item {
id: item
property bool blockRecordingKey: false
property bool isRecordingAudio: false
property bool isDragging: false
// 提取公共的禁用逻辑,减少重复代码
property bool baseBlocked: item.isDragging || item.initialOnlyCreateFolder
signal copy
signal createFolder
// ... 其他 signal
Shortcut {
id: f1
autoRepeat: false
// 使用 baseBlocked 替代重复的 &&
enabled: !item.baseBlocked
sequence: "F1"
onActivated: { showHelpManual(); }
}
Shortcut {
id: ctrl_Shift_H
enabled: !item.baseBlocked
sequence: "Ctrl+Shift+/"
onActivated: { showShortcutsView(); }
}
Shortcut {
id: ctrl_N
sequence: "Ctrl+N"
// 对于包含其他特殊逻辑的,继续追加
enabled: !item.baseBlocked && !item.blockCreateKeys
onActivated: { createFolder(); }
}
// ... 其他同理
}3. MainWindow.qml (更极致的性能与简洁方案,可选) Shortcuts {
id: shortcuts
// 直接控制组件级别的 enabled,性能最高,代码最简
enabled: rootWindow.active && !itemListView.isDragging && !folderListView.isDragging
// 内部的各个 Shortcut 就不需要再判断 isDragging 了
// ...
}(注意:需确认 |
wyu71
approved these changes
May 27, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx, wyu71 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose isDragging state from ItemListView and FolderListView, disable all Shortcut elements and Delete key during drag.
拖拽记事本或文件夹时屏蔽所有快捷键操作(Delete、Ctrl+N、
Ctrl+B、F2、F3、Ctrl+R、Ctrl+S 等),避免误触。
Log: 拖拽过程中屏蔽快捷键操作
PMS: BUG-361629
Influence: 拖拽过程中所有快捷键和Delete键被禁用,松手后自动恢复。