113 Zeilen
3.9 KiB
Python
113 Zeilen
3.9 KiB
Python
"""
|
|
Platform Grid View - Zeigt die Plattform-Kacheln in einem Grid
|
|
"""
|
|
|
|
import os
|
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QGridLayout, QLabel
|
|
from PyQt5.QtCore import pyqtSignal, Qt
|
|
from PyQt5.QtGui import QFont
|
|
|
|
from views.widgets.platform_button import PlatformButton
|
|
|
|
|
|
class PlatformGridView(QWidget):
|
|
"""
|
|
Grid-Ansicht der Plattform-Kacheln
|
|
Wiederverwendung der existierenden PlatformButton-Komponente
|
|
"""
|
|
|
|
# Signal wird ausgelöst, wenn eine Plattform ausgewählt wird
|
|
platform_selected = pyqtSignal(str)
|
|
|
|
def __init__(self, language_manager=None):
|
|
super().__init__()
|
|
self.language_manager = language_manager
|
|
self.init_ui()
|
|
|
|
if self.language_manager:
|
|
self.language_manager.language_changed.connect(self.update_texts)
|
|
self.update_texts()
|
|
|
|
def init_ui(self):
|
|
"""Initialisiert die UI nach Styleguide"""
|
|
# Hauptlayout mit Container-Padding
|
|
layout = QVBoxLayout(self)
|
|
layout.setContentsMargins(40, 40, 40, 40)
|
|
layout.setSpacing(32)
|
|
|
|
# Titel
|
|
self.title_label = QLabel("AccountForger")
|
|
self.title_label.setAlignment(Qt.AlignCenter)
|
|
self.title_label.setObjectName("platform_title")
|
|
|
|
# Poppins Font für Titel
|
|
title_font = QFont("Poppins", 32)
|
|
title_font.setBold(True)
|
|
self.title_label.setFont(title_font)
|
|
|
|
layout.addWidget(self.title_label)
|
|
|
|
# Container für Plattform-Grid
|
|
platforms_container = QWidget()
|
|
platforms_container.setObjectName("platforms_container") # For QSS targeting
|
|
grid_layout = QGridLayout(platforms_container)
|
|
grid_layout.setSpacing(24) # Styleguide Grid-Gap
|
|
|
|
# Definiere verfügbare Plattformen
|
|
platforms = [
|
|
{"name": "Instagram", "enabled": True},
|
|
{"name": "Facebook", "enabled": True},
|
|
{"name": "TikTok", "enabled": True},
|
|
{"name": "X", "enabled": True},
|
|
{"name": "VK", "enabled": True},
|
|
{"name": "OK.ru", "enabled": True},
|
|
{"name": "Gmail", "enabled": True}
|
|
]
|
|
|
|
# Icon-Pfade
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
parent_dir = os.path.dirname(os.path.dirname(current_dir))
|
|
icons_dir = os.path.join(parent_dir, "resources", "icons")
|
|
|
|
# Platziere Buttons in einem 2x4 Grid
|
|
for i, platform in enumerate(platforms):
|
|
row = i // 4
|
|
col = i % 4
|
|
|
|
# Icon-Pfad erstellen
|
|
platform_icon_name = platform['name'].lower()
|
|
if platform['name'] == "X":
|
|
platform_icon_name = "twitter"
|
|
elif platform['name'] == "OK.ru":
|
|
platform_icon_name = "ok"
|
|
icon_path = os.path.join(icons_dir, f"{platform_icon_name}.svg")
|
|
|
|
if not os.path.exists(icon_path):
|
|
icon_path = None
|
|
|
|
# Platform Button erstellen
|
|
button = PlatformButton(
|
|
platform["name"],
|
|
icon_path,
|
|
platform["enabled"]
|
|
)
|
|
|
|
# Signal verbinden
|
|
platform_signal_name = "x" if platform["name"] == "X" else platform["name"]
|
|
button.clicked.connect(
|
|
lambda checked=False, p=platform_signal_name: self.platform_selected.emit(p.lower())
|
|
)
|
|
|
|
grid_layout.addWidget(button, row, col, Qt.AlignCenter)
|
|
|
|
layout.addWidget(platforms_container)
|
|
layout.addStretch()
|
|
|
|
def update_texts(self):
|
|
"""Aktualisiert die Texte gemäß der aktuellen Sprache"""
|
|
if not self.language_manager:
|
|
return
|
|
|
|
self.title_label.setText(
|
|
self.language_manager.get_text("main.title", "AccountForger")
|
|
) |