From b6b957f83be9e040b25a671bcbbdffa944837169 Mon Sep 17 00:00:00 2001 From: Protonos Date: Sat, 9 Dec 2023 22:08:33 +0100 Subject: [PATCH] Background window management workarround --- main.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 980d7cb..75d5844 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ from components.dialog_windows import AfterInstall from werkzeug.wrappers import Request, Response from werkzeug.serving import run_simple -from windows_toasts import ToastActivatedEventArgs +from windows_toasts import ToastActivatedEventArgs, WindowsToaster, Toast, ToastButton, InteractableWindowsToaster initConfig() @@ -47,10 +47,13 @@ def __init__(self): print('Launching in debug mode...') if not "--startup" in sys.argv: - # if "--startup" in sys.argv: self.InitWindow() self.show() + else: + self.InitWindow() + self.show() + self.hide() # Add task tray icon which makes menu window visible on click self.tray = QSystemTrayIcon() menu = QMenu() @@ -60,7 +63,6 @@ def __init__(self): os.path.dirname(__file__), 'res', 'icon.png' ))) self.tray.setVisible(True) - # Check if window is visible and toggle visibility self.bt_master.clicked.connect(self.masterButton) self.bt_uninstall.clicked.connect(self.startRemoval) @@ -449,19 +451,29 @@ def run(self): # Checks if spicetify is ok +newToast = Toast(['Spicetify Manager']) +newToast.AddAction(ToastButton('Open Manager', 'response=manager')) + + def alertSpicetifyStatus(): status = spicetifyStatusCheck() - if status == 2: - spicetifyStatusToast( - 'A new version of Spicetify is available').on_activated = toast_callback + if status == 0: + print("A new version of Spicetify is available") + interactableToaster = InteractableWindowsToaster( + 'An update for spicetify is available') + interactableToaster.show_toast(newToast) elif status == 1: - spicetifyStatusToast( - 'Spicetify is not working correctly').on_activated = toast_callback + print("Spicetify is not working correctly") + interactableToaster = InteractableWindowsToaster( + 'Spicetify is not working correctly') + interactableToaster.show_toast(newToast) + +def activated_callback(activatedEventArgs: ToastActivatedEventArgs): + manager.show() -def toast_callback(activatedEventArgs: ToastActivatedEventArgs): - print('For some f***ing reason this is not working pls help') +newToast.on_activated = activated_callback # start the app manager = None