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:
QToolBarQToolBarthat 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
QMenupopulated 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 underlyingQActionfor 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
Nonefor a top-level attachment viaQMainWindow.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
QToolButtonusesInstantPopupmode for the extension button, which means itsmousePressEventcallsshowMenu()and returns before theclickedsignal 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:
Trueif the event was consumed; otherwise the result of the superclass filter.- Return type:
The overflow menu used for hidden toolbar items.
Exposes the populated
QMenuso 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
Nonewhen no overflow has yet caused Qt to create one.- Return type:
QToolButton | None
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