diff options
| author | Papoteur <papoteur@mageia.org> | 2025-05-30 14:53:56 +0200 |
|---|---|---|
| committer | Papoteur <papoteur@mageia.org> | 2025-06-11 08:24:27 +0200 |
| commit | 4aba503f8c64b1a0021bb4bc0f36acd04128361e (patch) | |
| tree | db7d4b9c87b4804c2545eb21277a40deee8102d3 /src | |
| parent | cd8b9b78c38e9555aaeb4157e5ac648ac7285653 (diff) | |
| download | mageiawelcome-4aba503f8c64b1a0021bb4bc0f36acd04128361e.tar mageiawelcome-4aba503f8c64b1a0021bb4bc0f36acd04128361e.tar.gz mageiawelcome-4aba503f8c64b1a0021bb4bc0f36acd04128361e.tar.bz2 mageiawelcome-4aba503f8c64b1a0021bb4bc0f36acd04128361e.tar.xz mageiawelcome-4aba503f8c64b1a0021bb4bc0f36acd04128361e.zip | |
Allow resizing
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui.py | 100 |
1 files changed, 73 insertions, 27 deletions
@@ -182,10 +182,12 @@ class SlidePage(QWidget, Commands): super().__init__() # Stocker le titre pour référence - self.title = title + self.title = title def paintEvent(self, event): painter = QPainter(self) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) + gradient = QLinearGradient(0, 0, 0, self.height()) gradient.setColorAt(0.0, QColor("#262F45")) gradient.setColorAt(1.0, QColor("#2397D4")) @@ -194,8 +196,10 @@ class SlidePage(QWidget, Commands): painter.drawRect(self.rect()) def resizeEvent(self, event): - self.paintEvent(event) - + """Gère le redimensionnement de la slide""" + super().resizeEvent(event) + # Forcer le repaint pour les gradients + self.update() class Links(SlidePage): """Widget pour une page individuelle du diaporama""" @@ -1082,15 +1086,16 @@ class BreadcrumbItem(QWidget): QWidget:hover { background-color: #2397D4; border-radius: 5px; - min-height: 30px; } QLabel { color: white; font-size: 14px; + min-height: 30px; } """ ) + else: if self.active: self.setStyleSheet( @@ -1204,6 +1209,20 @@ class SlideShowWidget(QStackedWidget): # Fil d'Ariane associé self.breadcrumb = None self.admin_rights = [] + self.slides = [] + + + def resizeEvent(self, event): + """Gère le redimensionnement du widget de slideshow""" + super().resizeEvent(event) # Appeler d'abord la méthode parent + + for i in range(self.count()): + widget = self.widget(i) + if widget: + widget.setGeometry(0, 0, event.size().width(), event.size().height()) + # Déclencher le repaint pour les slides avec gradient + if hasattr(widget, 'update'): + widget.update() def set_breadcrumb(self, breadcrumb): """Associe un fil d'Ariane au diaporama""" @@ -1212,6 +1231,7 @@ class SlideShowWidget(QStackedWidget): def add_slide(self, slide, admin_rights=False): """Ajoute une diapositive au diaporama""" + self.slides.append(slide) self.addWidget(slide) if self.breadcrumb: width = self.breadcrumb.add_item(slide.title, self.count() - 1) @@ -1332,6 +1352,44 @@ class SlideShowWidget(QStackedWidget): # used to display note at bottom self.admin_widget = admin_widget +class Banner(QLabel): + def __init__(self): + super().__init__() + + def resizeEvent(self, event): + size = event.size() + # if the width of the picture matches the one of banner, we can't reduce the size of the window + new_picture = self.createGradientBanner(size.width() - 4, 120) + self.setPixmap(QPixmap.fromImage(new_picture)) + self.setAlignment(Qt.AlignmentFlag.AlignCenter) + super().resizeEvent(event) + + def resizeEvent(self, event): + """Redimensionne la bannière en fonction de la taille de la fenêtre""" + size = event.size() + new_picture = self.createGradientBanner(size.width() - 4, 120) + self.setPixmap(QPixmap.fromImage(new_picture)) + self.setAlignment(Qt.AlignmentFlag.AlignCenter) + super().resizeEvent(event) + + def createGradientBanner(self, width, height): + image = QImage(width, height, QImage.Format.Format_ARGB32) + image.fill(QColorConstants.Transparent) + + painter = QPainter(image) + logo = QPixmap("img/mageia-2013-black-alpha.png") + gradient = QLinearGradient(0, 0, width, 0) + gradient.setColorAt(0.0, QColorConstants.Svg.lightgray) + gradient.setColorAt(1.0, QColorConstants.White) + + painter.fillRect(0, 0, width, height, gradient) + painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_SourceOver) + painter.drawPixmap( + QPoint((width - logo.width()) // 2, (height - logo.height()) // 2), logo + ) + painter.end() + + return image class SlideShowApp(QMainWindow): """Application principale de diaporama""" @@ -1340,15 +1398,14 @@ class SlideShowApp(QMainWindow): super().__init__() #: the application title self.setWindowTitle( _("Welcome", "Welcome to Mageia")) + self.setMinimumSize(DEFAULT_WIDTH, 600) # Taille minimale self.setGeometry(100, 100, 100 + DEFAULT_WIDTH, 700) - + # central Widget central_widget = QWidget() main_layout = QGridLayout(central_widget) main_layout.setContentsMargins(0, 0, 0, 0) - banner = QLabel() - picture = self.createGradientBanner(self.width(), 120) - banner.setPixmap(QPixmap.fromImage(picture)) + banner = Banner() main_layout.addWidget(banner, 0, 0) # Créer le fil d'Ariane @@ -1417,31 +1474,20 @@ class SlideShowApp(QMainWindow): user = pwd.getpwuid(os.getuid())[0] # login return user - def createGradientBanner(self, width, height): - image = QImage(width, height, QImage.Format.Format_ARGB32) - image.fill(QColorConstants.Transparent) - - painter = QPainter(image) - logo = QPixmap("img/mageia-2013-black-alpha.png") - gradient = QLinearGradient(0, 0, width, 0) - gradient.setColorAt(0.0, QColorConstants.Svg.lightgray) - gradient.setColorAt(1.0, QColorConstants.White) - - painter.fillRect(0, 0, width, height, gradient) - painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_SourceOver) - painter.drawPixmap( - QPoint((width - logo.width()) // 2, (height - logo.height()) // 2), logo - ) - painter.end() - - return image - def toogle_start(self): if self.cb_launch.isChecked(): self.autostart.enable() else: self.autostart.disable() + def resizeEvent(self, event): + """Gère le redimensionnement de la fenêtre principale""" + super().resizeEvent(event) + + # S'assurer que tous les composants sont redimensionnés correctement + if hasattr(self, 'slideshow'): + # Propager l'événement de redimensionnement au slideshow + self.slideshow.resizeEvent(event) if __name__ == "__main__": app = QApplication(sys.argv) |
