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

Terminate Xcodes app after last window closed #621

Merged
merged 6 commits into from
Oct 18, 2024
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
7 changes: 7 additions & 0 deletions Xcodes/Backend/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class AppState: ObservableObject {
}
}

@Published var terminateAfterLastWindowClosed = false {
didSet {
Current.defaults.set(terminateAfterLastWindowClosed, forKey: "terminateAfterLastWindowClosed")
}
}

// MARK: - Runtimes

@Published var downloadableRuntimes: [DownloadableRuntime] = []
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Xcodes/Frontend/Preferences/GeneralPreferencePane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ struct GeneralPreferencePane: View {
NotificationsView().environmentObject(appState)
}
.groupBoxStyle(PreferencesGroupBoxStyle())
Divider()

GroupBox(label: Text("Misc")) {
Toggle("TerminateAfterLastWindowClosed", isOn: $appState.terminateAfterLastWindowClosed)
}
.groupBoxStyle(PreferencesGroupBoxStyle())
}
}
}
Expand Down
250 changes: 249 additions & 1 deletion Xcodes/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -8029,7 +8029,7 @@
"el" : {
"stringUnit" : {
"state" : "translated",
"value" : "Εισάγετε τον %2$d-ψήφιο κωδικού που εστάλη στο %2$@:"
"value" : "Εισάγετε τον %1$d-ψήφιο κωδικού που εστάλη στο %2$@:"
}
},
"en" : {
Expand Down Expand Up @@ -14829,6 +14829,130 @@
}
}
},
"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",
"value" : "杂项"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "雜項"
}
}
}
},
"Moving" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -20721,6 +20845,130 @@
}
}
},
"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" : "translated",
"value" : "在最后一个窗口关闭后终止App"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "在最後一個窗口關閉後終止 App"
}
}
}
},
"TrashingArchive" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
6 changes: 5 additions & 1 deletion Xcodes/XcodesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down