From 74b08e31c70470fca3d78a21801d1f8133cbd758 Mon Sep 17 00:00:00 2001 From: Vitali Graf Date: Sun, 31 May 2026 11:51:21 +0200 Subject: [PATCH] Version 1.7.1: Icon-System vereinfacht und gecacht MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - icons.py: _ICON_MAP entfernt (war reine Identitätsabbildung), Pfad wird direkt aus dem Namen abgeleitet - icons.py: Render-Cache mit Schlüssel (name, theme-farbe) ergänzt, vermeidet wiederholtes SVG-Rendering bei Baum-/Kontextmenü-Aufbau - icons.py: Qt-Ressourcen-Registrierung gekapselt (Import aus main.py hierher verschoben) - download_icons.py: toten folder-open-Eintrag entfernt (in Feather nicht vorhanden, nirgends genutzt) Co-Authored-By: Claude Opus 4.8 --- DocuMentor.wxs | 2 +- THIRD_PARTY_LICENSES.txt | 4 ++-- installer.iss | 2 +- pyproject.toml | 2 +- scripts/download_icons.py | 1 - src/icons.py | 39 ++++++++++++--------------------------- src/main.py | 3 --- uv.lock | 2 +- 8 files changed, 18 insertions(+), 37 deletions(-) diff --git a/DocuMentor.wxs b/DocuMentor.wxs index babbb0e..e7d754d 100644 --- a/DocuMentor.wxs +++ b/DocuMentor.wxs @@ -4,7 +4,7 @@ QIcon: """ - Lädt ein Icon aus dem Qt-Ressource-System und färbt es mit der aktuellen Palette-Farbe. + Lädt ein Feather-Icon aus dem Qt-Ressource-System und färbt es mit der aktuellen Palette-Farbe. Args: name: Feather-Icon-Name (z.B. "folder-plus", "settings") @@ -40,10 +23,7 @@ def icon(name: str) -> QIcon: Returns: QIcon in der Textfarbe des aktiven Themes, oder leerer QIcon bei unbekanntem Namen """ - path = _ICON_MAP.get(name) - if path is None: - logger.warning(f"Unbekannter Icon-Name: {name!r}") - return QIcon() + path = f":/icons/{name}.svg" app = QApplication.instance() if app is None: @@ -51,6 +31,10 @@ def icon(name: str) -> QIcon: color = app.palette().color(QPalette.ColorRole.WindowText).name().encode() + cache_key = (name, color) + if (cached := _ICON_CACHE.get(cache_key)) is not None: + return cached + f = QFile(path) if not f.open(QFile.OpenModeFlag.ReadOnly): logger.warning(f"Icon konnte nicht geöffnet werden: {path}") @@ -69,4 +53,5 @@ def icon(name: str) -> QIcon: painter.end() result.addPixmap(pixmap) + _ICON_CACHE[cache_key] = result return result diff --git a/src/main.py b/src/main.py index 1b7cdcd..86f3809 100644 --- a/src/main.py +++ b/src/main.py @@ -98,9 +98,6 @@ def main(): if icon_path.exists(): app.setWindowIcon(QIcon(str(icon_path))) - # Qt-Ressourcen registrieren (Icons) - import res.resources_rc # noqa: F401 - # Hauptfenster erstellen window = MainWindow() diff --git a/uv.lock b/uv.lock index 6a63f99..b6a2a85 100644 --- a/uv.lock +++ b/uv.lock @@ -39,7 +39,7 @@ wheels = [ [[package]] name = "documentor" -version = "1.7.0" +version = "1.7.1" source = { virtual = "." } dependencies = [ { name = "connectorx" },