From d7b4f3682c3dbff821f3af8ef77b9e6826948797 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 23 May 2021 22:28:02 +0200 Subject: [PATCH 1/2] gui_qt: show a message when hiding to tray --- plover/gui_qt/main_window.py | 8 +++++++- plover/gui_qt/trayicon.py | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plover/gui_qt/main_window.py b/plover/gui_qt/main_window.py index 5a1f25e68..e2e297633 100644 --- a/plover/gui_qt/main_window.py +++ b/plover/gui_qt/main_window.py @@ -143,6 +143,7 @@ def __init__(self, engine, use_qt_notifications): self.on_configure() # Apply configuration settings. config = self._engine.config + self._warn_on_hide_to_tray = not config['start_minimized'] self._update_machine(config['machine_type']) self._configured = False self.dictionaries.on_config_changed(config) @@ -274,7 +275,12 @@ def on_show(self): self._focus() def closeEvent(self, event): + event.ignore() self.hide() if not self._trayicon.is_enabled(): self._engine.quit() - event.ignore() + return + if not self._warn_on_hide_to_tray: + return + self._trayicon.show_message(_('Application is still running.')) + self._warn_on_hide_to_tray = False diff --git a/plover/gui_qt/trayicon.py b/plover/gui_qt/trayicon.py index d00e9a595..9dc4451ae 100644 --- a/plover/gui_qt/trayicon.py +++ b/plover/gui_qt/trayicon.py @@ -41,6 +41,12 @@ def set_menu(self, menu): if self._enabled: self._trayicon.setContextMenu(menu) + def show_message(self, message, + icon=QSystemTrayIcon.Information, + timeout=10000): + self._trayicon.showMessage(__software_name__.capitalize(), + message, icon, timeout) + def log(self, level, message): if self._enabled: if level <= log.INFO: @@ -52,8 +58,7 @@ def log(self, level, message): else: icon = QSystemTrayIcon.Critical timeout = 25 - self._trayicon.showMessage(__software_name__.capitalize(), - message, icon, timeout * 1000) + self.show_message(message, icon, timeout * 1000) else: if level <= log.INFO: icon = QMessageBox.Information From d502f4000903f2929cd3664e3e2b3c1a9b3e9cb8 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 23 May 2021 22:32:51 +0200 Subject: [PATCH 2/2] add news entry --- news.d/feature/1333.ui.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news.d/feature/1333.ui.md diff --git a/news.d/feature/1333.ui.md b/news.d/feature/1333.ui.md new file mode 100644 index 000000000..09155c645 --- /dev/null +++ b/news.d/feature/1333.ui.md @@ -0,0 +1 @@ +Show a message when hiding to tray.