Skip to content

Commit 20e2142

Browse files
authored
Merge pull request #8 from Teraskull/develop
Update 1.4.0
2 parents ea42fa6 + e171033 commit 20e2142

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
## App limitations:
4444

45-
* It takes a few seconds to list all currently installed apps, due to the Windows PowerShell subprocesses.
45+
* [FIXED] ~~It takes a few seconds to list all currently installed apps.~~
4646
* [FIXED] ~~When uninstalling apps, PowerShell windows will open.~~
4747
* You can only **uninstall** apps with this GUI, hence the name.
4848
* You cannot uninstall other apps, for example Cortana, with this GUI, because PowerShell does not support it.

app.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import sys
99

1010

11-
app_version = "1.3.5"
11+
__version__ = "1.4.0"
1212

1313

1414
class Logic():
1515
def __init__(self):
16-
about.label_version.setText(f"Version {app_version}")
16+
about.label_version.setText(f"Version {__version__}")
1717
self.total_size = 0
1818
self.checkbox_dict = {
1919
ui.checkBox: "*Microsoft.3DBuilder*", ui.checkBox_2: "*Microsoft.Microsoft3DViewer*", ui.checkBox_3: "*Microsoft.WindowsAlarms*",
@@ -41,6 +41,7 @@ def __init__(self):
4141
ui.checkBox_22: 16.62, ui.checkBox_23: 12.40, ui.checkBox_24: 30.59,
4242
ui.checkBox_25: 35.02, ui.checkBox_26: 119.06, ui.checkBox_27: 64.59,
4343
}
44+
ui.progressbar.setMaximum(len(self.checkbox_dict))
4445
ui.actionRefresh.triggered.connect(self.app_refresh)
4546
ui.actionHomepage.triggered.connect(self.app_homepage)
4647
ui.actionAbout.triggered.connect(self.app_about)
@@ -50,14 +51,19 @@ def __init__(self):
5051
ui.button_deselect_all.clicked.connect(self.deselect_all)
5152
for i in self.checkbox_dict:
5253
i.clicked.connect(self.enable_buttons)
53-
self.worker = Worker(self.checkbox_dict)
54+
55+
self.workerThread = QThread()
56+
self.thread_list = []
57+
for item, i in enumerate(self.checkbox_dict):
58+
self.thread_list.append(CheckApps(self.checkbox_dict, i))
59+
self.thread_list[item].moveToThread(self.workerThread)
60+
self.thread_list[item].app_signal.connect(self.enable_installed)
61+
self.thread_list[item].progress_signal.connect(self.update_progress)
5462
self.app_refresh()
55-
self.worker.finished.connect(self.thread_finished)
56-
self.worker.app_signal.connect(self.enable_installed)
57-
self.worker.progress_signal.connect(self.update_progress)
5863

5964
def app_refresh(self):
6065
self.installed_apps = []
66+
self.progress = 0
6167
for i in self.checkbox_dict:
6268
i.setEnabled(False)
6369
i.setChecked(False)
@@ -67,8 +73,9 @@ def app_refresh(self):
6773
ui.button_deselect_all.setDisabled(True)
6874
ui.button_uninstall.setDisabled(True)
6975
QApplication.setOverrideCursor(QCursor(Qt.BusyCursor))
70-
ui.label_info.setText('Updating list of installed apps...')
71-
self.worker.start()
76+
ui.label_info.setText('Refreshing list of installed apps...')
77+
for new_thread in self.thread_list:
78+
new_thread.start()
7279

7380
def thread_finished(self):
7481
ui.progressbar.hide()
@@ -83,9 +90,11 @@ def enable_installed(self, i):
8390
self.installed_apps.append(i)
8491
self.enable_buttons()
8592

86-
@staticmethod
87-
def update_progress(progress):
88-
ui.progressbar.setValue(progress)
93+
def update_progress(self):
94+
self.progress += 1
95+
ui.progressbar.setValue(self.progress)
96+
if self.progress >= len(self.checkbox_dict):
97+
self.thread_finished()
8998

9099
def enable_buttons(self):
91100
self.total_size = 0
@@ -149,24 +158,20 @@ def uninstall(self):
149158
QMessageBox.information(ui, 'PyDebloatX', f"Uninstalling {j} app{'s' if j > 1 else ''}.", QMessageBox.Ok)
150159

151160

152-
class Worker(QThread):
153-
end_signal = pyqtSignal()
154-
progress_signal = pyqtSignal(int)
161+
class CheckApps(QThread):
162+
progress_signal = pyqtSignal()
155163
app_signal = pyqtSignal(object)
156164

157-
def __init__(self, checkbox_dict):
165+
def __init__(self, checkbox_dict, i):
158166
super().__init__()
159167
self.checkbox_dict = checkbox_dict
168+
self.i = i
160169

161170
def run(self):
162-
progress = 100 / 27
163-
for i in self.checkbox_dict:
164-
x = subprocess.Popen(["powershell", f"(Get-AppxPackage {self.checkbox_dict[i]}) -and $?"], stdout=subprocess.PIPE, shell=True)
165-
progress += 100 / 27
166-
self.progress_signal.emit(int(progress))
167-
if x.communicate()[0].decode().strip() == "True":
168-
self.app_signal.emit(i)
169-
self.end_signal.emit()
171+
x = subprocess.Popen(["powershell", f"(Get-AppxPackage {self.checkbox_dict[self.i]}) -and $?"], stdout=subprocess.PIPE, shell=True)
172+
if x.communicate()[0].decode().strip() == "True":
173+
self.app_signal.emit(self.i)
174+
self.progress_signal.emit()
170175

171176

172177
if __name__ == '__main__':
@@ -175,6 +180,6 @@ def run(self):
175180
about.setupUi()
176181
ui = Ui_MainWindow()
177182
ui.setupUi()
178-
logic = Logic()
179183
ui.show()
184+
logic = Logic()
180185
sys.exit(app.exec_())

gui_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def retranslateUi(self):
137137
self.actionQuit.setText(_translate("MainWindow", "&Quit"))
138138
self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
139139

140-
self.label_info.setText(_translate("MainWindow", "Updating list of installed apps..."))
140+
self.label_info.setText(_translate("MainWindow", "Refreshing list of installed apps..."))
141141

142142
self.checkBox.setText(_translate("MainWindow", "3D Builder"))
143143
self.checkBox_2.setText(_translate("MainWindow", "3D Viewer"))

0 commit comments

Comments
 (0)