intellicrack.ui.overflow_toolbar

Overflow-aware QToolBar for Intellicrack’s main toolbar.

Qt’s stock QToolBar exposes a built-in extension arrow when items exceed the visible width, but the popup menu it shows only renders text/icons for plain QAction entries. Items added through addWidget() are backed by QWidgetAction instances whose default widgets cannot be reparented into a QMenu, so the popup ends up empty or collapsed to a few pixels. In Intellicrack the entire Tools row is composed of QPushButton widgets, which is why the user-visible arrow does nothing useful on overflow.

This module ships OverflowToolBar, a drop-in QToolBar replacement that detects Qt’s internal extension button, replaces both its attached menu and its mouse-press handling, and shows a properly populated menu where each entry proxies clicks back to the underlying widget (or to the original QAction when no widget proxy is needed).

class OverflowToolBar[source]

Bases: QToolBar

QToolBar that exposes hidden widget actions through a popup.

The toolbar installs itself onto Qt’s extension button once it is created by the layout, replaces the button’s attached menu with a custom QMenu populated on demand, and intercepts left-button mouse presses so Qt’s built-in (empty) popup never opens. Each menu entry proxies activation back to the corresponding clipped widget (or directly triggers the underlying QAction for non- widget actions), so users can reach every Tools-row button even when the window is too narrow to display all of them.

__init__(title, parent=None)[source]

Initialize the overflow-aware toolbar.

Parameters:
  • title (str) – Human-readable title for the toolbar (used by Qt for accessibility and dock-area context menus).

  • parent (QWidget | None) – Parent widget for ownership, or None for a top-level attachment via QMainWindow.addToolBar().

Return type:

None

resizeEvent(a0)[source]

Hook Qt’s extension button once it has been created by the layout.

Parameters:

a0 (QResizeEvent | None) – The resize event delivered by Qt.

Return type:

None

actionEvent(event)[source]

Re-attempt the extension hook after action changes.

Parameters:

event (QActionEvent | None) – Action event delivered by Qt when an action is added, removed, or modified.

Return type:

None

eventFilter(a0, a1)[source]

Intercept activation events on the extension button.

Qt’s QToolButton uses InstantPopup mode for the extension button, which means its mousePressEvent calls showMenu() and returns before the clicked signal can fire. The filter consumes left-button presses (and Space/Enter key presses) directly so the overflow menu is shown by this class instead of Qt’s default empty popup.

Parameters:
  • a0 (QObject | None) – The watched object.

  • a1 (QEvent | None) – The intercepted event.

Returns:

True if the event was consumed; otherwise the result of the superclass filter.

Return type:

bool

property overflow_menu: QMenu

The overflow menu used for hidden toolbar items.

Exposes the populated QMenu so callers (including the Intellicrack UI integration tests and accessibility helpers) can attach signal handlers, enumerate actions, or close the menu without touching the underlying private attribute.

Returns:

The overflow menu instance.

Return type:

QMenu

property extension_button: QToolButton | None

Qt’s extension button once it has been hooked, or None.

Qt creates the extension button lazily during the toolbar’s first layout pass, after which _hook_extension_button() registers it with this property. Callers can use the returned reference to verify the hook has been installed, inspect the button’s configuration, or send synthetic events for accessibility helpers and tests.

Returns:

The hooked extension button, or None when no overflow has yet caused Qt to create one.

Return type:

QToolButton | None

populate_overflow_menu()[source]

Public entry point that rebuilds the overflow menu on demand.

Delegates to _populate_overflow_menu(). Provided so callers can pre-populate the menu (for example, to enumerate clipped actions before triggering them) without invoking the private slot directly.

Return type:

None