diff --git a/app.py b/app.py index f7997e8..e2a175e 100644 --- a/app.py +++ b/app.py @@ -8,13 +8,12 @@ import sys -app_version = "1.3.2" +app_version = "1.3.3" class Logic(): def __init__(self): about.label_version.setText(f"Version {app_version}") - self.installed_apps = [] self.checkbox_dict = { ui.checkBox: "*Microsoft.Microsoft3DViewer*", ui.checkBox_2: "*Microsoft.WindowsAlarms*", ui.checkBox_3: "*Microsoft.WindowsCalculator*", ui.checkBox_4: "*microsoft.windowscommunicationsapps*", ui.checkBox_5: "*Microsoft.WindowsCamera*", ui.checkBox_6: "*Microsoft.GetHelp*", @@ -37,12 +36,16 @@ def __init__(self): ui.button_deselect_all.clicked.connect(self.deselect_all) for i in self.checkbox_dict: i.clicked.connect(self.enable_buttons) - - self.worker = Worker() - self.worker.start() + self.worker = Worker(self.checkbox_dict) + self.app_refresh() self.worker.finished.connect(self.thread_finished) + self.worker.app_signal.connect(self.enable_installed) self.worker.progress_signal.connect(self.update_progress) + def app_refresh(self): + self.installed_apps = [] + self.worker.start() + def thread_finished(self): ui.progressbar.hide() ui.progressbar.setValue(0) @@ -50,8 +53,10 @@ def thread_finished(self): ui.label_info.setText('Select the default Windows 10 apps to uninstall:') ui.actionRefresh.setDisabled(False) self.enable_buttons() - for i in self.installed_apps: - i.setEnabled(True) + + def enable_installed(self, i): + self.installed_apps.append(i) + self.enable_buttons() @staticmethod def update_progress(progress): @@ -70,9 +75,6 @@ def enable_buttons(self): else: ui.button_select_all.setDisabled(False) - def app_refresh(self): - self.worker.start() - @staticmethod def app_homepage(): webbrowser.open_new('https://github.com/Teraskull/PyDebloatX') @@ -107,9 +109,9 @@ def uninstall(self): j += 1 buttonReply = QMessageBox.question(ui, 'PyDebloatX', f"Uninstall {j} selected app(s)?", QMessageBox.Yes | QMessageBox.No) if buttonReply == QMessageBox.Yes: - for i in self.checkbox_dict: + for i in self.installed_apps: if i.isChecked(): - subprocess.Popen(f'powershell Get-AppxPackage {self.checkbox_dict[i]} | Remove-AppxPackage') + subprocess.Popen(f"powershell (Get-AppxPackage {self.checkbox_dict[i]} | Remove-AppxPackage)") i.setChecked(False) i.setEnabled(False) self.deselect_all() @@ -119,9 +121,13 @@ def uninstall(self): class Worker(QThread): end_signal = pyqtSignal() progress_signal = pyqtSignal(int) + app_signal = pyqtSignal(object) + + def __init__(self, checkbox_dict): + super(Worker, self).__init__() + self.checkbox_dict = checkbox_dict def run(self): - logic.installed_apps = [] ui.progressbar.show() ui.actionRefresh.setDisabled(True) ui.button_select_all.setDisabled(True) @@ -129,14 +135,15 @@ def run(self): ui.button_uninstall.setDisabled(True) QApplication.setOverrideCursor(QCursor(Qt.BusyCursor)) progress = 100 / 27 - for i in logic.checkbox_dict: + for i in self.checkbox_dict: i.setEnabled(False) - for i in logic.checkbox_dict: - x = subprocess.Popen(["powershell", f"(Get-AppxPackage {logic.checkbox_dict[i]}) -and ($true)"], stdout=subprocess.PIPE).communicate()[0] + for i in self.checkbox_dict: + x = subprocess.Popen(["powershell", f"(Get-AppxPackage {self.checkbox_dict[i]}) -and $?"], stdout=subprocess.PIPE).communicate()[0] progress += 100 / 27 self.progress_signal.emit(int(progress)) if x.decode().strip() == "True": - logic.installed_apps.append(i) + i.setEnabled(True) + self.app_signal.emit(i) self.end_signal.emit()