Interfície en català, botó Esborra i botons d'icona segons l'estat
This commit is contained in:
+45
-15
@@ -4,14 +4,14 @@ from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import Qt, Signal
|
||||
from PySide6.QtCore import QSize, Qt, Signal
|
||||
from PySide6.QtGui import QPalette, QPixmap
|
||||
from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
QSizePolicy,
|
||||
QStyle,
|
||||
QVBoxLayout,
|
||||
)
|
||||
|
||||
@@ -27,6 +27,7 @@ class GameRow(QFrame):
|
||||
|
||||
download_requested = Signal(object) # Game
|
||||
run_requested = Signal(object) # Game
|
||||
delete_requested = Signal(object) # Game
|
||||
|
||||
def __init__(self, game: Game, root: Path, parent=None) -> None:
|
||||
super().__init__(parent)
|
||||
@@ -63,17 +64,31 @@ class GameRow(QFrame):
|
||||
text_box.addStretch(1)
|
||||
layout.addLayout(text_box, stretch=1)
|
||||
|
||||
# --- Botones ---
|
||||
self.download_btn = QPushButton("Download")
|
||||
self.run_btn = QPushButton("Run")
|
||||
for btn in (self.download_btn, self.run_btn):
|
||||
btn.setMinimumWidth(96)
|
||||
btn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
# --- Botons (icones compactes amb tooltip; visibilitat segons l'estat) ---
|
||||
style = self.style()
|
||||
self._icon_download = style.standardIcon(QStyle.SP_ArrowDown)
|
||||
self._icon_update = style.standardIcon(QStyle.SP_BrowserReload)
|
||||
|
||||
self.download_btn = QPushButton()
|
||||
self.run_btn = QPushButton()
|
||||
self.run_btn.setIcon(style.standardIcon(QStyle.SP_MediaPlay))
|
||||
self.run_btn.setToolTip("Juga")
|
||||
self.delete_btn = QPushButton()
|
||||
self.delete_btn.setIcon(style.standardIcon(QStyle.SP_TrashIcon))
|
||||
self.delete_btn.setToolTip("Esborra")
|
||||
for btn in (self.download_btn, self.run_btn, self.delete_btn):
|
||||
btn.setFixedSize(36, 30)
|
||||
btn.setIconSize(QSize(18, 18))
|
||||
self.download_btn.clicked.connect(lambda: self.download_requested.emit(self.game))
|
||||
self.run_btn.clicked.connect(lambda: self.run_requested.emit(self.game))
|
||||
btn_box = QVBoxLayout()
|
||||
self.delete_btn.clicked.connect(lambda: self.delete_requested.emit(self.game))
|
||||
|
||||
btn_box = QHBoxLayout()
|
||||
btn_box.setSpacing(4)
|
||||
btn_box.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||
btn_box.addWidget(self.download_btn)
|
||||
btn_box.addWidget(self.run_btn)
|
||||
btn_box.addWidget(self.delete_btn)
|
||||
layout.addLayout(btn_box)
|
||||
|
||||
self.refresh()
|
||||
@@ -92,7 +107,7 @@ class GameRow(QFrame):
|
||||
"""Recarga icono, descripción y estado desde la cache local."""
|
||||
meta = load_meta(self.root, self.game.id)
|
||||
self._set_icon()
|
||||
self.desc_label.setText(meta.description or "(sin descripción todavía)")
|
||||
self.desc_label.setText(meta.description or "(sense descripció encara)")
|
||||
self._set_status(meta)
|
||||
|
||||
def _set_icon(self) -> None:
|
||||
@@ -113,18 +128,32 @@ class GameRow(QFrame):
|
||||
)
|
||||
|
||||
def _set_status(self, meta: GameMeta) -> None:
|
||||
if not self.is_installed():
|
||||
self.status_label.setText("No instalado")
|
||||
installed = self.is_installed()
|
||||
|
||||
# Visibilitat dels botons segons l'estat:
|
||||
# - Juga / Esborra: només si està descarregat.
|
||||
# - Descarrega: si no està descarregat o hi ha update pendent.
|
||||
self.run_btn.setVisible(installed)
|
||||
self.delete_btn.setVisible(installed)
|
||||
self.download_btn.setVisible((not installed) or self._update_available)
|
||||
if installed and self._update_available:
|
||||
self.download_btn.setIcon(self._icon_update)
|
||||
self.download_btn.setToolTip("Actualitza")
|
||||
else:
|
||||
self.download_btn.setIcon(self._icon_download)
|
||||
self.download_btn.setToolTip("Descarrega")
|
||||
|
||||
if not installed:
|
||||
self.status_label.setText("No descarregat")
|
||||
self.status_label.setStyleSheet("color: #cc8855; font-size: 11px;")
|
||||
self.run_btn.setEnabled(True) # se permite, avisará si no está
|
||||
elif self._update_available:
|
||||
self.status_label.setText("⬆ Actualización disponible")
|
||||
self.status_label.setText("⬆ Actualització disponible")
|
||||
self.status_label.setStyleSheet(
|
||||
"color: #e0a030; font-weight: bold; font-size: 11px;"
|
||||
)
|
||||
else:
|
||||
ver = f" {meta.version}" if meta.version else ""
|
||||
self.status_label.setText(f"Instalado{ver}")
|
||||
self.status_label.setText(f"Descarregat{ver}")
|
||||
self.status_label.setStyleSheet("color: #6fae6f; font-size: 11px;")
|
||||
|
||||
# --------------------------------------------------------------- busy UI
|
||||
@@ -132,6 +161,7 @@ class GameRow(QFrame):
|
||||
def set_busy(self, busy: bool, message: str = "") -> None:
|
||||
self.download_btn.setEnabled(not busy)
|
||||
self.run_btn.setEnabled(not busy)
|
||||
self.delete_btn.setEnabled(not busy)
|
||||
if busy and message:
|
||||
self.status_label.setText(message)
|
||||
self.status_label.setStyleSheet("color: #d0d060; font-size: 11px;")
|
||||
|
||||
Reference in New Issue
Block a user