diff options
| author | Dustin Mierau <mierau@users.noreply.github.com> | 2024-10-04 10:12:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-04 10:12:25 -0700 |
| commit | 77b3ac3c051fc4e8fa126cd21e261be28f4aad1a (patch) | |
| tree | ba3e3d567872c92a74734c593e9717aa12a0441a /Hotline/Application-macOS.swift | |
| parent | 93841e378308f959566e1411a7cba6a2602db2e8 (diff) | |
| parent | 5dc0ed09a3cdebad75d46aa3ef8f7a83b18ba449 (diff) | |
Merge pull request #34 from jverkoey/openservershortcut
Add Cmd+Down keyboard shortcut for connecting to servers.
Diffstat (limited to 'Hotline/Application-macOS.swift')
| -rw-r--r-- | Hotline/Application-macOS.swift | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Hotline/Application-macOS.swift b/Hotline/Application-macOS.swift index 56ead01..fe3a828 100644 --- a/Hotline/Application-macOS.swift +++ b/Hotline/Application-macOS.swift @@ -77,6 +77,7 @@ struct Application: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @State private var hotlinePanel: HotlinePanel? = nil + @State private var selection: Bookmark? = nil @FocusedValue(\.activeHotlineModel) private var activeHotline: Hotline? @FocusedValue(\.activeServerState) private var activeServerState: ServerState? @@ -97,7 +98,7 @@ struct Application: App { var body: some Scene { // MARK: Tracker Window Window("Servers", id: "servers") { - TrackerView() + TrackerView(selection: $selection) .frame(minWidth: 250, minHeight: 250) } .modelContainer(self.modelContainer) @@ -195,6 +196,14 @@ struct Application: App { } } CommandMenu("Server") { + Button("Connect") { + guard let selection else { + return + } + connect(to: selection) + } + .disabled(selection == nil || selection?.server == nil) + .keyboardShortcut(.downArrow, modifiers: .command) Button("Disconnect") { activeHotline?.disconnect() } @@ -259,7 +268,13 @@ struct Application: App { .defaultSize(width: 450, height: 550) .defaultPosition(.center) } - + + func connect(to item: Bookmark) { + if let server = item.server { + openWindow(id: "server", value: server) + } + } + func showBannerWindow() { if hotlinePanel == nil { hotlinePanel = HotlinePanel(HotlinePanelView()) |