|
|
@@ -1,10 +1,93 @@
|
|
|
import os
|
|
|
-from PyQt6.QtWidgets import QLabel, QWidget, QVBoxLayout, QFrame, QProgressBar
|
|
|
+from PyQt6.QtWidgets import QLabel, QWidget, QVBoxLayout, QFrame, QProgressBar, QFileDialog
|
|
|
from PyQt6.QtGui import QPixmap, QPainter, QColor
|
|
|
from PyQt6.QtSvg import QSvgRenderer
|
|
|
from PyQt6.QtCore import Qt, QSize, QPointF, QTimer
|
|
|
|
|
|
|
|
|
+# ══════════════════════════════════════════════════════════════════
|
|
|
+# DIALOGUES FICHIERS (QFileDialog isolé du stylesheet parent)
|
|
|
+# ══════════════════════════════════════════════════════════════════
|
|
|
+
|
|
|
+_FILE_DIALOG_QSS = """
|
|
|
+ QDialog { background-color: #2b2b2b; color: #DCE4EE; }
|
|
|
+ QLabel { color: #DCE4EE; background: transparent; }
|
|
|
+ QLineEdit { background-color: #1a1a1a; color: #DCE4EE;
|
|
|
+ border: 1px solid #444; border-radius: 4px; padding: 4px;
|
|
|
+ selection-background-color: #1f538d; }
|
|
|
+ QListView, QTreeView { background-color: #1e1e1e; color: #DCE4EE;
|
|
|
+ border: 1px solid #333; outline: none; }
|
|
|
+ QListView::item, QTreeView::item { color: #DCE4EE; }
|
|
|
+ QListView::item:selected, QTreeView::item:selected { background-color: #1f538d; color: white; }
|
|
|
+ QListView::item:hover, QTreeView::item:hover { background-color: #333333; }
|
|
|
+ QHeaderView::section { background-color: #252525; color: #DCE4EE;
|
|
|
+ border: 1px solid #333; padding: 4px; }
|
|
|
+ QPushButton { background-color: #444444; color: #ffffff;
|
|
|
+ border: 1px solid #555; border-radius: 4px; padding: 5px 14px; }
|
|
|
+ QPushButton:hover { background-color: #555555; }
|
|
|
+ QPushButton:default { background-color: #1f538d; border-color: #2a6dbd; }
|
|
|
+ QComboBox { background-color: #1a1a1a; color: #DCE4EE;
|
|
|
+ border: 1px solid #444; border-radius: 4px; padding: 3px 8px; }
|
|
|
+ QComboBox QAbstractItemView { background-color: #1e1e1e; color: #DCE4EE;
|
|
|
+ selection-background-color: #1f538d;
|
|
|
+ border: 1px solid #444; }
|
|
|
+ QToolButton { background-color: #333333; color: #DCE4EE; border: none; border-radius: 4px; }
|
|
|
+ QToolButton:hover { background-color: #444444; }
|
|
|
+ QToolButton:checked { background-color: #1f538d; }
|
|
|
+ QSplitter::handle { background-color: #333333; }
|
|
|
+ QScrollBar:vertical, QScrollBar:horizontal { background: #202020; }
|
|
|
+ QScrollBar::handle:vertical, QScrollBar::handle:horizontal { background: #3e3e3e; border-radius: 3px; }
|
|
|
+ QScrollBar::add-line, QScrollBar::sub-line { height: 0; width: 0; }
|
|
|
+"""
|
|
|
+
|
|
|
+
|
|
|
+def _file_dialog(parent, title, default, name_filter, file_mode, accept_mode):
|
|
|
+ """
|
|
|
+ Construit un QFileDialog Qt-widget autonome.
|
|
|
+ Evite le dialogue natif Linux (portal D-Bus, instable sous XCB) et isole
|
|
|
+ le dialogue du stylesheet du parent (qui donnait un fond noir illisible).
|
|
|
+ """
|
|
|
+ dlg = QFileDialog(parent)
|
|
|
+ dlg.setFileMode(file_mode)
|
|
|
+ dlg.setAcceptMode(accept_mode)
|
|
|
+ dlg.setOption(QFileDialog.Option.DontUseNativeDialog, True)
|
|
|
+ if title:
|
|
|
+ dlg.setWindowTitle(title)
|
|
|
+ if name_filter:
|
|
|
+ dlg.setNameFilter(name_filter)
|
|
|
+ if default:
|
|
|
+ dlg.selectFile(default)
|
|
|
+ dlg.setStyleSheet(_FILE_DIALOG_QSS)
|
|
|
+
|
|
|
+ ok = dlg.exec()
|
|
|
+ selected = ""
|
|
|
+ if ok and dlg.selectedFiles():
|
|
|
+ selected = dlg.selectedFiles()[0]
|
|
|
+ return selected, dlg.selectedNameFilter()
|
|
|
+
|
|
|
+
|
|
|
+def get_open_file(parent, title="", directory="", filter_=""):
|
|
|
+ """Ouvre un sélecteur de fichier (widget Qt isolé). Retourne (path, selected_filter)."""
|
|
|
+ return _file_dialog(parent, title, directory, filter_,
|
|
|
+ QFileDialog.FileMode.ExistingFile,
|
|
|
+ QFileDialog.AcceptMode.AcceptOpen)
|
|
|
+
|
|
|
+
|
|
|
+def get_save_file(parent, title="", directory="", filter_=""):
|
|
|
+ """Ouvre un sélecteur d'enregistrement (widget Qt isolé). Retourne (path, selected_filter)."""
|
|
|
+ return _file_dialog(parent, title, directory, filter_,
|
|
|
+ QFileDialog.FileMode.AnyFile,
|
|
|
+ QFileDialog.AcceptMode.AcceptSave)
|
|
|
+
|
|
|
+
|
|
|
+def get_existing_directory(parent, title="", directory=""):
|
|
|
+ """Ouvre un sélecteur de dossier (widget Qt isolé)."""
|
|
|
+ path, _ = _file_dialog(parent, title, directory, "",
|
|
|
+ QFileDialog.FileMode.Directory,
|
|
|
+ QFileDialog.AcceptMode.AcceptOpen)
|
|
|
+ return path
|
|
|
+
|
|
|
+
|
|
|
# ══════════════════════════════════════════════════════════════════
|
|
|
# SVG / ICÔNES
|
|
|
# ══════════════════════════════════════════════════════════════════
|