diff --git a/app/history_panel.py b/app/history_panel.py index c272bbf..ca309cb 100644 --- a/app/history_panel.py +++ b/app/history_panel.py @@ -282,6 +282,10 @@ def _setup_ui(self) -> None: self._btn_clear.clicked.connect(self._on_clear_clicked) header_row.addWidget(self._btn_clear) + self._btn_close = QPushButton(t("history.button.close")) + self._btn_close.clicked.connect(self.close) + header_row.addWidget(self._btn_close) + layout.addLayout(header_row) self._scroll = QScrollArea() @@ -304,6 +308,13 @@ def _setup_ui(self) -> None: self._empty_label.setProperty("role", "muted") self._list_layout.insertWidget(0, self._empty_label, 1) + def keyPressEvent(self, event) -> None: # noqa: N802 + if event.key() == Qt.Key.Key_Escape: + self.close() + event.accept() + return + super().keyPressEvent(event) + def add_entry(self, text: str, is_dictation: bool = False, source: Optional[str] = None) -> None: if not text or not text.strip(): return diff --git a/app/i18n.py b/app/i18n.py index 598d62a..3051edb 100644 --- a/app/i18n.py +++ b/app/i18n.py @@ -147,6 +147,7 @@ "history.tooltip.merge": "Alle Diktat-Einträge kombinieren, als Datei speichern und kopieren", "history.header": "Verlauf ({count})", "history.button.merge": "Zusammenführen", + "history.button.close": "Schließen", "history.button.clear_all": "Alles löschen", "history.button.confirm_clear": "Sicher?", "history.status.saved": "✓ Gespeichert", @@ -404,6 +405,7 @@ "history.tooltip.merge": "Combine all dictation entries, save as a file, and copy", "history.header": "History ({count})", "history.button.merge": "Merge", + "history.button.close": "Close", "history.button.clear_all": "Delete all", "history.button.confirm_clear": "Sure?", "history.status.saved": "✓ Saved", diff --git a/app/main_window.py b/app/main_window.py index a3f53d7..97c3ce0 100644 --- a/app/main_window.py +++ b/app/main_window.py @@ -233,6 +233,13 @@ def __init__(self, owner: "MainWindow") -> None: self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True) self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) + def keyPressEvent(self, event) -> None: # noqa: N802 + if event.key() == Qt.Key.Key_Escape: + self.hide() + event.accept() + return + super().keyPressEvent(event) + class MainWindow(QWidget): """One frameless surface with header, microphone, status and tools. @@ -688,6 +695,7 @@ def _on_discard_clicked(self) -> None: def _on_dictation_clicked(self) -> None: self._update_dictation_text() self._controller.set_dictation_mode(self._btn_dictation.isChecked()) + self._options_popup.hide() def update_state(self, state: str, workflow: Optional[WorkflowType], error: Optional[str]) -> None: self._state = state