From 5dc0ed09a3cdebad75d46aa3ef8f7a83b18ba449 Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Wed, 31 Jul 2024 21:14:11 -0400 Subject: Add Cmd+Down keyboard shortcut for connecting to servers. --- Hotline/Application-macOS.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Hotline/Application-macOS.swift') 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()) -- cgit