From 27d5b03321ad6128b8dfe7488521cc5893953220 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 12 Oct 2024 00:09:20 +0800 Subject: [PATCH 1/6] Terminate Xcodes app after last window closed --- Xcodes/XcodesApp.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Xcodes/XcodesApp.swift b/Xcodes/XcodesApp.swift index 74b3aef6..b4ac30ad 100644 --- a/Xcodes/XcodesApp.swift +++ b/Xcodes/XcodesApp.swift @@ -166,6 +166,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func applicationDidFinishLaunching(_: Notification) {} + + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + true + } } func localizeString(_ key: String, comment: String = "") -> String { From 3d5fdd528b41f761284e79cca5a0b5066e602979 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 13 Oct 2024 12:11:50 +0800 Subject: [PATCH 2/6] Replace WIndowGroup with Window to fix multi window and terminate issue --- Xcodes/XcodesApp.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Xcodes/XcodesApp.swift b/Xcodes/XcodesApp.swift index b4ac30ad..363c19b2 100644 --- a/Xcodes/XcodesApp.swift +++ b/Xcodes/XcodesApp.swift @@ -11,7 +11,7 @@ struct XcodesApp: App { @StateObject private var updater = ObservableUpdater() var body: some Scene { - WindowGroup("Xcodes") { + Window("Xcodes", id: "main") { MainWindow() .environmentObject(appState) .environmentObject(updater) @@ -166,10 +166,6 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func applicationDidFinishLaunching(_: Notification) {} - - func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - true - } } func localizeString(_ key: String, comment: String = "") -> String { From f8970f44d5a963242815c0171d81270444dbf23e Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 16 Oct 2024 14:02:55 +0800 Subject: [PATCH 3/6] Add TerminateAfterLastWindowClosed toggle support in Misc --- Xcodes/Backend/AppState.swift | 7 +++ .../Preferences/AdvancedPreferencePane.swift | 5 +++ Xcodes/Resources/Localizable.xcstrings | 44 +++++++++++++++++++ Xcodes/XcodesApp.swift | 4 ++ 4 files changed, 60 insertions(+) diff --git a/Xcodes/Backend/AppState.swift b/Xcodes/Backend/AppState.swift index 46a5d633..47c89dc3 100644 --- a/Xcodes/Backend/AppState.swift +++ b/Xcodes/Backend/AppState.swift @@ -104,6 +104,12 @@ class AppState: ObservableObject { } } + @Published var terminateAfterLastWindowClosed = false { + didSet { + Current.defaults.set(terminateAfterLastWindowClosed, forKey: "terminateAfterLastWindowClosed") + } + } + // MARK: - Runtimes @Published var downloadableRuntimes: [DownloadableRuntime] = [] @@ -173,6 +179,7 @@ class AppState: ObservableObject { onSelectActionType = SelectedActionType(rawValue: Current.defaults.string(forKey: "onSelectActionType") ?? "none") ?? .none installPath = Current.defaults.string(forKey: "installPath") ?? Path.defaultInstallDirectory.string showOpenInRosettaOption = Current.defaults.bool(forKey: "showOpenInRosettaOption") ?? false + terminateAfterLastWindowClosed = Current.defaults.bool(forKey: "terminateAfterLastWindowClosed") ?? false } // MARK: Timer diff --git a/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift b/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift index c9531c5c..77d2bf8e 100644 --- a/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift +++ b/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift @@ -151,6 +151,11 @@ struct AdvancedPreferencePane: View { } } .groupBoxStyle(PreferencesGroupBoxStyle()) + + GroupBox(label: Text("Misc")) { + Toggle("TerminateAfterLastWindowClosed", isOn: $appState.terminateAfterLastWindowClosed) + } + .groupBoxStyle(PreferencesGroupBoxStyle()) } } } diff --git a/Xcodes/Resources/Localizable.xcstrings b/Xcodes/Resources/Localizable.xcstrings index 6d61d71d..0d894408 100644 --- a/Xcodes/Resources/Localizable.xcstrings +++ b/Xcodes/Resources/Localizable.xcstrings @@ -14829,6 +14829,28 @@ } } }, + "Misc" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "杂项" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "雜項" + } + } + } + }, "Moving" : { "extractionState" : "manual", "localizations" : { @@ -20721,6 +20743,28 @@ } } }, + "TerminateAfterLastWindowClosed" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "在最后一个窗口关闭后终止App" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "在最後一個窗口關閉後終止 App" + } + } + } + }, "TrashingArchive" : { "extractionState" : "manual", "localizations" : { diff --git a/Xcodes/XcodesApp.swift b/Xcodes/XcodesApp.swift index 363c19b2..a7835dd6 100644 --- a/Xcodes/XcodesApp.swift +++ b/Xcodes/XcodesApp.swift @@ -166,6 +166,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func applicationDidFinishLaunching(_: Notification) {} + + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return Current.defaults.bool(forKey: "terminateAfterLastWindowClosed") ?? false + } } func localizeString(_ key: String, comment: String = "") -> String { From b91a7e53ad85be84e7756939b33e8f111e79ebdb Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 16 Oct 2024 21:46:04 +0800 Subject: [PATCH 4/6] Update the missing Localizable string --- Xcodes/Resources/Localizable.xcstrings | 208 ++++++++++++++++++++++++- 1 file changed, 206 insertions(+), 2 deletions(-) diff --git a/Xcodes/Resources/Localizable.xcstrings b/Xcodes/Resources/Localizable.xcstrings index 0d894408..15204e8b 100644 --- a/Xcodes/Resources/Localizable.xcstrings +++ b/Xcodes/Resources/Localizable.xcstrings @@ -14831,12 +14831,114 @@ }, "Misc" : { "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "ca" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "el" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, "en" : { "stringUnit" : { "state" : "translated", "value" : "Misc" } }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "fi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "hi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "pt-BR" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "ru" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, + "uk" : { + "stringUnit" : { + "state" : "translated", + "value" : "Misc" + } + }, "zh-Hans" : { "stringUnit" : { "state" : "translated", @@ -20745,21 +20847,123 @@ }, "TerminateAfterLastWindowClosed" : { "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "ca" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "el" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, "en" : { "stringUnit" : { "state" : "translated", "value" : "Terminate App after last window is closed" } }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "fi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "hi" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "pl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "pt-BR" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "ru" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "tr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, + "uk" : { + "stringUnit" : { + "state" : "translated", + "value" : "Terminate App after last window is closed" + } + }, "zh-Hans" : { "stringUnit" : { - "state" : "needs_review", + "state" : "translated", "value" : "在最后一个窗口关闭后终止App" } }, "zh-Hant" : { "stringUnit" : { - "state" : "needs_review", + "state" : "translated", "value" : "在最後一個窗口關閉後終止 App" } } From 3d6908f526235273a7c94117ad8bc3d45fb3de1e Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 16 Oct 2024 21:50:16 +0800 Subject: [PATCH 5/6] Fix Xcode warning for Localizable string --- Xcodes/Resources/Localizable.xcstrings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcodes/Resources/Localizable.xcstrings b/Xcodes/Resources/Localizable.xcstrings index 15204e8b..f1132cdd 100644 --- a/Xcodes/Resources/Localizable.xcstrings +++ b/Xcodes/Resources/Localizable.xcstrings @@ -8029,7 +8029,7 @@ "el" : { "stringUnit" : { "state" : "translated", - "value" : "Εισάγετε τον %2$d-ψήφιο κωδικού που εστάλη στο %2$@:" + "value" : "Εισάγετε τον %1$d-ψήφιο κωδικού που εστάλη στο %2$@:" } }, "en" : { From 59331bcb38085770868e982ae7e0158ed223f3cf Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 17 Oct 2024 00:32:56 +0800 Subject: [PATCH 6/6] Adjust TerminateAfterLastWindowClosed toggle location Move from advanced pane into general --- Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift | 5 ----- Xcodes/Frontend/Preferences/GeneralPreferencePane.swift | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift b/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift index 77d2bf8e..c9531c5c 100644 --- a/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift +++ b/Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift @@ -151,11 +151,6 @@ struct AdvancedPreferencePane: View { } } .groupBoxStyle(PreferencesGroupBoxStyle()) - - GroupBox(label: Text("Misc")) { - Toggle("TerminateAfterLastWindowClosed", isOn: $appState.terminateAfterLastWindowClosed) - } - .groupBoxStyle(PreferencesGroupBoxStyle()) } } } diff --git a/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift b/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift index 0e714e42..b15f5c6d 100644 --- a/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift +++ b/Xcodes/Frontend/Preferences/GeneralPreferencePane.swift @@ -20,6 +20,12 @@ struct GeneralPreferencePane: View { NotificationsView().environmentObject(appState) } .groupBoxStyle(PreferencesGroupBoxStyle()) + Divider() + + GroupBox(label: Text("Misc")) { + Toggle("TerminateAfterLastWindowClosed", isOn: $appState.terminateAfterLastWindowClosed) + } + .groupBoxStyle(PreferencesGroupBoxStyle()) } } }