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. 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