fix(keyboard): SheetSidebar::event() 不再处理 Alt+M 消除双菜单#286
Conversation
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
Reviewer's guide (collapsed on small PRs)Reviewer's GuideSheetSidebar::event() is simplified to only handle the keyboard Menu key (Qt::Key_Menu) and no longer treats Alt+M as a menu trigger, avoiding duplicate context menus because Alt+M is already converted to a right-click by Application::notify(). Sequence diagram for updated keyboard menu handlingsequenceDiagram
participant User
participant Application
participant SheetSidebar
participant SideBarImageListView
participant ContextMenu
%% Alt+M path (handled only by Application::notify)
User->>Application: notify(KeyPress Alt+M)
Application->>Application: notify
Application->>SideBarImageListView: MouseEvent RightButton
SideBarImageListView->>SideBarImageListView: mousePressEvent
SideBarImageListView->>ContextMenu: showMenu
%% Keyboard Menu key path (handled by SheetSidebar::event)
User->>SheetSidebar: event(QEvent::KeyPress Key_Menu)
SheetSidebar->>SheetSidebar: event
SheetSidebar->>ContextMenu: showMenu
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Now that Alt+M is handled exclusively in Application::notify, consider keeping a brief comment here explaining why Key_Menu events are still consumed (to avoid Qt mnemonic/accelerator side effects), so future readers don’t reintroduce Alt+M handling or remove the consumption logic by mistake.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that Alt+M is handled exclusively in Application::notify, consider keeping a brief comment here explaining why Key_Menu events are still consumed (to avoid Qt mnemonic/accelerator side effects), so future readers don’t reintroduce Alt+M handling or remove the consumption logic by mistake.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够优秀,无需额外修改,以下为保持当前逻辑的完整上下文参考实现
bool SheetSidebar::event(QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *key_event = static_cast<QKeyEvent *>(event);
if (key_event->key() == Qt::Key_Menu && !key_event->isAutoRepeat()) {
showMenu();
return true;
}
}
return QWidget::event(event);
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JWWTSL, lzwind 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 |
log:
pms: bug-363119
Summary by Sourcery
Bug Fixes: