Improve macOS app lifecycle and split handle

This commit is contained in:
Mikei386
2026-06-04 11:53:46 +02:00
parent 00d34f864b
commit cc2dd6fd1f
2 changed files with 115 additions and 4 deletions
+22
View File
@@ -1,12 +1,34 @@
import AppKit
import SwiftUI
@main
struct GrowthLapseApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
.frame(minWidth: 980, minHeight: 680)
}
.windowStyle(.titleBar)
.commands {
CommandGroup(replacing: .appTermination) {
Button("GrowthLapse beenden") {
NSApp.terminate(nil)
}
.keyboardShortcut("q", modifiers: .command)
}
}
}
}
final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
NSApp.setActivationPolicy(.regular)
NSApp.activate(ignoringOtherApps: true)
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
true
}
}