From b025e0bbcf692f0d42026fa0e9b204a37187ee75 Mon Sep 17 00:00:00 2001 From: Boris Yumankulov Date: Tue, 10 Jun 2025 00:22:54 +0500 Subject: [PATCH] feat: rework QMessageBox handle and add focus style to it Signed-off-by: Boris Yumankulov --- portprotonqt/input_manager.py | 20 +++++++++++++++++--- portprotonqt/themes/standart/styles.py | 4 ++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/portprotonqt/input_manager.py b/portprotonqt/input_manager.py index 1b4fa7a..51da736 100644 --- a/portprotonqt/input_manager.py +++ b/portprotonqt/input_manager.py @@ -3,7 +3,7 @@ import threading from typing import Protocol, cast from evdev import InputDevice, ecodes, list_devices import pyudev -from PySide6.QtWidgets import QWidget, QStackedWidget, QApplication, QScrollArea, QLineEdit, QDialog, QMenu, QComboBox, QListView +from PySide6.QtWidgets import QWidget, QStackedWidget, QApplication, QScrollArea, QLineEdit, QDialog, QMenu, QComboBox, QListView, QMessageBox from PySide6.QtCore import Qt, QObject, QEvent, QPoint, Signal, Slot, QTimer from PySide6.QtGui import QKeyEvent from portprotonqt.logger import get_logger @@ -284,8 +284,22 @@ class InputManager(QObject): self.dpad_timer.stop() # Stop timer when D-pad is released return - # Handle SystemOverlay or AddGameDialog navigation with D-pad - if isinstance(active, QDialog) and code == ecodes.ABS_HAT0Y and value != 0: + # Handle SystemOverlay, AddGameDialog, or QMessageBox navigation with D-pad + if isinstance(active, QDialog) and code == ecodes.ABS_HAT0X and value != 0: + if isinstance(active, QMessageBox): # Specific handling for QMessageBox + if not focused or not active.focusWidget(): + # If no widget is focused, focus the first focusable widget + focusables = active.findChildren(QWidget, options=Qt.FindChildOption.FindChildrenRecursively) + focusables = [w for w in focusables if w.focusPolicy() & Qt.FocusPolicy.StrongFocus] + if focusables: + focusables[0].setFocus(Qt.FocusReason.OtherFocusReason) + return + if value > 0: # Right + active.focusNextChild() + elif value < 0: # Left + active.focusPreviousChild() + return + elif isinstance(active, QDialog) and code == ecodes.ABS_HAT0Y and value != 0: # Keep up/down for other dialogs if not focused or not active.focusWidget(): # If no widget is focused, focus the first focusable widget focusables = active.findChildren(QWidget, options=Qt.FindChildOption.FindChildrenRecursively) diff --git a/portprotonqt/themes/standart/styles.py b/portprotonqt/themes/standart/styles.py index d66468a..2ba0c9e 100644 --- a/portprotonqt/themes/standart/styles.py +++ b/portprotonqt/themes/standart/styles.py @@ -519,6 +519,10 @@ MESSAGE_BOX_STYLE = """ background: #09bec8; border-color: rgba(255, 255, 255, 0.3); } + QMessageBox QPushButton:focus { + border: 2px solid #409EFF; + background: #404554; + } """ # СТИЛИ ДЛЯ ВКЛАДКИ НАСТРОЕК PORTPROTON