Fix config admin — layout grid + scroll, plus de chevauchement
- Remplacé GroupBox/FormLayout par QGridLayout compact - Ajout QScrollArea pour les petits écrans - Dialog prend la taille du parent - Titres de section colorés, inputs stylés Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from PyQt6.QtWidgets import (
|
from PyQt6.QtWidgets import (
|
||||||
QDialog, QVBoxLayout, QHBoxLayout, QFormLayout,
|
QDialog, QVBoxLayout, QHBoxLayout, QGridLayout,
|
||||||
QLineEdit, QPushButton, QLabel, QComboBox, QGroupBox
|
QLineEdit, QPushButton, QLabel, QComboBox, QScrollArea, QWidget
|
||||||
)
|
)
|
||||||
from PyQt6.QtCore import Qt
|
from PyQt6.QtCore import Qt
|
||||||
from PyQt6.QtGui import QFont
|
from PyQt6.QtGui import QFont
|
||||||
@@ -42,89 +42,133 @@ def save_config(config):
|
|||||||
|
|
||||||
|
|
||||||
class ConfigDialog(QDialog):
|
class ConfigDialog(QDialog):
|
||||||
"""Panneau de configuration admin."""
|
"""Panneau de configuration admin — plein écran, responsive."""
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.setWindowTitle("Configuration — Admin")
|
self.setWindowTitle("Configuration — Admin")
|
||||||
self.setMinimumSize(500, 450)
|
|
||||||
self.config = load_config()
|
self.config = load_config()
|
||||||
self._setup_ui()
|
self._setup_ui()
|
||||||
|
|
||||||
|
def showEvent(self, event):
|
||||||
|
super().showEvent(event)
|
||||||
|
# Prendre toute la taille du parent
|
||||||
|
if self.parent():
|
||||||
|
self.resize(self.parent().size())
|
||||||
|
|
||||||
|
def _fs(self, pct):
|
||||||
|
"""Font size en % de la hauteur du dialogue."""
|
||||||
|
return max(8, int(self.height() * pct / 100)) if self.height() > 0 else 14
|
||||||
|
|
||||||
def _setup_ui(self):
|
def _setup_ui(self):
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
layout.setSpacing(15)
|
layout.setContentsMargins(20, 10, 20, 10)
|
||||||
|
layout.setSpacing(8)
|
||||||
|
|
||||||
# Titre
|
# Titre
|
||||||
title = QLabel("Configuration Photostation")
|
title = QLabel("Configuration Photostation")
|
||||||
title.setFont(QFont("", 20, QFont.Weight.Bold))
|
title.setFont(QFont("", 18, QFont.Weight.Bold))
|
||||||
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
layout.addWidget(title)
|
layout.addWidget(title)
|
||||||
|
|
||||||
# WiFi
|
# Scroll area pour le contenu
|
||||||
wifi_group = QGroupBox("WiFi (Hotspot)")
|
scroll = QScrollArea()
|
||||||
wifi_form = QFormLayout(wifi_group)
|
scroll.setWidgetResizable(True)
|
||||||
self.wifi_name_input = QLineEdit(self.config["wifi_ap_name"])
|
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||||
self.wifi_name_input.setFont(QFont("", 14))
|
scroll.setStyleSheet("QScrollArea { border: none; }")
|
||||||
self.wifi_name_input.setMinimumHeight(40)
|
|
||||||
wifi_form.addRow("Nom du réseau :", self.wifi_name_input)
|
|
||||||
self.wifi_pass_input = QLineEdit(self.config["wifi_ap_password"])
|
|
||||||
self.wifi_pass_input.setFont(QFont("", 14))
|
|
||||||
self.wifi_pass_input.setMinimumHeight(40)
|
|
||||||
wifi_form.addRow("Mot de passe :", self.wifi_pass_input)
|
|
||||||
layout.addWidget(wifi_group)
|
|
||||||
|
|
||||||
# QR Code
|
content = QWidget()
|
||||||
qr_group = QGroupBox("QR Code")
|
grid = QGridLayout(content)
|
||||||
qr_form = QFormLayout(qr_group)
|
grid.setSpacing(8)
|
||||||
self.upload_url_input = QLineEdit(self.config["upload_url"])
|
grid.setColumnStretch(0, 1)
|
||||||
self.upload_url_input.setFont(QFont("", 14))
|
grid.setColumnStretch(1, 2)
|
||||||
self.upload_url_input.setMinimumHeight(40)
|
|
||||||
qr_form.addRow("URL d'upload :", self.upload_url_input)
|
|
||||||
layout.addWidget(qr_group)
|
|
||||||
|
|
||||||
# Email
|
row = 0
|
||||||
email_group = QGroupBox("Email")
|
|
||||||
email_form = QFormLayout(email_group)
|
|
||||||
self.email_input = QLineEdit(self.config["email_address"])
|
|
||||||
self.email_input.setFont(QFont("", 14))
|
|
||||||
self.email_input.setMinimumHeight(40)
|
|
||||||
email_form.addRow("Adresse email :", self.email_input)
|
|
||||||
layout.addWidget(email_group)
|
|
||||||
|
|
||||||
# Imprimante
|
# ── WiFi ──
|
||||||
printer_group = QGroupBox("Impression")
|
wifi_title = QLabel("WiFi (Hotspot)")
|
||||||
printer_form = QFormLayout(printer_group)
|
wifi_title.setFont(QFont("", 13, QFont.Weight.Bold))
|
||||||
self.printer_input = QLineEdit(self.config["printer_name"])
|
wifi_title.setStyleSheet("color: #2196F3; padding-top: 5px;")
|
||||||
self.printer_input.setFont(QFont("", 14))
|
grid.addWidget(wifi_title, row, 0, 1, 2)
|
||||||
self.printer_input.setMinimumHeight(40)
|
row += 1
|
||||||
self.printer_input.setPlaceholderText("Nom CUPS (vide = par défaut)")
|
|
||||||
printer_form.addRow("Imprimante :", self.printer_input)
|
grid.addWidget(self._label("Nom du réseau :"), row, 0)
|
||||||
|
self.wifi_name_input = self._input(self.config["wifi_ap_name"])
|
||||||
|
grid.addWidget(self.wifi_name_input, row, 1)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
grid.addWidget(self._label("Mot de passe :"), row, 0)
|
||||||
|
self.wifi_pass_input = self._input(self.config["wifi_ap_password"])
|
||||||
|
grid.addWidget(self.wifi_pass_input, row, 1)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
# ── QR Code ──
|
||||||
|
qr_title = QLabel("QR Code")
|
||||||
|
qr_title.setFont(QFont("", 13, QFont.Weight.Bold))
|
||||||
|
qr_title.setStyleSheet("color: #2196F3; padding-top: 5px;")
|
||||||
|
grid.addWidget(qr_title, row, 0, 1, 2)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
grid.addWidget(self._label("URL d'upload :"), row, 0)
|
||||||
|
self.upload_url_input = self._input(self.config["upload_url"])
|
||||||
|
grid.addWidget(self.upload_url_input, row, 1)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
# ── Email ──
|
||||||
|
email_title = QLabel("Email")
|
||||||
|
email_title.setFont(QFont("", 13, QFont.Weight.Bold))
|
||||||
|
email_title.setStyleSheet("color: #2196F3; padding-top: 5px;")
|
||||||
|
grid.addWidget(email_title, row, 0, 1, 2)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
grid.addWidget(self._label("Adresse email :"), row, 0)
|
||||||
|
self.email_input = self._input(self.config["email_address"])
|
||||||
|
grid.addWidget(self.email_input, row, 1)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
# ── Impression ──
|
||||||
|
print_title = QLabel("Impression")
|
||||||
|
print_title.setFont(QFont("", 13, QFont.Weight.Bold))
|
||||||
|
print_title.setStyleSheet("color: #2196F3; padding-top: 5px;")
|
||||||
|
grid.addWidget(print_title, row, 0, 1, 2)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
grid.addWidget(self._label("Imprimante :"), row, 0)
|
||||||
|
self.printer_input = self._input(self.config["printer_name"], "Nom CUPS (vide = par défaut)")
|
||||||
|
grid.addWidget(self.printer_input, row, 1)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
grid.addWidget(self._label("Format par défaut :"), row, 0)
|
||||||
self.format_combo = QComboBox()
|
self.format_combo = QComboBox()
|
||||||
self.format_combo.setFont(QFont("", 14))
|
self.format_combo.setFont(QFont("", 12))
|
||||||
self.format_combo.setMinimumHeight(40)
|
self.format_combo.setMinimumHeight(35)
|
||||||
self.format_combo.addItems(["10x15 cm", "13x18 cm", "15x20 cm"])
|
self.format_combo.addItems(["10x15 cm", "13x18 cm", "15x20 cm"])
|
||||||
self.format_combo.setCurrentText(self.config["print_format"])
|
self.format_combo.setCurrentText(self.config["print_format"])
|
||||||
printer_form.addRow("Format par défaut :", self.format_combo)
|
grid.addWidget(self.format_combo, row, 1)
|
||||||
layout.addWidget(printer_group)
|
row += 1
|
||||||
|
|
||||||
# Boutons
|
scroll.setWidget(content)
|
||||||
|
layout.addWidget(scroll, 1)
|
||||||
|
|
||||||
|
# Boutons en bas
|
||||||
buttons = QHBoxLayout()
|
buttons = QHBoxLayout()
|
||||||
|
buttons.setSpacing(15)
|
||||||
|
|
||||||
cancel_btn = QPushButton("Annuler")
|
cancel_btn = QPushButton("Annuler")
|
||||||
cancel_btn.setFont(QFont("", 14))
|
cancel_btn.setFont(QFont("", 13))
|
||||||
cancel_btn.setMinimumHeight(50)
|
cancel_btn.setMinimumHeight(45)
|
||||||
cancel_btn.setStyleSheet("""
|
cancel_btn.setStyleSheet("""
|
||||||
QPushButton { background-color: #757575; color: white; border-radius: 10px; padding: 10px 30px; }
|
QPushButton { background-color: #757575; color: white; border-radius: 8px; padding: 8px 25px; }
|
||||||
QPushButton:pressed { background-color: #616161; }
|
QPushButton:pressed { background-color: #616161; }
|
||||||
""")
|
""")
|
||||||
cancel_btn.clicked.connect(self.reject)
|
cancel_btn.clicked.connect(self.reject)
|
||||||
buttons.addWidget(cancel_btn)
|
buttons.addWidget(cancel_btn)
|
||||||
|
|
||||||
save_btn = QPushButton("Enregistrer")
|
save_btn = QPushButton("Enregistrer")
|
||||||
save_btn.setFont(QFont("", 14, QFont.Weight.Bold))
|
save_btn.setFont(QFont("", 13, QFont.Weight.Bold))
|
||||||
save_btn.setMinimumHeight(50)
|
save_btn.setMinimumHeight(45)
|
||||||
save_btn.setStyleSheet("""
|
save_btn.setStyleSheet("""
|
||||||
QPushButton { background-color: #4CAF50; color: white; border-radius: 10px; padding: 10px 30px; }
|
QPushButton { background-color: #4CAF50; color: white; border-radius: 8px; padding: 8px 25px; }
|
||||||
QPushButton:pressed { background-color: #388E3C; }
|
QPushButton:pressed { background-color: #388E3C; }
|
||||||
""")
|
""")
|
||||||
save_btn.clicked.connect(self._save)
|
save_btn.clicked.connect(self._save)
|
||||||
@@ -132,6 +176,31 @@ class ConfigDialog(QDialog):
|
|||||||
|
|
||||||
layout.addLayout(buttons)
|
layout.addLayout(buttons)
|
||||||
|
|
||||||
|
def _label(self, text):
|
||||||
|
lbl = QLabel(text)
|
||||||
|
lbl.setFont(QFont("", 12))
|
||||||
|
lbl.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
|
||||||
|
return lbl
|
||||||
|
|
||||||
|
def _input(self, value, placeholder=""):
|
||||||
|
inp = QLineEdit(value)
|
||||||
|
inp.setFont(QFont("", 12))
|
||||||
|
inp.setMinimumHeight(35)
|
||||||
|
inp.setStyleSheet("""
|
||||||
|
QLineEdit {
|
||||||
|
border: 2px solid #ccc;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
QLineEdit:focus {
|
||||||
|
border-color: #2196F3;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
if placeholder:
|
||||||
|
inp.setPlaceholderText(placeholder)
|
||||||
|
return inp
|
||||||
|
|
||||||
def _save(self):
|
def _save(self):
|
||||||
self.config["wifi_ap_name"] = self.wifi_name_input.text()
|
self.config["wifi_ap_name"] = self.wifi_name_input.text()
|
||||||
self.config["wifi_ap_password"] = self.wifi_pass_input.text()
|
self.config["wifi_ap_password"] = self.wifi_pass_input.text()
|
||||||
|
|||||||
Reference in New Issue
Block a user