Kompletter Rewrite
This commit is contained in:
105
serien_checker/ui/widgets.py
Normal file
105
serien_checker/ui/widgets.py
Normal file
@@ -0,0 +1,105 @@
|
||||
"""
|
||||
Custom widgets for Serien-Checker UI
|
||||
"""
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QVBoxLayout, QHBoxLayout, QLabel, QProgressBar,
|
||||
QPushButton, QTextEdit
|
||||
)
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
|
||||
class ProgressDialog(QDialog):
|
||||
"""Dialog showing progress for long-running operations"""
|
||||
|
||||
def __init__(self, parent, title: str = "Bitte warten..."):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle(title)
|
||||
self.setModal(True)
|
||||
self.setFixedSize(400, 150)
|
||||
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
|
||||
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
"""Initialize UI"""
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
# Status label
|
||||
self.status_label = QLabel("Initialisiere...")
|
||||
layout.addWidget(self.status_label)
|
||||
|
||||
# Progress bar
|
||||
self.progress_bar = QProgressBar()
|
||||
self.progress_bar.setRange(0, 100)
|
||||
self.progress_bar.setValue(0)
|
||||
layout.addWidget(self.progress_bar)
|
||||
|
||||
# Cancel button
|
||||
button_layout = QHBoxLayout()
|
||||
button_layout.addStretch()
|
||||
|
||||
self.cancel_btn = QPushButton("Abbrechen")
|
||||
self.cancel_btn.clicked.connect(self.reject)
|
||||
button_layout.addWidget(self.cancel_btn)
|
||||
|
||||
layout.addLayout(button_layout)
|
||||
|
||||
def set_progress(self, value: int, message: str = None):
|
||||
"""Update progress"""
|
||||
self.progress_bar.setValue(value)
|
||||
if message:
|
||||
self.status_label.setText(message)
|
||||
|
||||
def set_indeterminate(self):
|
||||
"""Set progress bar to indeterminate mode"""
|
||||
self.progress_bar.setRange(0, 0)
|
||||
|
||||
def set_determinate(self):
|
||||
"""Set progress bar to determinate mode"""
|
||||
self.progress_bar.setRange(0, 100)
|
||||
|
||||
|
||||
class UpdateResultDialog(QDialog):
|
||||
"""Dialog showing update results"""
|
||||
|
||||
def __init__(self, parent, stats: dict):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle("Update-Ergebnis")
|
||||
self.setModal(True)
|
||||
self.resize(450, 300)
|
||||
|
||||
self.init_ui(stats)
|
||||
|
||||
def init_ui(self, stats: dict):
|
||||
"""Initialize UI"""
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
# Title
|
||||
title = QLabel("Update abgeschlossen")
|
||||
title.setStyleSheet("font-weight: bold; font-size: 14px;")
|
||||
layout.addWidget(title)
|
||||
|
||||
# Results text
|
||||
results = QTextEdit()
|
||||
results.setReadOnly(True)
|
||||
|
||||
text = "Zusammenfassung:\n\n"
|
||||
text += f"Neue Staffeln: {stats.get('new_seasons', 0)}\n"
|
||||
text += f"Neue Folgen: {stats.get('new_episodes', 0)}\n"
|
||||
text += f"Aktualisierte Folgen: {stats.get('updated_episodes', 0)}\n"
|
||||
text += f"Unverändert: {stats.get('unchanged', 0)}\n"
|
||||
|
||||
results.setText(text)
|
||||
layout.addWidget(results)
|
||||
|
||||
# OK button
|
||||
button_layout = QHBoxLayout()
|
||||
button_layout.addStretch()
|
||||
|
||||
ok_btn = QPushButton("OK")
|
||||
ok_btn.clicked.connect(self.accept)
|
||||
ok_btn.setDefault(True)
|
||||
button_layout.addWidget(ok_btn)
|
||||
|
||||
layout.addLayout(button_layout)
|
||||
Reference in New Issue
Block a user