mirror of
https://github.com/D-Modem/gui.git
synced 2026-11-28 22:30:49 -08:00
The terminal view now takes any TerminalHost (the modem, or a remote login), so both pages draw with the same view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
60 lines
1.8 KiB
Swift
60 lines
1.8 KiB
Swift
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// Copyright (C) 2026 D-Modem Authors
|
|
//
|
|
// DModemApp.swift - the app: its window, menus and the line settings
|
|
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct DModemApp: App {
|
|
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
|
|
@StateObject private var modem = Modem()
|
|
@StateObject private var remote = RemoteSession()
|
|
|
|
var body: some Scene {
|
|
Window("D-Modem", id: "main") {
|
|
ContentView()
|
|
.environmentObject(modem)
|
|
.environmentObject(modem.voice)
|
|
.environmentObject(remote)
|
|
.frame(minWidth: 760, minHeight: 520)
|
|
.onAppear {
|
|
delegate.modem = modem
|
|
delegate.remote = remote
|
|
}
|
|
}
|
|
.commands {
|
|
CommandMenu("Modem") {
|
|
Button(modem.running ? "Stop" : "Start") {
|
|
modem.running ? modem.stop() : modem.start()
|
|
}
|
|
.keyboardShortcut("r")
|
|
Divider()
|
|
Button("Answer") { modem.answer() }
|
|
.disabled(modem.state != Int(DMC_RINGING))
|
|
Button("Hang Up") { modem.hangUp() }
|
|
.keyboardShortcut(".")
|
|
.disabled(!modem.canHangUp)
|
|
}
|
|
}
|
|
Settings {
|
|
LineSettingsView()
|
|
.environmentObject(modem)
|
|
}
|
|
}
|
|
}
|
|
|
|
final class AppDelegate: NSObject, NSApplicationDelegate {
|
|
weak var modem: Modem?
|
|
weak var remote: RemoteSession?
|
|
|
|
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool {
|
|
true
|
|
}
|
|
|
|
func applicationWillTerminate(_ notification: Notification) {
|
|
remote?.stop()
|
|
modem?.stop()
|
|
}
|
|
}
|