diff --git a/app/blitztext_linux.py b/app/blitztext_linux.py index 5369c73..7ecc0b8 100644 --- a/app/blitztext_linux.py +++ b/app/blitztext_linux.py @@ -163,6 +163,14 @@ def create_help_label(text: str) -> QLabel: return label +def _apply_window_icon(window: QWidget) -> None: + """Set the branded window icon; failures are purely cosmetic and ignored.""" + try: + window.setWindowIcon(theme.create_app_icon()) + except Exception: # pragma: no cover - purely cosmetic + pass + + class SettingsDialog(QDialog): """Settings dialog for configuring BlitztextLinux.""" @@ -1360,10 +1368,7 @@ def _ensure_compose_window(self) -> ComposeWindow: if self._compose_window is None: window = ComposeWindow(self.llm_service, self.paste_service, self.config) window.prompt_saved.connect(self._on_custom_prompt_saved) - try: - window.setWindowIcon(theme.create_app_icon()) - except Exception: # pragma: no cover - rein kosmetisch - pass + _apply_window_icon(window) self._compose_window = window return self._compose_window @@ -1409,10 +1414,7 @@ def _on_history_count_changed(self, count: int) -> None: def _ensure_main_window(self) -> MainWindow: if self._main_window is None: window = MainWindow(self) - try: - window.setWindowIcon(theme.create_app_icon()) - except Exception: # pragma: no cover - rein kosmetisch - pass + _apply_window_icon(window) window.set_dictation_checked(self._dictation_mode) if self._history_panel is not None: window.set_history_count(self._history_panel.entry_count) diff --git a/app/hotkey_service.py b/app/hotkey_service.py index d255ed2..18c80b6 100644 --- a/app/hotkey_service.py +++ b/app/hotkey_service.py @@ -371,11 +371,7 @@ def _discover_keyboards(transcription_key: str = "KEY_LEFTALT") -> list: pass if devices: - for dev in fallback_candidates: - try: - dev.close() - except Exception: - pass + _close_devices(fallback_candidates) return devices if fallback_candidates: @@ -384,11 +380,7 @@ def _discover_keyboards(transcription_key: str = "KEY_LEFTALT") -> list: "Warning: no keyboard with Meta key found, falling back", file=sys.stderr, flush=True, ) - for dev in fallback_candidates[1:]: - try: - dev.close() - except Exception: - pass + _close_devices(fallback_candidates[1:]) return fallback_candidates[:1] return []