Estil targeta tipus web a les files + tema seleccionable (system/clar/fosc)
UI: - Files amb estil de targeta: icona arrodonida, títol gran, subtítol atenuat i 'pills' amb estat, versió, data de llançament, jugadors, autor i topics. Els pills envolten amb un FlowLayout nou quan no caben. - Submenú Opcions > Tema amb Sistema/Clar/Fosc; persisteix a settings.json (theme) i s'aplica a l'instant. El watcher del SO només actua en mode Sistema. Dades: - GameMeta guarda topics i created_at, llegits de la resposta de Gitea que ja demanàvem (gratis, auto-sincronitzats). - games.toml: camps opcionals players i author per joc (la resta surt de Gitea). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,9 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QThreadPool, Qt, QTimer
|
||||
from PySide6.QtGui import QAction
|
||||
from PySide6.QtGui import QAction, QActionGroup
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QInputDialog,
|
||||
QLineEdit,
|
||||
QMainWindow,
|
||||
@@ -23,6 +24,7 @@ from .. import gitops
|
||||
from ..config import Config, Game
|
||||
from ..settings import load_settings, save_settings
|
||||
from ..workers import CheckUpdatesWorker, DownloadWorker, RunWorker
|
||||
from . import theme
|
||||
from .game_row import GameRow
|
||||
|
||||
APP_NAME = "Jail Launcher"
|
||||
@@ -46,6 +48,13 @@ class MainWindow(QMainWindow):
|
||||
self.setWindowTitle(WINDOW_TITLE)
|
||||
self.resize(720, 640)
|
||||
|
||||
# Aplica el tema guardado (system/light/dark) i vigila els canvis del SO
|
||||
# només quan estem en mode 'system'.
|
||||
app = QApplication.instance()
|
||||
if app is not None:
|
||||
theme.apply_theme(app, self.settings.theme)
|
||||
theme.watch_system_theme(app, lambda: self.settings.theme == theme.THEME_SYSTEM)
|
||||
|
||||
self._build_menu()
|
||||
|
||||
splitter = QSplitter(Qt.Vertical)
|
||||
@@ -130,6 +139,9 @@ class MainWindow(QMainWindow):
|
||||
self.action_check_on_start.toggled.connect(self._on_toggle_check_on_start)
|
||||
menu.addAction(self.action_check_on_start)
|
||||
|
||||
menu.addSeparator()
|
||||
self._build_theme_menu(menu)
|
||||
|
||||
menu.addSeparator()
|
||||
self.action_delete = QAction("Esborra un joc", self, checkable=True)
|
||||
self.action_delete.toggled.connect(self._set_delete_mode)
|
||||
@@ -140,6 +152,30 @@ class MainWindow(QMainWindow):
|
||||
self.action_token.triggered.connect(self._configure_token)
|
||||
menu.addAction(self.action_token)
|
||||
|
||||
def _build_theme_menu(self, parent_menu) -> None:
|
||||
"""Submenú Tema amb tres opcions exclusives: Sistema / Clar / Fosc."""
|
||||
submenu = parent_menu.addMenu("Tema")
|
||||
group = QActionGroup(self)
|
||||
group.setExclusive(True)
|
||||
options = [
|
||||
("Sistema", theme.THEME_SYSTEM),
|
||||
("Clar", theme.THEME_LIGHT),
|
||||
("Fosc", theme.THEME_DARK),
|
||||
]
|
||||
for label, mode in options:
|
||||
action = QAction(label, self, checkable=True)
|
||||
action.setChecked(self.settings.theme == mode)
|
||||
action.triggered.connect(lambda _checked, m=mode: self._on_theme_selected(m))
|
||||
group.addAction(action)
|
||||
submenu.addAction(action)
|
||||
|
||||
def _on_theme_selected(self, mode: str) -> None:
|
||||
self.settings.theme = mode
|
||||
save_settings(self.settings)
|
||||
app = QApplication.instance()
|
||||
if app is not None:
|
||||
theme.apply_theme(app, mode)
|
||||
|
||||
def _configure_token(self) -> None:
|
||||
token, ok = QInputDialog.getText(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user