Thème couleur + logo + nom de la borne configurables
Config admin (section Apparence) : - Nom de la borne (remplace "Photostation") - Couleur du thème (hex) avec prévisualisation live - Logo enseigne (chemin image) Style : - Couleur primaire lue depuis la config (plus de #2196F3 en dur) - Fonction _darken() pour les variantes pressed/border Home screen : - Logo affiché à côté du titre - Titre = nom de la borne - Rafraîchissement après sauvegarde config Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -53,10 +53,24 @@ class HomeScreen(QWidget):
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
|
||||
# Titre (appui long 5s = config)
|
||||
self.title = LongPressLabel("Photostation", self._open_config)
|
||||
# Header : logo + titre (appui long 5s = config)
|
||||
header_layout = QHBoxLayout()
|
||||
header_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.logo_label = QLabel()
|
||||
self.logo_label.setFixedSize(60, 60)
|
||||
self.logo_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.logo_label.hide()
|
||||
header_layout.addWidget(self.logo_label)
|
||||
|
||||
station_name = self.config.get("station_name", "Photostation")
|
||||
self.title = LongPressLabel(station_name, self._open_config)
|
||||
self.title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
layout.addWidget(self.title)
|
||||
header_layout.addWidget(self.title)
|
||||
|
||||
layout.addLayout(header_layout)
|
||||
|
||||
self._load_logo()
|
||||
|
||||
# Zone switchable
|
||||
self.stack = QStackedWidget()
|
||||
@@ -488,10 +502,31 @@ class HomeScreen(QWidget):
|
||||
|
||||
# ─── Config ───
|
||||
|
||||
def _load_logo(self):
|
||||
"""Charge le logo depuis le chemin configuré."""
|
||||
logo_path = self.config.get("logo_path", "")
|
||||
if logo_path:
|
||||
import os
|
||||
if os.path.isfile(logo_path):
|
||||
pixmap = QPixmap(logo_path)
|
||||
if not pixmap.isNull():
|
||||
self.logo_label.setPixmap(
|
||||
pixmap.scaled(56, 56,
|
||||
Qt.AspectRatioMode.KeepAspectRatio,
|
||||
Qt.TransformationMode.SmoothTransformation)
|
||||
)
|
||||
self.logo_label.show()
|
||||
return
|
||||
self.logo_label.hide()
|
||||
|
||||
def _open_config(self):
|
||||
if ConfigDialog.open_config(self):
|
||||
self.config = load_config()
|
||||
self.title.setText(self.config.get("station_name", "Photostation"))
|
||||
self._load_logo()
|
||||
self._set_qr_button_icon()
|
||||
self._refresh_config_labels()
|
||||
self._apply_responsive_styles()
|
||||
|
||||
def _refresh_config_labels(self):
|
||||
self.config = load_config()
|
||||
|
||||
@@ -56,8 +56,27 @@ def btn_style(widget: QWidget, bg: str, pressed: str) -> str:
|
||||
"""
|
||||
|
||||
|
||||
def _get_theme_color():
|
||||
"""Charge la couleur du thème depuis la config."""
|
||||
try:
|
||||
from ui.widgets.config_dialog import load_config
|
||||
config = load_config()
|
||||
return config.get("theme_color", "#2196F3")
|
||||
except Exception:
|
||||
return "#2196F3"
|
||||
|
||||
|
||||
def _darken(hex_color, factor=0.8):
|
||||
"""Assombrit une couleur hex."""
|
||||
hex_color = hex_color.lstrip("#")
|
||||
r, g, b = int(hex_color[0:2], 16), int(hex_color[2:4], 16), int(hex_color[4:6], 16)
|
||||
r, g, b = int(r * factor), int(g * factor), int(b * factor)
|
||||
return f"#{r:02x}{g:02x}{b:02x}"
|
||||
|
||||
|
||||
def blue_btn(widget: QWidget) -> str:
|
||||
return btn_style(widget, "#2196F3", "#1976D2")
|
||||
color = _get_theme_color()
|
||||
return btn_style(widget, color, _darken(color))
|
||||
|
||||
|
||||
def green_btn(widget: QWidget) -> str:
|
||||
@@ -84,13 +103,14 @@ def highlight_box(widget: QWidget) -> str:
|
||||
r = scale(widget, Sizes.RADIUS)
|
||||
p = scale(widget, Sizes.PADDING)
|
||||
fs = scale(widget, Sizes.BODY_LARGE)
|
||||
color = _get_theme_color()
|
||||
return f"""
|
||||
QLabel {{
|
||||
background-color: #E3F2FD;
|
||||
border: 2px solid #2196F3;
|
||||
border: 2px solid {color};
|
||||
border-radius: {r}px;
|
||||
padding: {p}px;
|
||||
color: #1565C0;
|
||||
color: {_darken(color)};
|
||||
font-size: {fs}px;
|
||||
}}
|
||||
"""
|
||||
|
||||
@@ -15,6 +15,10 @@ CONFIG_PATH = os.path.join(
|
||||
)
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
# Apparence
|
||||
"theme_color": "#2196F3",
|
||||
"logo_path": "",
|
||||
"station_name": "Photostation",
|
||||
# WiFi hotspot
|
||||
"wifi_ap_name": "Photostation",
|
||||
"wifi_ap_password": "photo1234",
|
||||
@@ -164,6 +168,40 @@ class ConfigDialog(QDialog):
|
||||
|
||||
row = 0
|
||||
|
||||
# ── Apparence ──
|
||||
grid.addWidget(self._section_title("Apparence"), row, 0, 1, 2)
|
||||
row += 1
|
||||
|
||||
grid.addWidget(self._label("Nom de la borne :"), row, 0)
|
||||
self.station_name_input = self._input(self.config.get("station_name", "Photostation"))
|
||||
grid.addWidget(self.station_name_input, row, 1)
|
||||
row += 1
|
||||
|
||||
grid.addWidget(self._label("Couleur du thème :"), row, 0)
|
||||
color_row = QHBoxLayout()
|
||||
self.theme_color_input = self._input(self.config.get("theme_color", "#2196F3"), "#2196F3")
|
||||
self.theme_color_input.setMaximumWidth(120)
|
||||
self.color_preview = QLabel(" ")
|
||||
self.color_preview.setFixedSize(35, 35)
|
||||
self.color_preview.setStyleSheet(
|
||||
f"background: {self.config.get('theme_color', '#2196F3')}; border-radius: 6px;"
|
||||
)
|
||||
self.theme_color_input.textChanged.connect(
|
||||
lambda t: self.color_preview.setStyleSheet(f"background: {t}; border-radius: 6px;")
|
||||
)
|
||||
color_row.addWidget(self.theme_color_input)
|
||||
color_row.addWidget(self.color_preview)
|
||||
color_row.addStretch()
|
||||
color_container = QWidget()
|
||||
color_container.setLayout(color_row)
|
||||
grid.addWidget(color_container, row, 1)
|
||||
row += 1
|
||||
|
||||
grid.addWidget(self._label("Logo (chemin image) :"), row, 0)
|
||||
self.logo_path_input = self._input(self.config.get("logo_path", ""), "/chemin/vers/logo.png")
|
||||
grid.addWidget(self.logo_path_input, row, 1)
|
||||
row += 1
|
||||
|
||||
# ── WiFi ──
|
||||
grid.addWidget(self._section_title("WiFi (Hotspot)"), row, 0, 1, 2)
|
||||
row += 1
|
||||
@@ -335,6 +373,9 @@ class ConfigDialog(QDialog):
|
||||
layout.addLayout(buttons)
|
||||
|
||||
def _save(self):
|
||||
self.config["station_name"] = self.station_name_input.text()
|
||||
self.config["theme_color"] = self.theme_color_input.text()
|
||||
self.config["logo_path"] = self.logo_path_input.text()
|
||||
self.config["wifi_ap_name"] = self.wifi_name_input.text()
|
||||
self.config["wifi_ap_password"] = self.wifi_pass_input.text()
|
||||
self.config["server_ip"] = self.server_ip_input.text()
|
||||
|
||||
Reference in New Issue
Block a user