77from PyQt6 import QtWidgets
88from PyQt6 .QtGui import QPixmap , QColor , QPalette , QIcon , QPainter
99from PyQt6 .QtCore import Qt , QObject , QSize , QEvent , pyqtSignal , QPropertyAnimation , QEasingCurve , QTimer , QThread
10- from PyQt6 .QtWidgets import QTableWidget , QMessageBox , QDialog , QLineEdit , QPushButton , QCheckBox , QTableWidgetItem , QApplication , QMainWindow , QStackedWidget , QVBoxLayout , QScrollArea , QWidget , QGridLayout , QToolButton , QSplitter , QHBoxLayout , QLabel
10+ from PyQt6 .QtWidgets import QProgressBar , QSplashScreen , QMessageBox , QDialog , QLineEdit , QPushButton , QCheckBox , QTableWidgetItem , QApplication , QMainWindow , QStackedWidget , QVBoxLayout , QScrollArea , QWidget , QGridLayout , QToolButton , QSplitter , QHBoxLayout , QLabel
1111import vlc
1212from io import BytesIO
1313from functools import lru_cache
@@ -597,10 +597,20 @@ class SettingsDialog(QDialog):
597597 def __init__ (self , config , parent = None ):
598598 super ().__init__ (parent )
599599 self .setGeometry (400 , 400 , 400 , 100 )
600+ self .centerWindow ()
600601 self .config = config
601602 self .setWindowTitle ("Configuration" )
602603 self .setup_ui ()
603604
605+ def centerWindow (self ):
606+ # Obtenir la taille de l'écran depuis l'application
607+ screen = QApplication .primaryScreen ().geometry ()
608+ windowSize = self .geometry () # Obtient la taille de la fenêtre courante
609+ # Calculer la position x et y pour centrer la fenêtre
610+ x = int ((screen .width () - windowSize .width ()) / 2 )
611+ y = int ((screen .height () - windowSize .height ()) / 2 )
612+ self .setGeometry (x , y , windowSize .width (), windowSize .height ())
613+
604614 def setup_ui (self ):
605615 layout = QVBoxLayout (self )
606616
@@ -650,6 +660,7 @@ def __init__(self):
650660
651661 self .setWindowTitle ("App IPTV" )
652662 self .setGeometry (100 , 100 , 1200 , 800 )
663+ self .centerWindow ()
653664
654665 # Réglages et configurations
655666 self .config = load_config ()
@@ -732,6 +743,15 @@ def __init__(self):
732743 self .initUI ()
733744 self .setupClock ()
734745
746+ def centerWindow (self ):
747+ # Obtenir la taille de l'écran depuis l'application
748+ screen = QApplication .primaryScreen ().geometry ()
749+ windowSize = self .geometry () # Obtient la taille de la fenêtre courante
750+ # Calculer la position x et y pour centrer la fenêtre
751+ x = int ((screen .width () - windowSize .width ()) / 2 )
752+ y = int ((screen .height () - windowSize .height ()) / 2 )
753+ self .setGeometry (x , y , windowSize .width (), windowSize .height ())
754+
735755 def setup_ui (self ):
736756 # Bouton de configuration
737757 self .settings_button = QPushButton ("⚙️" )
@@ -1068,9 +1088,6 @@ def remove_epg_display_widget(self):
10681088 # Étape 4: Supprimer le widget
10691089 self .epg_table .deleteLater ()
10701090 self .epg_table = None
1071-
1072- # Nettoyer le layout qui contenait le widget si nécessaire
1073- self .epg_table .widget ().deleteLater ()
10741091
10751092 def togglePlayPause (self ):
10761093 if self .isPlaying :
@@ -1407,10 +1424,33 @@ def get_current_program(self, channel_uuid):
14071424
14081425 return program_name , program_desc , program_picture_url , program_start_date , program_duration
14091426
1410- if __name__ == "__main__" :
1411- os .environ ["QT_QPA_PLATFORM" ] = "xcb"
1412- app = QApplication ([])
1413- mainWindow = MainWindow ()
1427+ class CustomSplashScreen (QSplashScreen ):
1428+ def __init__ (self , pixmap , * args , ** kwargs ):
1429+ super (CustomSplashScreen , self ).__init__ (pixmap , * args , ** kwargs )
1430+ self .progressBar = QProgressBar (self )
1431+ self .progressBar .setGeometry (100 , 350 , 500 , 20 ) # Ajuster la position et la taille
1432+
1433+ def setProgress (self , value ):
1434+ self .progressBar .setValue (value )
1435+ QApplication .instance ().processEvents ()
1436+
1437+ def main ():
1438+ app = QApplication (sys .argv )
1439+ splash_pix = QPixmap ('./image/splash_screen.png' )
1440+ splash = CustomSplashScreen (splash_pix )
1441+ splash .show ()
1442+
1443+ # Simuler le chargement de l'application
1444+ for i in range (1 , 101 ):
1445+ splash .setProgress (i )
1446+ time .sleep (0.03 ) # Simuler le temps de chargement
1447+
1448+ mainWindow = MainWindow () # Supposons que vous avez une fenêtre principale
14141449 mainWindow .show ()
1450+ splash .finish (mainWindow )
14151451
1416- app .exec ()
1452+ sys .exit (app .exec ())
1453+
1454+ if __name__ == '__main__' :
1455+ os .environ ["QT_QPA_PLATFORM" ] = "xcb"
1456+ main ()
0 commit comments