diff options
| author | Dustin Mierau <dustin@mierau.me> | 2024-01-04 08:36:46 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2024-01-04 08:36:46 -0800 |
| commit | a037710e03b690a73d30320bf7378bf5cc119c44 (patch) | |
| tree | 044fefe85a2a245bf9c2fd74465fbdfd1256597d /Hotline | |
| parent | cc6e0e35cf6e662ffc3ad24e2510265caa5cf52a (diff) | |
Add Connect to Server to menu with classic cmd-K shortcut. Make sure globe next to server name dims when window is inactive.
Diffstat (limited to 'Hotline')
| -rw-r--r-- | Hotline/Application.swift | 27 | ||||
| -rw-r--r-- | Hotline/macOS/ServerView.swift | 3 |
2 files changed, 16 insertions, 14 deletions
diff --git a/Hotline/Application.swift b/Hotline/Application.swift index 8e1b4d9..91f8dac 100644 --- a/Hotline/Application.swift +++ b/Hotline/Application.swift @@ -1,17 +1,16 @@ import SwiftUI import SwiftData -enum ServerWindowDestination: Hashable, Codable { - case server(server: Server) - case none -} - @main struct Application: App { #if os(iOS) private var model = Hotline(trackerClient: HotlineTrackerClient(), client: HotlineClient()) #endif + #if os(macOS) + @Environment(\.openWindow) private var openWindow + #endif + @State private var preferences = Prefs() var body: some Scene { @@ -33,16 +32,16 @@ struct Application: App { .frame(minWidth: 400, minHeight: 300) .environment(preferences) } - .defaultSize(width: 700, height: 800) + .defaultSize(width: 750, height: 700) .defaultPosition(.center) -// .commandsRemoved() -// .commands { -// CommandGroup(before: CommandGroupPlacement.newItem) { -// Button("before item") { -// print("before item") -// } -// } -// } + .commands { + CommandGroup(replacing: CommandGroupPlacement.newItem) { + Button("Connect to Server...") { + openWindow(id: "server") + } + .keyboardShortcut(.init("K"), modifiers: .command) + } + } Settings { SettingsView() diff --git a/Hotline/macOS/ServerView.swift b/Hotline/macOS/ServerView.swift index 7589744..a7dc90d 100644 --- a/Hotline/macOS/ServerView.swift +++ b/Hotline/macOS/ServerView.swift @@ -390,9 +390,12 @@ struct ServerView: View { .toolbar { ToolbarItem(placement: .navigation) { Image(systemName: "globe.americas.fill") + .renderingMode(.template) + .resizable() .scaledToFit() .frame(width: 18) + .opacity(controlActiveState == .inactive ? 0.4 : 1.0) } } } |