-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrometheusApp.swift
More file actions
42 lines (36 loc) · 1.1 KB
/
PrometheusApp.swift
File metadata and controls
42 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import SwiftUI
import AppKit
@main
struct PrometheusApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(.hiddenTitleBar)
.windowResizability(.contentSize)
.commands {
CommandGroup(replacing: .newItem) {}
}
}
}
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
// Activate the app and bring it to front
NSApp.setActivationPolicy(.regular)
NSApp.activate(ignoringOtherApps: true)
// Bring all windows to front
if let window = NSApplication.shared.windows.first {
window.makeKeyAndOrderFront(nil)
window.center()
}
}
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
if !flag {
for window in sender.windows {
window.makeKeyAndOrderFront(nil)
}
}
return true
}
}