From a59ac44f95bb4cb4a4460028fa9cc7198a2f6adc Mon Sep 17 00:00:00 2001 From: Steven Huang <140762048+shuang886@users.noreply.github.com> Date: Thu, 23 Nov 2023 08:58:53 -0800 Subject: [PATCH 1/3] replace "Installation Successful" dialog with text in installer window --- Source/Installer/AppDelegate.swift | 50 ++++++++++++++++++------ Source/Installer/Base.lproj/MainMenu.xib | 24 +++++++----- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/Source/Installer/AppDelegate.swift b/Source/Installer/AppDelegate.swift index f9c15eb90..dc23349ce 100644 --- a/Source/Installer/AppDelegate.swift +++ b/Source/Installer/AppDelegate.swift @@ -37,12 +37,14 @@ private let kTranslocationRemovalDeadline: TimeInterval = 60.0 @NSApplicationMain @objc (AppDelegate) class AppDelegate: NSWindowController, NSApplicationDelegate { - @IBOutlet weak private var installButton: NSButton! + @IBOutlet weak private var actionButton: NSButton! @IBOutlet weak private var cancelButton: NSButton! @IBOutlet private var textView: NSTextView! @IBOutlet weak private var progressSheet: NSWindow! @IBOutlet weak private var progressIndicator: NSProgressIndicator! - + @IBOutlet weak var welcomeText: NSTextField! + @IBOutlet weak var agreeText: NSTextField! + private var archiveUtil: ArchiveUtil? private var installingVersion = "" private var upgrading = false @@ -67,9 +69,9 @@ class AppDelegate: NSWindowController, NSApplicationDelegate { self.archiveUtil = ArchiveUtil(appName: kTargetBin, targetAppBundleName: kTargetBundle) _ = archiveUtil?.validateIfNotarizedArchiveExists() - cancelButton.nextKeyView = installButton - installButton.nextKeyView = cancelButton - if let cell = installButton.cell as? NSButtonCell { + cancelButton.nextKeyView = actionButton + actionButton.nextKeyView = cancelButton + if let cell = actionButton.cell as? NSButtonCell { window?.defaultButtonCell = cell } @@ -97,7 +99,7 @@ class AppDelegate: NSWindowController, NSApplicationDelegate { } if upgrading { - installButton.title = NSLocalizedString("Agree and Upgrade", comment: "") + actionButton.title = NSLocalizedString("Agree and Upgrade", comment: "") } window?.center() @@ -106,9 +108,15 @@ class AppDelegate: NSWindowController, NSApplicationDelegate { } @IBAction func agreeAndInstallAction(_ sender: AnyObject) { - cancelButton.isEnabled = false - installButton.isEnabled = false - removeThenInstallInputMethod() + if !agreeText.isHidden { + // user agreed to terms for install + cancelButton.isEnabled = false + actionButton.isEnabled = false + removeThenInstallInputMethod() + } else { + // installation was successful, user clicked [Ok] + endAppWithDelay() + } } @objc func timerTick(_ timer: Timer) { @@ -239,15 +247,33 @@ class AppDelegate: NSWindowController, NSApplicationDelegate { if warning { runAlertPanel(title: NSLocalizedString("Attention", comment: ""), message: NSLocalizedString("McBopomofo is upgraded, but please log out or reboot for the new version to be fully functional.", comment: ""), buttonTitle: NSLocalizedString("OK", comment: "")) + endAppWithDelay() } else { if !mainInputSourceEnabled && !isMacOS12OrAbove { runAlertPanel(title: NSLocalizedString("Warning", comment: ""), message: NSLocalizedString("Input method may not be fully enabled. Please enable it through System Preferences > Keyboard > Input Sources.", comment: ""), buttonTitle: NSLocalizedString("Continue", comment: "")) + endAppWithDelay() } else { - runAlertPanel(title: NSLocalizedString("Installation Successful", comment: ""), message: NSLocalizedString("McBopomofo is ready to use.", comment: ""), buttonTitle: NSLocalizedString("OK", comment: "")) + let headlineAttr = [ + NSAttributedString.Key.font : NSFont.boldSystemFont(ofSize: NSFont.systemFontSize * 1.3), + NSAttributedString.Key.foregroundColor : NSColor.textColor + ] + let bodyAttr = [ + NSAttributedString.Key.font : NSFont.systemFont(ofSize: NSFont.systemFontSize), + NSAttributedString.Key.foregroundColor : NSColor.textColor + ] + let message = NSMutableAttributedString(string: NSLocalizedString("Installation Successful", comment: ""), attributes: headlineAttr) + let details = NSAttributedString(string: NSLocalizedString("McBopomofo is ready to use.", comment: ""), attributes: bodyAttr) + message.append(NSAttributedString(string: "\n\n")) + message.append(details) + textView.textStorage?.setAttributedString(message) + + welcomeText.isHidden = true + agreeText.isHidden = true + cancelButton.isHidden = true + actionButton.title = NSLocalizedString("OK", comment: "") + actionButton.isEnabled = true } } - - endAppWithDelay() } func endAppWithDelay() { diff --git a/Source/Installer/Base.lproj/MainMenu.xib b/Source/Installer/Base.lproj/MainMenu.xib index 6664bcf16..9e80408af 100644 --- a/Source/Installer/Base.lproj/MainMenu.xib +++ b/Source/Installer/Base.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -87,7 +87,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -119,7 +119,7 @@ - - - + @@ -153,7 +153,7 @@ Gw - + @@ -167,14 +167,18 @@ Gw + + + + @@ -182,7 +186,7 @@ Gw - + @@ -191,7 +195,7 @@ Gw - + From 57c1dc3e00d9e7e1066e6b7a88ae752f2ee793d0 Mon Sep 17 00:00:00 2001 From: Steven Huang <140762048+shuang886@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:10:17 -0800 Subject: [PATCH 2/3] oops, leftover installButton reference --- Source/Installer/Base.lproj/MainMenu.xib | 1 - Source/Installer/zh-Hant.lproj/MainMenu.xib | 1 - 2 files changed, 2 deletions(-) diff --git a/Source/Installer/Base.lproj/MainMenu.xib b/Source/Installer/Base.lproj/MainMenu.xib index 9e80408af..34b65e7be 100644 --- a/Source/Installer/Base.lproj/MainMenu.xib +++ b/Source/Installer/Base.lproj/MainMenu.xib @@ -174,7 +174,6 @@ Gw - diff --git a/Source/Installer/zh-Hant.lproj/MainMenu.xib b/Source/Installer/zh-Hant.lproj/MainMenu.xib index 8577bad56..fac646921 100644 --- a/Source/Installer/zh-Hant.lproj/MainMenu.xib +++ b/Source/Installer/zh-Hant.lproj/MainMenu.xib @@ -171,7 +171,6 @@ Gw - From 353702c4b58529807582ae8c085e2e1fe0b5291a Mon Sep 17 00:00:00 2001 From: Steven Huang <140762048+shuang886@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:34:04 -0800 Subject: [PATCH 3/3] hook up actionButton, welcomeText, and agreeText --- Source/Installer/zh-Hant.lproj/MainMenu.xib | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/Installer/zh-Hant.lproj/MainMenu.xib b/Source/Installer/zh-Hant.lproj/MainMenu.xib index fac646921..3e4fba817 100644 --- a/Source/Installer/zh-Hant.lproj/MainMenu.xib +++ b/Source/Installer/zh-Hant.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -87,7 +87,7 @@ - + @@ -119,7 +119,7 @@ - - - + @@ -153,7 +153,7 @@ Gw - + @@ -170,10 +170,13 @@ Gw + + + @@ -181,7 +184,7 @@ Gw - + @@ -190,7 +193,7 @@ Gw - +