Skip to content

Commit f8970f4

Browse files
committed
Add TerminateAfterLastWindowClosed toggle support in Misc
1 parent 3d5fdd5 commit f8970f4

4 files changed

Lines changed: 60 additions & 0 deletions

File tree

Xcodes/Backend/AppState.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ class AppState: ObservableObject {
104104
}
105105
}
106106

107+
@Published var terminateAfterLastWindowClosed = false {
108+
didSet {
109+
Current.defaults.set(terminateAfterLastWindowClosed, forKey: "terminateAfterLastWindowClosed")
110+
}
111+
}
112+
107113
// MARK: - Runtimes
108114

109115
@Published var downloadableRuntimes: [DownloadableRuntime] = []
@@ -173,6 +179,7 @@ class AppState: ObservableObject {
173179
onSelectActionType = SelectedActionType(rawValue: Current.defaults.string(forKey: "onSelectActionType") ?? "none") ?? .none
174180
installPath = Current.defaults.string(forKey: "installPath") ?? Path.defaultInstallDirectory.string
175181
showOpenInRosettaOption = Current.defaults.bool(forKey: "showOpenInRosettaOption") ?? false
182+
terminateAfterLastWindowClosed = Current.defaults.bool(forKey: "terminateAfterLastWindowClosed") ?? false
176183
}
177184

178185
// MARK: Timer

Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ struct AdvancedPreferencePane: View {
151151
}
152152
}
153153
.groupBoxStyle(PreferencesGroupBoxStyle())
154+
155+
GroupBox(label: Text("Misc")) {
156+
Toggle("TerminateAfterLastWindowClosed", isOn: $appState.terminateAfterLastWindowClosed)
157+
}
158+
.groupBoxStyle(PreferencesGroupBoxStyle())
154159
}
155160
}
156161
}

Xcodes/Resources/Localizable.xcstrings

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14829,6 +14829,28 @@
1482914829
}
1483014830
}
1483114831
},
14832+
"Misc" : {
14833+
"localizations" : {
14834+
"en" : {
14835+
"stringUnit" : {
14836+
"state" : "translated",
14837+
"value" : "Misc"
14838+
}
14839+
},
14840+
"zh-Hans" : {
14841+
"stringUnit" : {
14842+
"state" : "translated",
14843+
"value" : "杂项"
14844+
}
14845+
},
14846+
"zh-Hant" : {
14847+
"stringUnit" : {
14848+
"state" : "translated",
14849+
"value" : "雜項"
14850+
}
14851+
}
14852+
}
14853+
},
1483214854
"Moving" : {
1483314855
"extractionState" : "manual",
1483414856
"localizations" : {
@@ -20721,6 +20743,28 @@
2072120743
}
2072220744
}
2072320745
},
20746+
"TerminateAfterLastWindowClosed" : {
20747+
"localizations" : {
20748+
"en" : {
20749+
"stringUnit" : {
20750+
"state" : "translated",
20751+
"value" : "Terminate App after last window is closed"
20752+
}
20753+
},
20754+
"zh-Hans" : {
20755+
"stringUnit" : {
20756+
"state" : "needs_review",
20757+
"value" : "在最后一个窗口关闭后终止App"
20758+
}
20759+
},
20760+
"zh-Hant" : {
20761+
"stringUnit" : {
20762+
"state" : "needs_review",
20763+
"value" : "在最後一個窗口關閉後終止 App"
20764+
}
20765+
}
20766+
}
20767+
},
2072420768
"TrashingArchive" : {
2072520769
"extractionState" : "manual",
2072620770
"localizations" : {

Xcodes/XcodesApp.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
166166
}
167167

168168
func applicationDidFinishLaunching(_: Notification) {}
169+
170+
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
171+
return Current.defaults.bool(forKey: "terminateAfterLastWindowClosed") ?? false
172+
}
169173
}
170174

171175
func localizeString(_ key: String, comment: String = "") -> String {

0 commit comments

Comments
 (0)