Skip to content

Commit

Permalink
Merge pull request #8 from Teraskull/develop
Browse files Browse the repository at this point in the history
Update 1.4.0
  • Loading branch information
Teraskull authored Jun 2, 2020
2 parents ea42fa6 + e171033 commit 20e2142
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

## App limitations:

* It takes a few seconds to list all currently installed apps, due to the Windows PowerShell subprocesses.
* [FIXED] ~~It takes a few seconds to list all currently installed apps.~~
* [FIXED] ~~When uninstalling apps, PowerShell windows will open.~~
* You can only **uninstall** apps with this GUI, hence the name.
* You cannot uninstall other apps, for example Cortana, with this GUI, because PowerShell does not support it.
Expand Down
53 changes: 29 additions & 24 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import sys


app_version = "1.3.5"
__version__ = "1.4.0"


class Logic():
def __init__(self):
about.label_version.setText(f"Version {app_version}")
about.label_version.setText(f"Version {__version__}")
self.total_size = 0
self.checkbox_dict = {
ui.checkBox: "*Microsoft.3DBuilder*", ui.checkBox_2: "*Microsoft.Microsoft3DViewer*", ui.checkBox_3: "*Microsoft.WindowsAlarms*",
Expand Down Expand Up @@ -41,6 +41,7 @@ def __init__(self):
ui.checkBox_22: 16.62, ui.checkBox_23: 12.40, ui.checkBox_24: 30.59,
ui.checkBox_25: 35.02, ui.checkBox_26: 119.06, ui.checkBox_27: 64.59,
}
ui.progressbar.setMaximum(len(self.checkbox_dict))
ui.actionRefresh.triggered.connect(self.app_refresh)
ui.actionHomepage.triggered.connect(self.app_homepage)
ui.actionAbout.triggered.connect(self.app_about)
Expand All @@ -50,14 +51,19 @@ 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.checkbox_dict)

self.workerThread = QThread()
self.thread_list = []
for item, i in enumerate(self.checkbox_dict):
self.thread_list.append(CheckApps(self.checkbox_dict, i))
self.thread_list[item].moveToThread(self.workerThread)
self.thread_list[item].app_signal.connect(self.enable_installed)
self.thread_list[item].progress_signal.connect(self.update_progress)
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.progress = 0
for i in self.checkbox_dict:
i.setEnabled(False)
i.setChecked(False)
Expand All @@ -67,8 +73,9 @@ def app_refresh(self):
ui.button_deselect_all.setDisabled(True)
ui.button_uninstall.setDisabled(True)
QApplication.setOverrideCursor(QCursor(Qt.BusyCursor))
ui.label_info.setText('Updating list of installed apps...')
self.worker.start()
ui.label_info.setText('Refreshing list of installed apps...')
for new_thread in self.thread_list:
new_thread.start()

def thread_finished(self):
ui.progressbar.hide()
Expand All @@ -83,9 +90,11 @@ def enable_installed(self, i):
self.installed_apps.append(i)
self.enable_buttons()

@staticmethod
def update_progress(progress):
ui.progressbar.setValue(progress)
def update_progress(self):
self.progress += 1
ui.progressbar.setValue(self.progress)
if self.progress >= len(self.checkbox_dict):
self.thread_finished()

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


class Worker(QThread):
end_signal = pyqtSignal()
progress_signal = pyqtSignal(int)
class CheckApps(QThread):
progress_signal = pyqtSignal()
app_signal = pyqtSignal(object)

def __init__(self, checkbox_dict):
def __init__(self, checkbox_dict, i):
super().__init__()
self.checkbox_dict = checkbox_dict
self.i = i

def run(self):
progress = 100 / 27
for i in self.checkbox_dict:
x = subprocess.Popen(["powershell", f"(Get-AppxPackage {self.checkbox_dict[i]}) -and $?"], stdout=subprocess.PIPE, shell=True)
progress += 100 / 27
self.progress_signal.emit(int(progress))
if x.communicate()[0].decode().strip() == "True":
self.app_signal.emit(i)
self.end_signal.emit()
x = subprocess.Popen(["powershell", f"(Get-AppxPackage {self.checkbox_dict[self.i]}) -and $?"], stdout=subprocess.PIPE, shell=True)
if x.communicate()[0].decode().strip() == "True":
self.app_signal.emit(self.i)
self.progress_signal.emit()


if __name__ == '__main__':
Expand All @@ -175,6 +180,6 @@ def run(self):
about.setupUi()
ui = Ui_MainWindow()
ui.setupUi()
logic = Logic()
ui.show()
logic = Logic()
sys.exit(app.exec_())
2 changes: 1 addition & 1 deletion gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def retranslateUi(self):
self.actionQuit.setText(_translate("MainWindow", "&Quit"))
self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q"))

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

self.checkBox.setText(_translate("MainWindow", "3D Builder"))
self.checkBox_2.setText(_translate("MainWindow", "3D Viewer"))
Expand Down

0 comments on commit 20e2142

Please sign in to comment.