d9e8c6ceab
Settings was a NavigationLink pushed inside the 320pt menu-bar popover, so the grouped form was cramped and most controls sat below a non-obvious scroll (and showed a confusing "< Settings" back arrow). Add SettingsWindow (same standalone NSWindow pattern as the Editor/Templates windows) and open it from the menu-bar "Settings…" button. Drop the now-unused NavigationStack and the 320pt cap so the form uses real window width with normal macOS spacing; window is resizable.
88 lines
3.1 KiB
Swift
88 lines
3.1 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
/// Hosts the speaker-correction editor in a standalone resizable window. A
|
|
/// menu-bar (LSUIElement) app has no normal window scene, so we open one via
|
|
/// AppKit and activate the app so it comes to the front.
|
|
@MainActor
|
|
final class EditorWindow {
|
|
static let shared = EditorWindow()
|
|
private var window: NSWindow?
|
|
|
|
func show(model: RecapEditModel) {
|
|
if let window {
|
|
window.contentViewController = NSHostingController(rootView: TranscriptEditorView(model: model))
|
|
window.title = model.title
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
window.makeKeyAndOrderFront(nil)
|
|
return
|
|
}
|
|
let w = NSWindow(
|
|
contentRect: NSRect(x: 0, y: 0, width: 640, height: 560),
|
|
styleMask: [.titled, .closable, .resizable, .miniaturizable],
|
|
backing: .buffered, defer: false)
|
|
w.title = model.title
|
|
w.isReleasedWhenClosed = false
|
|
w.center()
|
|
w.contentViewController = NSHostingController(rootView: TranscriptEditorView(model: model))
|
|
window = w
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
w.makeKeyAndOrderFront(nil)
|
|
}
|
|
}
|
|
|
|
/// Hosts the app Settings in a standalone resizable window. Far roomier than the
|
|
/// old in-popover NavigationLink, which cramped the form into the 320pt menu-bar
|
|
/// panel and hid most controls below a non-obvious scroll.
|
|
@MainActor
|
|
final class SettingsWindow {
|
|
static let shared = SettingsWindow()
|
|
private var window: NSWindow?
|
|
|
|
func show(settings: AppSettings) {
|
|
if let window {
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
window.makeKeyAndOrderFront(nil)
|
|
return
|
|
}
|
|
let w = NSWindow(
|
|
contentRect: NSRect(x: 0, y: 0, width: 520, height: 660),
|
|
styleMask: [.titled, .closable, .resizable, .miniaturizable],
|
|
backing: .buffered, defer: false)
|
|
w.title = "Settings"
|
|
w.isReleasedWhenClosed = false
|
|
w.center()
|
|
w.contentViewController = NSHostingController(
|
|
rootView: SettingsView().environmentObject(settings))
|
|
window = w
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
w.makeKeyAndOrderFront(nil)
|
|
}
|
|
}
|
|
|
|
/// Hosts the recap-templates manager in its own resizable window.
|
|
@MainActor
|
|
final class TemplatesWindow {
|
|
static let shared = TemplatesWindow()
|
|
private var window: NSWindow?
|
|
|
|
func show(settings: AppSettings) {
|
|
if let window {
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
window.makeKeyAndOrderFront(nil)
|
|
return
|
|
}
|
|
let w = NSWindow(
|
|
contentRect: NSRect(x: 0, y: 0, width: 760, height: 560),
|
|
styleMask: [.titled, .closable, .resizable, .miniaturizable],
|
|
backing: .buffered, defer: false)
|
|
w.title = "Recap Templates"
|
|
w.isReleasedWhenClosed = false
|
|
w.center()
|
|
w.contentViewController = NSHostingController(rootView: TemplatesView(settings: settings))
|
|
window = w
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
w.makeKeyAndOrderFront(nil)
|
|
}
|
|
}
|