Consola amb 3 estats (mostra/auto-amaga/amaga), animada i més alta

- Submenú Opcions > Consola: Mostra / Auto-amaga / Amaga, persistit a
  settings.json (console_mode). Es reemplaça el QSplitter per un panell
  col·lapsable amb alçada animada (QPropertyAnimation, easing InOutCubic) i
  més alçada (220px).
- Mode auto: la consola es desplega amb activitat (worker o nova línia de log)
  i es replega sola tras un marge sense activitat.
- Pills robustos al canvi de tema: color de text concret des de la paleta en
  comptes de palette(...) (que Qt cacheja), i pills_box sense fons propi perquè
  no pinti cap banda darrere.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 10:35:37 +02:00
parent 93efbb06c4
commit 962e5b054f
3 changed files with 151 additions and 15 deletions
+19 -4
View File
@@ -16,6 +16,7 @@ from pathlib import Path
from PySide6.QtCore import QRectF, Qt, Signal
from PySide6.QtGui import QPainter, QPainterPath, QPalette, QPixmap
from PySide6.QtWidgets import (
QApplication,
QFrame,
QHBoxLayout,
QLabel,
@@ -62,15 +63,26 @@ def _rounded_pixmap(src: QPixmap, size: int, radius: int) -> QPixmap:
return out
def _make_pill(text: str, fg: str = "palette(text)", bg: str = _NEUTRAL_BG,
def _palette_text_color() -> str:
"""Color de text actual de la paleta, com a rgb() concret (no 'palette(text)',
que Qt cacheja als stylesheets i no es refresca en canviar de tema)."""
c = QApplication.palette().color(QPalette.WindowText)
return f"rgb({c.red()}, {c.green()}, {c.blue()})"
def _make_pill(text: str, fg: str | None = None, bg: str = _NEUTRAL_BG,
bold: bool = False) -> QLabel:
"""Una 'pill' arrodonida amb fons translúcid; passiva al ratolí."""
"""Una 'pill' arrodonida amb fons translúcid; passiva al ratolí.
Sense `fg` explícit s'usa el color de text de la paleta vigent (pills neutres).
"""
pill = QLabel(text)
pill.setAttribute(Qt.WA_TransparentForMouseEvents)
weight = "600" if bold else "normal"
pill.setStyleSheet(
f"QLabel {{ background: {bg}; color: {fg}; border-radius: 9px; "
f"padding: 2px 8px; font-size: 11px; font-weight: {weight}; }}"
f"QLabel {{ background: {bg}; color: {fg or _palette_text_color()}; "
f"border-radius: 9px; padding: 2px 8px; font-size: 11px; "
f"font-weight: {weight}; }}"
)
return pill
@@ -119,6 +131,9 @@ class GameRow(QFrame):
self.pills_box = QWidget()
self.pills_layout = FlowLayout(self.pills_box, spacing=6)
self.pills_box.setAttribute(Qt.WA_TransparentForMouseEvents)
# Sense fons propi: que no pinti cap banda darrere dels pills.
self.pills_box.setAttribute(Qt.WA_NoSystemBackground, True)
self.pills_box.setAutoFillBackground(False)
sp = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sp.setHeightForWidth(True)
self.pills_box.setSizePolicy(sp)