Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace "Installation Successful" dialog with text in installer window #386

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions Source/Installer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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()
Expand All @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
25 changes: 14 additions & 11 deletions Source/Installer/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -87,7 +87,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="640" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<view key="contentView" id="372">
<rect key="frame" x="0.0" y="0.0" width="640" height="360"/>
<autoresizingMask key="autoresizingMask"/>
Expand All @@ -97,7 +97,7 @@
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" id="vR5-yR-zjT">
<rect key="frame" x="1" y="1" width="583" height="249"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" importsGraphics="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="537">
<rect key="frame" x="0.0" y="0.0" width="583" height="249"/>
Expand All @@ -119,7 +119,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="575">
<button imageHugsTitle="YES" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="575">
<rect key="frame" x="460" y="12" width="166" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Agree and Install" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="576">
Expand All @@ -130,7 +130,7 @@
<action selector="agreeAndInstallAction:" target="494" id="708"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="592">
<button imageHugsTitle="YES" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="592">
<rect key="frame" x="330" y="12" width="130" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="593">
Expand All @@ -144,7 +144,7 @@ Gw
<action selector="cancelAction:" target="494" id="707"/>
</connections>
</button>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="623">
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="623">
<rect key="frame" x="17" y="323" width="559" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Welcome to the McBopomofo Installer! Please read the following Software Licence:" id="624">
Expand All @@ -153,7 +153,7 @@ Gw
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="688">
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="688">
<rect key="frame" x="17" y="19" width="337" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="By installing the software I agree to the terms above." id="689">
Expand All @@ -167,22 +167,25 @@ Gw
<connections>
<outlet property="delegate" destination="494" id="706"/>
</connections>
<point key="canvasLocation" x="128" y="-82"/>
</window>
<customObject id="494" customClass="AppDelegate">
<connections>
<outlet property="actionButton" destination="575" id="PpP-7z-w9u"/>
<outlet property="agreeText" destination="688" id="iFC-Cv-pu2"/>
<outlet property="cancelButton" destination="592" id="710"/>
<outlet property="installButton" destination="575" id="709"/>
<outlet property="progressIndicator" destination="deb-uT-yNv" id="Cpk-6Z-0rj"/>
<outlet property="progressSheet" destination="gHl-Hx-eQn" id="gD4-XO-YO1"/>
<outlet property="textView" destination="537" id="705"/>
<outlet property="welcomeText" destination="623" id="z8h-V3-Fjz"/>
<outlet property="window" destination="371" id="532"/>
</connections>
</customObject>
<customObject id="420" customClass="NSFontManager"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="gHl-Hx-eQn">
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="283" y="305" width="480" height="180"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
<view key="contentView" id="wAe-c8-Vh9">
<rect key="frame" x="0.0" y="0.0" width="480" height="180"/>
<autoresizingMask key="autoresizingMask"/>
Expand All @@ -191,7 +194,7 @@ Gw
<rect key="frame" x="20" y="67" width="440" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
</progressIndicator>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VDL-Yq-heb">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VDL-Yq-heb">
<rect key="frame" x="18" y="94" width="444" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Stopping the old version. This may take up to one minute…" id="nTo-dx-qfZ">
Expand Down
Loading