55 lines
1.9 KiB
Python

import sys
import app.utils.paths as paths
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QIcon
from app.ui.main_window import MainWindow
from app.ui.windows.splash_screen import SplashScreen
from app.core.main_manager import MainManager
def main() -> int:
main_manager: MainManager = MainManager.get_instance()
theme_manager = main_manager.get_theme_manager()
settings_manager = main_manager.get_settings_manager()
update_manager = main_manager.get_update_manager()
app: QApplication = QApplication(sys.argv)
app.setApplicationName(settings_manager.get_config("app_name"))
app.setWindowIcon(QIcon(paths.get_asset_path("icon")))
# Vérifier si l'image splash existe
splash_image_path = paths.get_asset_path(settings_manager.get_config("splash_image"))
use_splash = splash_image_path and paths.Path(splash_image_path).exists()
if use_splash:
# Créer et afficher le splash screen
splash = SplashScreen(duration=1500)
splash.show_splash()
# Vérifier les mises à jour en arrière-plan
if update_manager.check_for_update():
splash.close_splash()
return 0
# Créer la fenêtre principale
window: MainWindow = MainWindow()
# Connecter le signal finished pour afficher la fenêtre principale
def show_main_window():
splash.close()
window.show()
splash.finished.connect(show_main_window)
else:
# Pas de splash screen, vérifier directement les mises à jour
if update_manager.check_for_update():
return 0
# Créer et afficher directement la fenêtre principale
window: MainWindow = MainWindow()
window.show()
app.setStyleSheet(theme_manager.get_sheet())
return app.exec()
if __name__ == "__main__":
sys.exit(main())