Skip to content

Commit

Permalink
Merge pull request #621 from Kyle-Ye/bugfix/windows
Browse files Browse the repository at this point in the history
Terminate Xcodes app after last window closed
  • Loading branch information
MattKiazyk authored Oct 18, 2024
2 parents cf85e2f + 59331bc commit 283c1a4
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Xcodes/Backend/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,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 @@ -199,6 +205,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
248 changes: 248 additions & 0 deletions Xcodes/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -14954,6 +14954,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 @@ -21220,6 +21344,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

0 comments on commit 283c1a4

Please sign in to comment.