From 35b1b820a7a0b3425a19b63f53c66555140337ec Mon Sep 17 00:00:00 2001 From: Tian Shilin Date: Wed, 24 Jun 2026 16:28:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(keyboard):=20SheetSidebar::event()=20?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=A4=84=E7=90=86=20Alt+M=20=E6=B6=88?= =?UTF-8?q?=E9=99=A4=E5=8F=8C=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit log: - Application::notify() 早已把 Alt+M 转为模拟 RightButton MouseEvent 发给焦点 widget,由 SideBarImageListView::mousePressEvent 右键分支 弹菜单;SheetSidebar::event() 同时再调一次 showMenu() 导致双菜单 (一在鼠标位置、一在 visualRect 位置),需按两次 ESC 才能关闭 - 删除 event() 中 Alt+M (Qt::Key_M + AltModifier) 判断,仅保留 Key_Menu (键盘菜单键) 处理路径;Alt+M 完全由 Application::notify 独占,与右键单击行为一致,一次 ESC 即可关闭 pms: bug-363119 --- reader/sidebar/SheetSidebar.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/reader/sidebar/SheetSidebar.cpp b/reader/sidebar/SheetSidebar.cpp index 606766a2..f79a736a 100644 --- a/reader/sidebar/SheetSidebar.cpp +++ b/reader/sidebar/SheetSidebar.cpp @@ -549,14 +549,7 @@ bool SheetSidebar::event(QEvent *event) // qCDebug(appLog) << "SheetSidebar::event start - type:" << event->type(); if (event->type() == QEvent::KeyPress) { QKeyEvent *key_event = static_cast(event); - const bool isMenuKey = (key_event->key() == Qt::Key_Menu); - const bool isAltM = (key_event->key() == Qt::Key_M - && (key_event->modifiers() & Qt::AltModifier)); - if ((isMenuKey || isAltM) && !key_event->isAutoRepeat()) { - // Consume the event so it does not propagate to Qt's mnemonic / - // accelerator handling — otherwise the same Alt+M keeps the - // accelerator state active after exec() returns, causing the - // popup to jump and requiring a second ESC to dismiss it. + if (key_event->key() == Qt::Key_Menu && !key_event->isAutoRepeat()) { showMenu(); return true; }