chore: added refresh hint
All checks were successful
Code check / Check code (push) Successful in 1m24s

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
2025-11-29 11:28:37 +05:00
parent 9d469f0a12
commit 86fb2b2d7c
5 changed files with 198 additions and 21 deletions

View File

@@ -270,7 +270,7 @@ class MainWindow(QMainWindow):
GamepadType.PLAYSTATION: "ps_options",
},
'menu': {
GamepadType.XBOX: "xbox_view",
GamepadType.XBOX: "xbox_view", # Select button on Xbox
GamepadType.PLAYSTATION: "ps_share",
},
'search': {
@@ -281,6 +281,10 @@ class MainWindow(QMainWindow):
GamepadType.XBOX: "xbox_y",
GamepadType.PLAYSTATION: "ps_square",
},
'guide_select': {
GamepadType.XBOX: "xbox_xbox", # Xbox Guide button
GamepadType.PLAYSTATION: "ps_ps", # PS button
},
}
return mappings.get(action, {}).get(gtype, "placeholder")
@@ -320,6 +324,7 @@ class MainWindow(QMainWindow):
("context_menu", _("Menu")),
("menu", _("Fullscreen")),
("search", _("Search")),
("guide_select", _("Refresh Grid")),
]
keyboard_hints = [
@@ -328,6 +333,7 @@ class MainWindow(QMainWindow):
("key_e", _("Add Game")),
("key_context", _("Menu")),
("key_f11", _("Fullscreen")),
("key_f5", _("Refresh Grid")),
]
self.hintsLabels = []
@@ -375,8 +381,99 @@ class MainWindow(QMainWindow):
hintsLayout.addWidget(container)
# Special function to create combination hint for Guide+Select
def makeCombinationHint(action_text: str, action: str | None = None):
container = QWidget()
layout = QHBoxLayout(container)
layout.setContentsMargins(0, 5, 0, 0)
layout.setSpacing(6)
# First icon (Guide button)
guide_icon = QLabel()
guide_icon.setFixedSize(26, 26)
guide_icon.setAlignment(Qt.AlignmentFlag.AlignCenter)
pixmap = QPixmap()
for candidate in (
self.theme_manager.get_theme_image("xbox_xbox", self.current_theme_name), # Xbox Guide
self.theme_manager.get_theme_image("ps_ps", self.current_theme_name), # PS Button
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
):
if candidate is not None and pixmap.load(str(candidate)):
break
if not pixmap.isNull():
guide_icon.setPixmap(pixmap.scaled(
26, 26,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation
))
layout.addWidget(guide_icon)
# Plus sign between icons
plus_icon = QLabel()
plus_icon.setFixedSize(26, 26)
plus_icon.setAlignment(Qt.AlignmentFlag.AlignCenter)
plus_pixmap = QPixmap()
for candidate in (
self.theme_manager.get_theme_image("key_+", self.current_theme_name),
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
):
if candidate is not None and plus_pixmap.load(str(candidate)):
break
if not plus_pixmap.isNull():
plus_icon.setPixmap(plus_pixmap.scaled(
26, 26,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation
))
layout.addWidget(plus_icon)
# Second icon (Select button)
select_icon = QLabel()
select_icon.setFixedSize(26, 26)
select_icon.setAlignment(Qt.AlignmentFlag.AlignCenter)
pixmap2 = QPixmap()
for candidate in (
self.theme_manager.get_theme_image("xbox_view", self.current_theme_name), # Xbox Select
self.theme_manager.get_theme_image("ps_share", self.current_theme_name), # PS Share
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
):
if candidate is not None and pixmap2.load(str(candidate)):
break
if not pixmap2.isNull():
select_icon.setPixmap(pixmap2.scaled(
26, 26,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation
))
layout.addWidget(select_icon)
# текст действия
text_label = QLabel(action_text)
text_label.setStyleSheet(self.theme.LAST_LAUNCH_VALUE_STYLE)
text_label.setAlignment(Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft)
layout.addWidget(text_label)
# For gamepad combination hints
container.setVisible(False)
self.hintsLabels.append((container, [guide_icon, plus_icon, select_icon], action)) # Store all three elements for dynamic update
hintsLayout.addWidget(container)
# Create gamepad hints
for action, text in gamepad_actions:
if action == "guide_select":
# For the Guide+Select combination, create a special combination hint
makeCombinationHint(text, action)
else:
makeHint("placeholder", text, True, action) # Initial placeholder
# Create keyboard hints
@@ -432,12 +529,88 @@ class MainWindow(QMainWindow):
gtype = self.input_manager.gamepad_type
logger.debug("Updating control hints, gamepad connected: %s, type: %s", is_gamepad_connected, gtype.value)
gamepad_actions = ['confirm', 'back', 'add_game', 'context_menu', 'menu', 'search']
gamepad_actions = ['confirm', 'back', 'add_game', 'context_menu', 'menu', 'search', 'guide_select']
for container, icon_label, action in self.hintsLabels:
for container, icon_element, action in self.hintsLabels:
if action in gamepad_actions: # Gamepad hint
if is_gamepad_connected:
container.setVisible(True)
# Check if this is a combination hint (array of icons) or single icon hint
if isinstance(icon_element, list) and len(icon_element) == 3 and action == "guide_select":
# This is a combination hint for Guide+Select
guide_icon, plus_icon, select_icon = icon_element
# Determine guide icon based on gamepad type
if gtype == GamepadType.XBOX:
guide_icon_name = "xbox_xbox" # Xbox Guide button
elif gtype == GamepadType.PLAYSTATION:
guide_icon_name = "ps_ps" # PS Button
else:
guide_icon_name = "xbox_xbox" # Default to Xbox guide
# Load Guide icon
guide_pixmap = QPixmap()
for candidate in (
self.theme_manager.get_theme_image(guide_icon_name, self.current_theme_name),
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
):
if candidate is not None and guide_pixmap.load(str(candidate)):
break
if not guide_pixmap.isNull():
guide_icon.setPixmap(guide_pixmap.scaled(
26, 26,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation
))
# Load Plus icon
plus_pixmap = QPixmap()
for candidate in (
self.theme_manager.get_theme_image("key_+", self.current_theme_name),
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
):
if candidate is not None and plus_pixmap.load(str(candidate)):
break
if not plus_pixmap.isNull():
plus_icon.setPixmap(plus_pixmap.scaled(
26, 26,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation
))
# Determine select icon based on gamepad type
if gtype == GamepadType.XBOX:
select_icon_name = "xbox_view" # Xbox Select button
elif gtype == GamepadType.PLAYSTATION:
select_icon_name = "ps_share" # PS Share button
else:
select_icon_name = "xbox_view" # Default to Xbox Select
# Load Select icon
select_pixmap = QPixmap()
for candidate in (
self.theme_manager.get_theme_image(select_icon_name, self.current_theme_name),
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
):
if candidate is not None and select_pixmap.load(str(candidate)):
break
if not select_pixmap.isNull():
select_icon.setPixmap(select_pixmap.scaled(
26, 26,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation
))
else:
# This is a regular single-icon hint
# Verify that icon_element is not a list before assigning
if isinstance(icon_element, list):
# This shouldn't happen based on current logic, but added for safety
logger.warning(f"Unexpected list found for single-icon hint with action: {action}")
continue # Skip this iteration to prevent error
icon_label = icon_element
# Update icon based on type
icon_name = self.get_button_icon(action, gtype)
icon_path = self.theme_manager.get_theme_image(icon_name, self.current_theme_name)

View File

@@ -0,0 +1 @@
<svg width="48" height="48" version="1.1" viewBox="0 0 48 48" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m24 9.185c-2.0302 0-3.7027 1.6725-3.7027 3.7027v7.4096h-7.4096c-2.0302 0-3.7027 1.6725-3.7027 3.7027s1.6725 3.7027 3.7027 3.7027h7.4096v7.4096c0 2.0302 1.6725 3.7027 3.7027 3.7027s3.7027-1.6725 3.7027-3.7027v-7.4096h7.4096c2.0302 0 3.7027-1.6725 3.7027-3.7027s-1.6725-3.7027-3.7027-3.7027h-7.4096v-7.4096c0-2.0302-1.6725-3.7027-3.7027-3.7027zm0 2.9613c0.41396 0 0.74137 0.32742 0.74137 0.74137v10.371h10.371c0.41396 0 0.74137 0.32742 0.74137 0.74137s-0.32742 0.74137-0.74137 0.74137h-10.371v10.371c0 0.41396-0.32742 0.74137-0.74137 0.74137s-0.74137-0.32742-0.74137-0.74137v-10.371h-10.371c-0.41396 0-0.74137-0.32742-0.74137-0.74137s0.32742-0.74137 0.74137-0.74137h10.371v-10.371c0-0.41396 0.32742-0.74137 0.74137-0.74137z" fill="#3f424d" stop-color="#000000" stroke-width="1.0662"/><path d="m24 11.494c1.1462 0 2.0844 0.93819 2.0844 2.0844v8.3375h8.3375c1.1462 0 2.0844 0.93819 2.0844 2.0844s-0.93819 2.0844-2.0844 2.0844h-8.3375v8.3375c0 1.1462-0.93819 2.0844-2.0844 2.0844s-2.0844-0.93819-2.0844-2.0844v-8.3375h-8.3375c-1.1462 0-2.0844-0.93819-2.0844-2.0844s0.93819-2.0844 2.0844-2.0844h8.3375v-8.3375c0-1.1462 0.93819-2.0844 2.0844-2.0844z" fill="#fff" stop-color="#000000" stroke-width="0"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1 @@
<svg width="48" height="48" version="1.1" viewBox="0 0 48 48" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m12 6c-3.3238 0-5.9998 2.6763-5.9998 5.9998v24c0 3.3238 2.6763 5.9998 5.9998 5.9998h24c3.3238 0 5.9998-2.6763 5.9998-5.9998v-24c0-3.3238-2.6763-5.9998-5.9998-5.9998z" fill="#3f424d" stroke-width="2.5714"/><path d="m13.697 8.5452c-2.8537 0-5.1515 2.2979-5.1515 5.1515v20.606c0 2.8537 2.2979 5.1515 5.1515 5.1515h20.606c2.8537 0 5.1515-2.2979 5.1515-5.1515v-20.606c0-2.8537-2.2979-5.1515-5.1515-5.1515z" fill="#fff" stroke-width="2.2078"/><path d="m15.222 18.538h8.5002v1.8684h-5.8744v2.6763h5.3189v1.8684h-5.3189v4.511h-2.6258zm13.6 11.092q-1.1614 0-3.4842-0.18515v-2.0367q2.0872 0.38714 3.1476 0.38714 0.92576 0 1.3466-0.20198 0.4208-0.21882 0.4208-0.67328v-1.6327q0-0.45446-0.30298-0.63962-0.30298-0.20198-0.99309-0.20198h-3.3664v-5.908h6.9011v1.8852h-4.4436v2.2218h1.7169q0.97626 0 1.902 0.3703 0.50496 0.21882 0.80794 0.67328t0.30298 1.0604v2.2892q0 0.65645-0.25248 1.1782-0.25248 0.50496-0.63962 0.77427-0.33664 0.25248-0.90893 0.40397-0.55546 0.15149-1.0772 0.20198-0.60595 0.03366-1.0772 0.03366z" fill="#3f424d" stroke-width="0" aria-label="F5"/></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1 @@
<svg width="48" height="48" version="1.1" viewBox="0 0 48 48" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m47 24a23 23 0 0 1-23 23 23 23 0 0 1-23-23 23 23 0 0 1 23-23 23 23 0 0 1 23 23z" fill="#3f424d"/><path d="M 42.513,24 A 18.513,18.513 0 0 1 24,42.513 18.513,18.513 0 0 1 5.4869995,24 18.513,18.513 0 0 1 24,5.4869995 18.513,18.513 0 0 1 42.513,24 Z" fill="#fff"/><path d="m20.375 10.836v21.898l4.4513 1.4106v-18.447c0-1.1417 0.63761-1.8498 1.4528-1.5795 1.2195 0.33732 1.2205 1.7172 1.2205 2.2383v7.34c0.69194 0.30705 1.3479 0.46456 1.9511 0.46456 0.90817 0 1.6684-0.36594 2.2003-1.06 0.57517-0.75032 0.87844-1.8745 0.87844-3.2519 0-3.9851-1.3499-5.7267-5.562-7.1711-1.3341-0.45192-4.3372-1.3851-6.5925-1.8413zm-1.6344 13.688-6.8797 2.441c-0.02379 0.0087-1.7358 0.57835-2.724 1.3092-0.35029 0.25948-0.50605 0.57737-0.44766 0.89955 0.11028 0.60112 0.89455 1.164 2.099 1.5035 2.5191 0.83248 5.1622 1.0445 7.7159 0.62504l0.23228-0.03801v-1.9131l-2.0863 0.75596c-0.96438 0.34597-2.458 0.42428-3.2646 0.16049-0.5795-0.19028-0.70734-0.49524-0.70951-0.71795-0.0043-0.26596 0.17441-0.64535 1.022-0.95023l5.0426-1.8033zm13.269 1.1529c-0.59973-0.0075-1.1869 0.016-1.7442 0.07603-2.1515 0.23785-3.7118 0.78326-3.7291 0.78975l-0.09714 0.0338v2.3692l5.0299-1.7695c0.96439-0.34597 2.4538-0.42428 3.2604-0.16048 0.5795 0.19028 0.70734 0.49523 0.70951 0.71795 0.0021 0.26596-0.17234 0.64329-1.0178 0.94601l-7.9819 2.8465v2.2594l10.706-3.8432c0.01297-0.0043 1.421-0.53074 1.968-1.2205 0.19245-0.24218 0.25306-0.4904 0.17737-0.73907-0.09298-0.30488-0.49051-0.89192-2.0863-1.3979-1.4887-0.56436-3.3954-0.88519-5.1946-0.908z" fill="#3f424d" stroke-width="2.1623"/></svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1 @@
<svg width="48" height="48" version="1.1" viewBox="0 0 48 48" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m47 24a23 23 0 0 1-23 23 23 23 0 0 1-23-23 23 23 0 0 1 23-23 23 23 0 0 1 23 23z" fill="#3f424d"/><path d="M 42.513,24 A 18.513,18.513 0 0 1 24,42.513 18.513,18.513 0 0 1 5.4869995,24 18.513,18.513 0 0 1 24,5.4869995 18.513,18.513 0 0 1 42.513,24 Z" fill="#fff"/><path d="m22.671 37.279c-2.0532-0.1967-4.1317-0.93396-5.9172-2.099-1.4962-0.97578-1.8338-1.3776-1.8338-2.1783 0-1.6086 1.7688-4.4266 4.7953-7.6383 1.7183-1.8246 4.1122-3.962 4.3709-3.9044 0.50369 0.11245 4.5276 4.0376 6.0343 5.8857 2.3821 2.9211 3.4769 5.3138 2.9205 6.3804-0.42284 0.81067-3.0472 2.3955-4.9749 3.0042-1.5891 0.50183-3.6761 0.71433-5.395 0.54984zm-9.772-5.9498c-1.2434-1.9076-1.8716-3.7854-2.1746-6.5015-0.10037-0.89679-0.06505-1.4095 0.22706-3.2507 0.36336-2.2923 1.6697-4.947 3.2402-6.5795 0.66849-0.69389 0.72796-0.71247 1.5433-0.43678 0.98817 0.33455 2.0445 1.0644 3.6832 2.5463l0.95719 0.8655-0.52351 0.64123c-2.4249 2.9769-4.9842 7.1991-5.9476 9.8105-0.52351 1.4188-0.73416 2.8437-0.50802 3.4369 0.15179 0.40084 0.01239 0.25153-0.49873-0.53095zm21.824 0.32433c0.12298-0.59972-0.03253-1.7006-0.39651-2.8115-0.78837-2.4054-3.4242-6.88-5.8445-9.9226l-0.76204-0.95781 0.82461-0.75677c1.0761-0.98817 1.8233-1.5798 2.63-2.0826 0.63596-0.39651 1.5451-0.74748 1.9361-0.74748 0.24069 0 1.0892 0.88285 1.7738 1.8431 1.0607 1.4869 1.8407 3.2929 2.2359 5.1701 0.25556 1.2143 0.27694 3.8102 0.0412 5.0214-0.19516 0.99375-0.60405 2.2818-1.0006 3.1556-0.30048 0.65455-1.0408 1.9262-1.3661 2.34-0.16728 0.21281-0.16728 0.2125-0.07435-0.24658zm-11.832-17.733c-1.117-0.56688-2.84-1.1756-3.7916-1.3398-0.33331-0.05731-0.90236-0.08983-1.2639-0.07125-0.78558 0.03965-0.75058-0.0012 0.50895-0.59631 1.047-0.4947 1.9206-0.78558 3.107-1.0346 1.3336-0.28034 3.8412-0.28344 5.1537-0.0068 1.4172 0.29893 3.0866 0.92002 4.027 1.4993l0.28003 0.17161-0.64123-0.03222c-1.275-0.06443-3.133 0.45072-5.128 1.4209-0.60158 0.29304-1.1245 0.52661-1.1629 0.52042-0.0381-0.0074-0.52847-0.24627-1.0904-0.53126z" fill="#3f424d" stroke-width=".30977"/></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB