Skip to content

Automation bridge: add a context-menu verb (trigger + inspect custom right-click menus) #3858

Description

@ten9876

Problem

The automation bridge can drive button drop-down menus (showMenuQToolButton::menu() / QPushButton::menu()), but it has no way to trigger or inspect a widget's custom right-click context menu (Qt::CustomContextMenu / customContextMenuRequested, or an overridden contextMenuEvent).

This surfaced while verifying the S-meter config relocation (#TODO link the PR), which moves TX/RX-meter select, peak-hold, decay-speed, and reset into a right-click context menu on the gauge. The bridge could confirm the inline controls were removed (dumpTree) but could not open or read the new context menushowMenu returns "has no drop-down menu (expected a QToolButton/QPushButton with menu())" because the menu is built on demand in a customContextMenuRequested handler, not attached to a button. So that whole class of UI is currently invisible/undriveable from the bridge.

Proposed enhancement

Add a verb (e.g. contextMenu <target>) that:

  1. Triggers the target widget's context menu — synthesize a QContextMenuEvent at the widget (or its center), which fires both customContextMenuRequested (CustomContextMenu policy) and an overridden contextMenuEvent. This must run deferred / on the GUI loop and be re-entrancy-safe like the existing showMenu/openMenu path (the popup runs its own event loop).
  2. Exposes the resulting QMenu for inspection + invocation, reusing the existing menu-walk/serialisation already used by showMenu (items, enabled/checked state, separators, section/header rows, submenus) so a driver can read the structure and invoke an item by text/path.

Nice-to-haves

  • Handle QWidgetAction header rows gracefully in the menu serialisation (the S-meter menu uses disabled QWidgetAction + QLabel for section titles, since QMenu::addSection() text doesn't render under the app's menu styling — so a generic header type in the dump would help).
  • Allow targeting by the same resolveWidget rules as invoke/showMenu (objectName, class, accessibleName, scope).

Why

Context-menu-driven config is a growing pattern in the UI (S-meter now; likely more as we de-clutter applets). Without this verb, those surfaces can't be regression-tested or automated through the bridge, which undercuts the bridge's value as a UI test harness.

Related: #3813 (other bridge driving gaps).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUIUser interfaceenhancementImprovement to existing featuremaintainer-reviewRequires maintainer review before any action is taken

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions