add threading to applying

This commit is contained in:
leminlimez
2025-03-27 12:32:23 -04:00
parent 69ad97e5c4
commit 2010fb216b
5 changed files with 91 additions and 33 deletions

29
gui/apply_worker.py Normal file
View File

@@ -0,0 +1,29 @@
from PySide6.QtCore import Signal, QThread
from PySide6.QtWidgets import QMessageBox
class ApplyAlertMessage:
def __init__(self, txt: str, title: str = "Error!", icon = QMessageBox.Critical, detailed_txt: str = None):
self.txt = txt
self.title = title
self.icon = icon
self.detailed_txt = detailed_txt
class ApplyThread(QThread):
progress = Signal(str)
alert = Signal(ApplyAlertMessage)
def update_label(self, txt: str):
self.progress.emit(txt)
def alert_window(self, msg: ApplyAlertMessage):
self.alert.emit(msg)
def __init__(self, manager, resetting: bool = False):
super().__init__()
self.manager = manager
self.resetting = resetting
def do_work(self):
self.manager.apply_changes(self.resetting, self.update_label, self.alert_window)
def run(self):
self.do_work()