Skip to content

Commit

Permalink
Merge pull request #1333 from benoit-pierre/fix_1280
Browse files Browse the repository at this point in the history
gui_qt: show a message when hiding to tray
  • Loading branch information
benoit-pierre authored Oct 9, 2021
2 parents cfe7900 + d502f40 commit b4860e7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions news.d/feature/1333.ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show a message when hiding to tray.
8 changes: 7 additions & 1 deletion plover/gui_qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
9 changes: 7 additions & 2 deletions plover/gui_qt/trayicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit b4860e7

Please sign in to comment.