Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions synodic_client/application/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from porringer.api import API, APIParameters
from porringer.schema import ListPluginsParameters, LocalConfiguration
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication

from synodic_client.application.screen.screen import Screen
Expand Down Expand Up @@ -42,14 +43,15 @@ def application() -> None:
app = QApplication([])
app.setQuitOnLastWindowClosed(False)

screen = Screen()
# Reduce CPU usage when idle - process events less aggressively
app.setAttribute(Qt.ApplicationAttribute.AA_CompressHighFrequencyEvents)

# Store tray screen as instance attribute using object.__setattr__
# to avoid type checking issues with dynamic attributes
tray_screen = TrayScreen(app, client, icon, screen.window)
object.__setattr__(app, 'tray', tray_screen)
_screen = Screen()
_tray = TrayScreen(app, client, icon, _screen.window)

app.exec_()
# sys.exit ensures proper cleanup and exit code propagation
# Leading underscore indicates references kept alive intentionally until exec() returns
sys.exit(app.exec())


if __name__ == '__main__':
Expand Down
21 changes: 17 additions & 4 deletions synodic_client/application/screen/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@ class MainWindow(QMainWindow):
def __init__(self) -> None:
"""Initialize the main window."""
super().__init__()
self.setWindowTitle('Synodic Client')

def show(self) -> None:
"""Show the window, initializing UI lazily on first show."""
# Future: Initialize heavy UI components here on first show
super().show()


class Screen:
"""Screen class for the Synodic Client application."""

def __init__(self):
"""Initialize the screen."""
self.window = MainWindow()
_window: MainWindow | None = None

@property
def window(self) -> MainWindow:
"""Lazily create the main window on first access.

self.window.setWindowTitle('Synodic Client')
Returns:
The MainWindow instance.
"""
if self._window is None:
self._window = MainWindow()
return self._window
2 changes: 1 addition & 1 deletion synodic_client/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def _apply_windows_update(self, current_exe: Path, new_exe: Path, backup_path: P
if sys.platform == 'win32':
# CREATE_NEW_CONSOLE = 0x00000200, DETACHED_PROCESS = 0x00000008
flags = 0x00000200 | 0x00000008

subprocess.Popen(
['cmd', '/c', str(script_path)],
creationflags=flags,
Expand Down
Loading