feat: pointing-hand cursor on all interactive widgets

QSS cannot set cursors and per-widget setCursor calls get forgotten as
widgets are added, so an app-level filter catches every Polish event on
buttons, combos, and sliders — dialogs and pop-outs included.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 10:35:54 +02:00
co-authored by Claude Fable 5
parent ed8b2bd165
commit 257edc25f8
+24 -1
View File
@@ -15,7 +15,7 @@ from aarecommon.models.models import (
SessionsStateEnum,
TokenData,
)
from PySide6.QtCore import QEvent, QPropertyAnimation, QSettings, Qt, QTimer, Signal, Slot
from PySide6.QtCore import QEvent, QObject, QPropertyAnimation, QSettings, Qt, QTimer, Signal, Slot
from PySide6.QtGui import (
QAction,
QActionGroup,
@@ -26,8 +26,10 @@ from PySide6.QtGui import (
QPalette,
)
from PySide6.QtWidgets import (
QAbstractButton,
QApplication,
QCheckBox,
QComboBox,
QDockWidget,
QFrame,
QGraphicsColorizeEffect,
@@ -39,6 +41,7 @@ from PySide6.QtWidgets import (
QPushButton,
QScrollArea,
QSizePolicy,
QSlider,
QStackedWidget,
QTabWidget,
QToolBar,
@@ -122,6 +125,22 @@ from aare.gui.widgets.wheel_value_guard import WheelValueGuard
logger = setup_logger(LOGGER_NAME)
class ClickableCursorFilter(QObject):
"""App-wide pointing-hand cursor on every button/combo/slider, present
and future. QSS cannot set cursors, and per-widget setCursor calls are
forgotten whenever a new widget is added — the Polish event fires once
for each widget when its style is applied, so this catches them all.
Widgets that manage their own cursor afterwards (beamline state strip's
forbidden cursor) still win: they set it later."""
def eventFilter(self, obj, event):
if event.type() == QEvent.Type.Polish and isinstance(
obj, (QAbstractButton, QComboBox, QSlider)
):
obj.setCursor(Qt.CursorShape.PointingHandCursor)
return False
class MainWindow(QMainWindow):
sample_geometry = Signal(SampleGeometryModel)
@@ -196,6 +215,10 @@ class MainWindow(QMainWindow):
self._tutorial_text_resolver = DictionaryTextResolver(MANUAL_MOUNT_TUTORIAL)
self.state_manager = UIStateManager("PSI", "AareGUI")
# App-level, not window-level: dialogs and pop-outs get it too.
self._clickable_cursor_filter = ClickableCursorFilter(self)
QApplication.instance().installEventFilter(self._clickable_cursor_filter)
# Wheel safety: sliders/spin boxes/combos only react to the wheel
# while the right mouse button is held; a bare wheel just scrolls
# the page — it can never nudge a value or move a motor.