Drag files in Finder, hold a modifier, and drop on a wheel of outputs. Conversions run entirely on-device through ImageIO, PDFKit, AVFoundation, the bundled CLI tools, and optional ffmpeg/LibreOffice. Includes a --self-test suite (41 checks) and a --convert CLI mode so the conversion matrix can be verified without the UI.
67 lines
1.9 KiB
Swift
67 lines
1.9 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
/// Longer text results (Info, Read QR, Statistics, archive listings).
|
|
final class ResultWindowController {
|
|
static let shared = ResultWindowController()
|
|
|
|
private var window: NSWindow?
|
|
|
|
private init() {}
|
|
|
|
func show(title: String, body: String) {
|
|
let view = ResultView(title: title, text: body, onClose: { [weak self] in self?.close() })
|
|
close()
|
|
|
|
let window = NSWindow(
|
|
contentRect: NSRect(x: 0, y: 0, width: 460, height: 320),
|
|
styleMask: [.titled, .closable, .resizable, .fullSizeContentView],
|
|
backing: .buffered,
|
|
defer: false
|
|
)
|
|
window.title = title
|
|
window.titlebarAppearsTransparent = true
|
|
window.level = .floating
|
|
window.contentView = NSHostingView(rootView: view)
|
|
window.center()
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
window.makeKeyAndOrderFront(nil)
|
|
self.window = window
|
|
}
|
|
|
|
func close() {
|
|
window?.orderOut(nil)
|
|
window = nil
|
|
}
|
|
}
|
|
|
|
struct ResultView: View {
|
|
let title: String
|
|
let text: String
|
|
let onClose: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
ScrollView {
|
|
Text(text)
|
|
.font(.system(size: 11.5, design: .monospaced))
|
|
.textSelection(.enabled)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(14)
|
|
}
|
|
Divider().opacity(0.4)
|
|
HStack {
|
|
Button("Copy") {
|
|
NSPasteboard.general.clearContents()
|
|
NSPasteboard.general.setString(text, forType: .string)
|
|
}
|
|
Spacer()
|
|
Button("Done", action: onClose)
|
|
.keyboardShortcut(.defaultAction)
|
|
}
|
|
.padding(10)
|
|
}
|
|
.frame(minWidth: 420, minHeight: 260)
|
|
}
|
|
}
|