63 Zeilen
2.1 KiB
Python
63 Zeilen
2.1 KiB
Python
# 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(12, 12, 12, 12)
|
|
|
|
# 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)
|
|
# Set object name for QSS targeting
|
|
self.icon_button.setObjectName("platform_icon_button")
|
|
|
|
# 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)
|
|
# Set object name for QSS targeting
|
|
self.name_label.setObjectName("platform_name_label")
|
|
|
|
# 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;") |