facebook-tool/gui/core/login_handle_dialog.py

45 lines
1.5 KiB
Python

# gui/dialogs/login_handle_dialog.py
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QProgressBar, QPushButton
from PyQt5.QtCore import QTimer, Qt
from gui.global_signals import global_signals
class LoginHandleDialog(QDialog):
def __init__(self, account_id=None, duration=10, parent=None):
super().__init__(parent)
self.account_id = account_id
self.duration = duration
self.elapsed = 0
self.setWindowTitle(f"Login Handle - Account {self.account_id}")
self.setFixedSize(300, 150)
layout = QVBoxLayout()
self.label = QLabel(f"Processing account_id={self.account_id}...")
self.label.setAlignment(Qt.AlignCenter)
layout.addWidget(self.label)
self.progress = QProgressBar()
self.progress.setRange(0, self.duration)
layout.addWidget(self.progress)
self.btn_cancel = QPushButton("Cancel")
self.btn_cancel.clicked.connect(self.reject)
layout.addWidget(self.btn_cancel)
self.setLayout(layout)
self.timer = QTimer(self)
self.timer.timeout.connect(self._update_progress)
self.timer.start(1000)
def _update_progress(self):
self.elapsed += 1
self.progress.setValue(self.elapsed)
if self.elapsed >= self.duration:
self.close()
def closeEvent(self, event):
"""Emit signal khi dialog đóng"""
global_signals.dialog_finished.emit(self.account_id)
super().closeEvent(event)