130 Zeilen
4.0 KiB
Python
130 Zeilen
4.0 KiB
Python
"""
|
|
Tab Navigation Component nach Styleguide
|
|
"""
|
|
|
|
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QLabel
|
|
from PyQt5.QtCore import pyqtSignal, Qt
|
|
from PyQt5.QtGui import QFont
|
|
|
|
|
|
class TabNavigation(QWidget):
|
|
"""
|
|
Tab-Navigation nach Styleguide mit zwei Modi:
|
|
- Plattformen (Standard)
|
|
- Accounts
|
|
"""
|
|
|
|
# Signal wird ausgelöst wenn Tab gewechselt wird (0=Plattformen, 1=Accounts)
|
|
tab_changed = pyqtSignal(int)
|
|
|
|
def __init__(self, language_manager=None):
|
|
super().__init__()
|
|
self.language_manager = language_manager
|
|
self.current_tab = 0
|
|
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"""
|
|
# Feste Höhe nach Styleguide
|
|
self.setFixedHeight(48)
|
|
|
|
# Basis-Styling
|
|
self.setStyleSheet("""
|
|
QWidget {
|
|
background-color: #FFFFFF;
|
|
border-bottom: 1px solid #E2E8F0;
|
|
}
|
|
""")
|
|
|
|
# Layout
|
|
layout = QHBoxLayout(self)
|
|
layout.setContentsMargins(40, 0, 40, 0)
|
|
layout.setSpacing(24)
|
|
|
|
# Tab Buttons erstellen
|
|
self.platform_tab = self._create_tab_button("Plattformen", True)
|
|
self.platform_tab.clicked.connect(lambda: self._on_tab_clicked(0))
|
|
layout.addWidget(self.platform_tab)
|
|
|
|
# Accounts Tab (ohne Badge)
|
|
self.accounts_tab = self._create_tab_button("Accounts", False)
|
|
self.accounts_tab.clicked.connect(lambda: self._on_tab_clicked(1))
|
|
layout.addWidget(self.accounts_tab)
|
|
|
|
# Spacer
|
|
layout.addStretch()
|
|
|
|
def _create_tab_button(self, text, active=False):
|
|
"""Erstellt einen Tab-Button nach Styleguide"""
|
|
btn = QPushButton(text)
|
|
btn.setCheckable(True)
|
|
btn.setChecked(active)
|
|
btn.setCursor(Qt.PointingHandCursor)
|
|
|
|
# Poppins Font
|
|
font = QFont("Poppins", 15)
|
|
font.setWeight(QFont.Medium)
|
|
btn.setFont(font)
|
|
|
|
btn.setStyleSheet("""
|
|
QPushButton {
|
|
background: transparent;
|
|
border: none;
|
|
border-bottom: 2px solid transparent;
|
|
padding: 12px 24px;
|
|
font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
font-size: 15px;
|
|
font-weight: 500;
|
|
color: #4A5568;
|
|
min-width: 100px;
|
|
}
|
|
QPushButton:checked {
|
|
color: #1A365D;
|
|
border-bottom-color: #3182CE;
|
|
}
|
|
QPushButton:hover:!checked {
|
|
color: #2D3748;
|
|
background-color: #F7FAFC;
|
|
}
|
|
QPushButton:pressed {
|
|
color: #1A365D;
|
|
}
|
|
""")
|
|
|
|
return btn
|
|
|
|
def _on_tab_clicked(self, index):
|
|
"""Behandelt Tab-Klicks"""
|
|
if self.current_tab != index:
|
|
self.current_tab = index
|
|
|
|
# Update button states
|
|
self.platform_tab.setChecked(index == 0)
|
|
self.accounts_tab.setChecked(index == 1)
|
|
|
|
# Emit signal
|
|
self.tab_changed.emit(index)
|
|
|
|
def set_active_tab(self, index):
|
|
"""Setzt den aktiven Tab programmatisch"""
|
|
self._on_tab_clicked(index)
|
|
|
|
def update_account_count(self, count):
|
|
"""Deprecated: Account-Anzahl wird nicht mehr im Tab angezeigt"""
|
|
pass
|
|
|
|
def update_texts(self):
|
|
"""Aktualisiert die Texte gemäß der aktuellen Sprache"""
|
|
if not self.language_manager:
|
|
return
|
|
|
|
self.platform_tab.setText(
|
|
self.language_manager.get_text("platform_selector.platforms_tab", "Plattformen")
|
|
)
|
|
self.accounts_tab.setText(
|
|
self.language_manager.get_text("platform_selector.accounts_tab", "Accounts")
|
|
) |