From 06a16d895861d91315d3a05d943205116fbd2856 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Fri, 20 Nov 2026 20:06:37 +0800 Subject: [PATCH] fix: guard displayShortcuts against key auto-repeat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: keyPressEvent did not filter auto-repeat events for the displayshortcuts shortcut, each repeat launched a new deepin-shortcut-viewer process that killed the previous one 2. Fix: add isAutoRepeat() early-return guard before calling displayShortcuts() so only the initial key press triggers it 3. Impact: only the displayshortcuts branch is affected, no change to other shortcuts or to displayShortcuts() itself Log: 修复快捷键预览界面一闪而过的问题 Influence: 1. Test Ctrl+Shift+? shortcut preview stays visible while holding 2. Test releasing and re-pressing Ctrl+Shift+? reopens preview 3. Verify other shortcuts are unaffected fix: 修复快捷键预览界面一闪而过无法持续显示 1. 根因:keyPressEvent 未过滤 auto-repeat 事件,按住 Ctrl+Shift+? 时 每次 auto-repeat 都启动新的 deepin-shortcut-viewer 进程,新进程 杀掉旧进程导致预览界面一闪而过 2. 方案:在调用 displayShortcuts() 前添加 isAutoRepeat() 守卫,仅 首次按键触发,auto-repeat 事件直接返回 3. 影响:仅影响 displayshortcuts 分支,不改变其他快捷键行为,不 改变 displayShortcuts() 函数本身 Log: 修复快捷键预览界面一闪而过的问题 Influence: 1. 测试按住 Ctrl+Shift+? 时预览界面持续显示 2. 测试释放后再次按下 Ctrl+Shift+? 可重新打开预览 3. 验证其他快捷键功能不受影响 PMS: BUG-381385 --- src/widgets/window.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 20233872..afa204fd 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -4585,6 +4585,8 @@ void Window::keyPressEvent(QKeyEvent *e) qCDebug(appLog) << "key press event press escape"; emit pressEsc(); } else if (key == Utils::getKeyshortcutFromKeymap(m_settings, "window", "displayshortcuts")) { + if (e->isAutoRepeat()) + return; qCDebug(appLog) << "key press event display shortcuts"; displayShortcuts(); } else if (key == Utils::getKeyshortcutFromKeymap(m_settings, "window", "print")) {