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" },