generated from LouisMazin/PythonApplicationTemplate
48 lines
1.7 KiB
Python
48 lines
1.7 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.setStyleSheet(theme_manager.get_sheet())
|
|
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()
|
|
|
|
# Connecter le signal finished pour créer et afficher la fenêtre principale
|
|
def show_main_window():
|
|
if update_manager.check_for_update():
|
|
app.quit()
|
|
return
|
|
window: MainWindow = MainWindow()
|
|
window.show()
|
|
|
|
splash.finished.connect(show_main_window)
|
|
else:
|
|
# Pas de splash screen, vérifier les mises à jour puis afficher la fenêtre principale
|
|
if update_manager.check_for_update():
|
|
return 0
|
|
window: MainWindow = MainWindow()
|
|
window.show()
|
|
|
|
return app.exec()
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main()) |