From b77609cb5f885a18d6d4bd0ffe261bad569017c6 Mon Sep 17 00:00:00 2001
From: Boris Yumankulov <boria138@altlinux.org>
Date: Sun, 15 Jun 2025 22:51:50 +0500
Subject: [PATCH] fix: resolve Pyright type errors

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
---
 portprotonqt/app.py  | 11 +++++------
 portprotonqt/tray.py | 11 ++++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/portprotonqt/app.py b/portprotonqt/app.py
index e475b85..071955d 100644
--- a/portprotonqt/app.py
+++ b/portprotonqt/app.py
@@ -29,12 +29,10 @@ def main():
     else:
         logger.error(f"Qt translations for {system_locale.name()} not found in {translations_path}")
 
-    # Парсинг аргументов командной строки
     args = parse_args()
 
     window = MainWindow()
 
-    # Обработка флага --fullscreen
     if args.fullscreen:
         logger.info("Launching in fullscreen mode due to --fullscreen flag")
         save_fullscreen_config(True)
@@ -53,18 +51,19 @@ def main():
             tray = None
         current_theme = read_theme_from_config()
         tray = SystemTray(app, current_theme)
-        tray.show_action.triggered.connect(window.show)
-        tray.hide_action.triggered.connect(window.hide)
+        # Ensure window is not None before connecting signals
+        if window:
+            tray.show_action.triggered.connect(window.show)
+            tray.hide_action.triggered.connect(window.hide)
 
     def cleanup_on_exit():
         nonlocal tray, window
-        app.aboutToQuit.disconnect()  # Disconnect to prevent further calls
+        app.aboutToQuit.disconnect()
         if tray:
             tray.cleanup()
             tray = None
         if window:
             window.close()
-            window = None
         app.quit()
 
     window.settings_saved.connect(recreate_tray)
diff --git a/portprotonqt/tray.py b/portprotonqt/tray.py
index 281c790..7c68fb3 100644
--- a/portprotonqt/tray.py
+++ b/portprotonqt/tray.py
@@ -35,14 +35,15 @@ class SystemTray:
         """Скрыть иконку трея"""
         if self.tray:
             self.tray.setVisible(False)
-            self.tray.setContextMenu(None)
+            if self.menu:
+                self.menu.deleteLater()
+                self.menu = None
 
     def cleanup(self):
         """Очистка ресурсов трея"""
-        self.hide_tray()
+        if self.tray:
+            self.tray.setVisible(False)
+            self.tray = None
         if self.menu:
             self.menu.deleteLater()
             self.menu = None
-        if self.tray:
-            self.tray.deleteLater()
-            self.tray = None