From 2960a4057ee8e2839e68b0b741998195616e5d28 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 31 Mar 2022 18:59:48 +0800 Subject: [PATCH] AppDelegate // Implement the Uninstallation feature. --- Source/Modules/AppDelegate.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Modules/AppDelegate.swift b/Source/Modules/AppDelegate.swift index e9dc35c9..7d69bd11 100644 --- a/Source/Modules/AppDelegate.swift +++ b/Source/Modules/AppDelegate.swift @@ -276,8 +276,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega } } + func selfUninstall() { + self.currentAlertType = "Uninstall" + let content = String(format: NSLocalizedString("This will remove vChewing Input Method from this user account, requiring your confirmation.", comment: "")) + ctlNonModalAlertWindow.shared.show(title: NSLocalizedString("Uninstallation", comment: ""), content: content, confirmButtonTitle: NSLocalizedString("OK", comment: ""), cancelButtonTitle: NSLocalizedString("Not Now", comment: ""), cancelAsDefault: false, delegate: self) + NSApp.setActivationPolicy(.accessory) + } + func ctlNonModalAlertWindowDidConfirm(_ controller: ctlNonModalAlertWindow) { switch self.currentAlertType { + case "Uninstall": + NSWorkspace.shared.openFile(mgrLangModel.dataFolderPath(isDefaultFolder: true), withApplication: "Finder") + IME.uninstall(isSudo: false, selfKill: true) case "Update": if let updateNextStepURL = self.updateNextStepURL { NSWorkspace.shared.open(updateNextStepURL)