From c03aa8f1663ab4cb59e11426920683c88bc827ad Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 20 Aug 2026 13:18:08 +0900 Subject: [PATCH] feat: delete shortcut --- dzgui/api/shortcuts.py | 7 ++++--- dzgui/views/dialogs/uninstall.py | 29 ++++++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/dzgui/api/shortcuts.py b/dzgui/api/shortcuts.py index 50c1d33..594d1a1 100644 --- a/dzgui/api/shortcuts.py +++ b/dzgui/api/shortcuts.py @@ -161,9 +161,10 @@ class Shortcuts: return NEW_ENTRY def delete_shortcut(self, start_path: Path) -> None: - for s in self.shortcuts["shortcuts"]: - if self.shortcuts[s]["StartDir"] == str(start_path): - del self.shortcuts[s] + shortcuts = self.shortcuts["shortcuts"] + for s in shortcuts: + if shortcuts[s]["StartDir"] == str(start_path): + del shortcuts[s] break self.save_shortcuts() diff --git a/dzgui/views/dialogs/uninstall.py b/dzgui/views/dialogs/uninstall.py index a46513e..1e50129 100644 --- a/dzgui/views/dialogs/uninstall.py +++ b/dzgui/views/dialogs/uninstall.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from pathlib import Path @@ -9,6 +10,7 @@ from dzgui.const.constants import APP_NAME from dzgui.strings import uninstall from dzgui.util._json import read_json from dzgui.util.css import load_css +from dzgui.util.format import format_exception from dzgui.views.components.box import HBox from dzgui.views.dialogs.wizard import ScrolledWizardPage, CheckboxWithLabel @@ -179,27 +181,29 @@ class UninstallPage(ScrolledWizardPage): self.steam_path = Path(steam) return Path(steam) except Exception as e: - print(e) + print(format_exception(e)) return None def wipe_conf_file(self, box: CheckboxWithPath) -> None: if box.get_active(): path = box.get_conf_path() try: - # TODO: - # path.unlink() + if path.is_dir(): + shutil.rmtree(path) + else: + path.unlink() print(f"Deleted '{path}'") except Exception as e: - print(e) + print(format_exception(e)) def wipe_steam_shortcut(self) -> None: - # TODO: - pass - # try: - # shortcuts = Shortcuts(self.steam_path) - # shortcuts.delete_shortcut(self.share) - # except Exception as e: - # print(e) + if self.steam_path is None: + return + try: + shortcuts = Shortcuts(self.steam_path) + shortcuts.delete_shortcut(self.share) + except Exception as e: + print(format_exception(e)) def wipe_pyapp(self) -> None: if self.pyapp is None: @@ -212,8 +216,7 @@ class UninstallPage(ScrolledWizardPage): self.wipe_conf_file(box) if self.steam_box.get_active(): self.wipe_steam_shortcut() - # TODO: - # self.wipe_pyapp() + self.wipe_pyapp() pass