Files
gui/macos/DModem/DModemApp.swift
T
Claude f7a9b12c0e Licence: AGPL-3.0-only, or a commercial licence from the D-Modem Authors
The suite's licence, as D-Modem, bbs, menu and brand: the AGPL-3.0-only
by default, and a commercial licence from the D-Modem Authors for uses
that can't meet its terms (COMMERCIAL-LICENSE.md).  The contributor
agreement grants the licence for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSQaj3bYPQDZU4qf9U
2026-11-07 11:01:39 +00:00

52 lines
1.5 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()
var body: some Scene {
Window("D-Modem", id: "main") {
ContentView()
.environmentObject(modem)
.frame(minWidth: 760, minHeight: 520)
.onAppear { delegate.modem = modem }
}
.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?
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool {
true
}
func applicationWillTerminate(_ notification: Notification) {
modem?.stop()
}
}