# Path: views/widgets/platform_button.py """ Benutzerdefinierter Button für die Plattformauswahl. """ import os from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QLabel, QWidget from PyQt5.QtCore import QSize, Qt, pyqtSignal from PyQt5.QtGui import QIcon, QFont class PlatformButton(QWidget): """Angepasster Button-Widget für Plattformauswahl mit Icon.""" # Signal wenn geklickt clicked = pyqtSignal() def __init__(self, platform_name, icon_path=None, enabled=True): super().__init__() self.platform = platform_name.lower() self.setMinimumSize(200, 200) self.setEnabled(enabled) # Layout für den Container layout = QVBoxLayout(self) layout.setAlignment(Qt.AlignCenter) layout.setContentsMargins(10, 10, 10, 10) # Icon-Button self.icon_button = QPushButton() self.icon_button.setFlat(True) self.icon_button.setCursor(Qt.PointingHandCursor) # Icon setzen, falls vorhanden if icon_path and os.path.exists(icon_path): self.icon_button.setIcon(QIcon(icon_path)) self.icon_button.setIconSize(QSize(120, 120)) # Größeres Icon self.icon_button.setMinimumSize(150, 150) # Platform button styling based on Styleguide self.icon_button.setStyleSheet(""" QPushButton { background-color: #F5F7FF; border: 1px solid transparent; border-radius: 16px; padding: 32px; } QPushButton:hover { background-color: #E8EBFF; border: 1px solid #0099CC; } QPushButton:pressed { background-color: #DCE2FF; padding: 23px; } QPushButton:disabled { background-color: #F0F0F0; opacity: 0.5; } """) # Button-Signal verbinden self.icon_button.clicked.connect(self.clicked) # Name-Label self.name_label = QLabel(platform_name) self.name_label.setAlignment(Qt.AlignCenter) name_font = QFont() name_font.setPointSize(12) name_font.setBold(True) self.name_label.setFont(name_font) # Name label styling based on Styleguide self.name_label.setStyleSheet(""" QLabel { color: #232D53; font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-weight: 600; letter-spacing: 0.5px; } """) # Widgets zum Layout hinzufügen layout.addWidget(self.icon_button, 0, Qt.AlignCenter) layout.addWidget(self.name_label, 0, Qt.AlignCenter) # Styling für den deaktivierten Zustand if not enabled: self.setStyleSheet("opacity: 0.5;")