mirror of https://github.com/borgbase/vorta
Show/Hide the main window in KDE when clicking on the tray icon (#143)
This commit is contained in:
parent
3af27d9603
commit
2eac612bd7
|
@ -82,6 +82,12 @@ class VortaApp(QApplication):
|
|||
self.main_window.show()
|
||||
self.main_window.raise_()
|
||||
|
||||
def toggle_main_window_visibility(self):
|
||||
if self.main_window.isVisible():
|
||||
self.main_window.hide()
|
||||
else:
|
||||
self.open_main_window_action()
|
||||
|
||||
def backup_started_event_response(self):
|
||||
set_tray_icon(self.tray, active=True)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from PyQt5.QtWidgets import QMenu, QSystemTrayIcon
|
||||
|
||||
from .borg.borg_thread import BorgThread
|
||||
|
@ -16,9 +17,18 @@ class TrayMenu(QSystemTrayIcon):
|
|||
menu.aboutToShow.connect(self.on_user_click)
|
||||
|
||||
self.setContextMenu(menu)
|
||||
|
||||
self.activated.connect(self.on_activation)
|
||||
self.setVisible(True)
|
||||
self.show()
|
||||
|
||||
def on_activation(self, reason):
|
||||
if reason == QSystemTrayIcon.Trigger:
|
||||
if os.environ.get('XDG_CURRENT_DESKTOP', '') == 'KDE':
|
||||
self.app.toggle_main_window_visibility()
|
||||
else:
|
||||
self.on_user_click()
|
||||
|
||||
def on_user_click(self):
|
||||
"""Build system tray menu based on current state."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue