Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
131 lines
6.0 KiB
Swift
131 lines
6.0 KiB
Swift
import AppKit
|
||
import SwiftUI
|
||
import LichtkastenCore
|
||
|
||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||
// Needed when started via `swift run` (no app bundle).
|
||
NSApp.setActivationPolicy(.regular)
|
||
NSApp.activate(ignoringOtherApps: true)
|
||
}
|
||
|
||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true }
|
||
}
|
||
|
||
@main
|
||
struct LichtkastenApp: App {
|
||
@NSApplicationDelegateAdaptor(AppDelegate.self) private var delegate
|
||
@StateObject private var state = AppState()
|
||
|
||
var body: some Scene {
|
||
WindowGroup("Lichtkasten") {
|
||
ContentView()
|
||
.environmentObject(state)
|
||
.environmentObject(state.uploads)
|
||
.environmentObject(state.tasks)
|
||
.frame(minWidth: 1000, minHeight: 640)
|
||
}
|
||
.commands { AppCommands(state: state) }
|
||
|
||
// PM: "IPTC Info" as its own window (I / ⌘I)
|
||
Window("IPTC-Info", id: "iptc") {
|
||
IPTCInfoWindow()
|
||
.environmentObject(state)
|
||
.frame(minWidth: 980, minHeight: 640)
|
||
}
|
||
.defaultSize(width: 1180, height: 760)
|
||
|
||
// PM: Tasks window – ingest, uploads, Lightroom
|
||
Window("Aufgaben", id: "tasks") {
|
||
TasksWindow()
|
||
.environmentObject(state)
|
||
.environmentObject(state.tasks)
|
||
.environmentObject(state.uploads)
|
||
.frame(minWidth: 620, minHeight: 360)
|
||
}
|
||
.defaultSize(width: 760, height: 520)
|
||
|
||
Settings {
|
||
SettingsView()
|
||
.environmentObject(state)
|
||
.frame(width: 720, height: 560)
|
||
}
|
||
}
|
||
}
|
||
|
||
struct AppCommands: Commands {
|
||
@ObservedObject var state: AppState
|
||
|
||
var body: some Commands {
|
||
CommandGroup(after: .newItem) {
|
||
Button("Ordner öffnen …") { state.chooseFolder() }.keyboardShortcut("o")
|
||
Button("Ingest (von Karte kopieren) …") { state.showIngest = true }.keyboardShortcut("g")
|
||
.disabled(state.ingestRunning)
|
||
Button("Ordner neu laden") { state.reload() }.keyboardShortcut("r")
|
||
Divider()
|
||
Button("Im Finder zeigen") {
|
||
NSWorkspace.shared.activateFileViewerSelecting(state.selectedItems.map(\.primary))
|
||
}.keyboardShortcut("r", modifiers: [.command, .shift])
|
||
}
|
||
CommandMenu("Bild") {
|
||
Button("Alle auswählen") { state.selectAll() }.keyboardShortcut("a", modifiers: [.command, .option])
|
||
Button("Getaggte auswählen") { state.selectTagged() }.keyboardShortcut("t", modifiers: [.command, .option])
|
||
Button("Auswahl aufheben") { state.deselectAll() }.keyboardShortcut("d")
|
||
Divider()
|
||
Button("Tag umschalten (T)") { state.toggleTag() }
|
||
Menu("Bewertung") {
|
||
ForEach(0...5, id: \.self) { n in
|
||
Button(n == 0 ? "Keine" : String(repeating: "★", count: n)) { state.setRating(n) }
|
||
}
|
||
}
|
||
Menu("Farbmarkierung") {
|
||
ForEach(ColorLabel.allCases, id: \.self) { l in Button(l.germanName) { state.setLabel(l) } }
|
||
Button("Keine") { state.setLabel(nil) }
|
||
}
|
||
Divider()
|
||
Button(state.previewMode ? "Kontaktabzug (Leertaste)" : "Vorschau (Leertaste)") { state.previewMode.toggle() }
|
||
Button("IPTC-Info … (I)") { state.openWindow("iptc") }
|
||
.keyboardShortcut("i")
|
||
Button(state.showInspector ? "IPTC-Seitenleiste ausblenden" : "IPTC-Seitenleiste (Mehrfachauswahl)") { state.showInspector.toggle() }
|
||
.keyboardShortcut("i", modifiers: [.command, .option])
|
||
Divider()
|
||
Button(state.isInSentFolder ? "Zum RAW-Ordner" : "Zum SENT-Ordner") { state.toggleRawSent() }
|
||
.keyboardShortcut("s", modifiers: [.command, .option])
|
||
.disabled(state.folder == nil)
|
||
}
|
||
CommandMenu("IPTC") {
|
||
Button("Vorlage anwenden …") { state.showTemplatePicker = true }.keyboardShortcut("i", modifiers: [.command, .shift])
|
||
Button("Letzte Vorlage erneut anwenden") {
|
||
if let id = state.settings.lastTemplateID, let t = state.templates.first(where: { $0.id == id }) {
|
||
state.applyTemplate(t)
|
||
}
|
||
}.keyboardShortcut("v", modifiers: [.command, .shift])
|
||
Button("Vorlagen verwalten …") { state.showTemplateManager = true }.keyboardShortcut("t", modifiers: [.command, .shift])
|
||
Divider()
|
||
Button("Photo-Mechanic-Vorlage importieren …") { state.importPMTemplate() }
|
||
Button("Code-Ersetzungen laden …") { state.importCodeReplacements() }
|
||
}
|
||
CommandMenu("Ausgabe") {
|
||
Button("In Lightroom Classic bearbeiten") { state.sendToLightroom(export: false, develop: true) }
|
||
.keyboardShortcut("e")
|
||
Button("An Lightroom Classic senden (nur Import)") { state.sendToLightroom(export: false) }
|
||
.keyboardShortcut("l", modifiers: [.command, .shift])
|
||
Button("Lightroom: Vorgabe anwenden + JPEG exportieren") { state.sendToLightroom(export: true) }
|
||
.keyboardShortcut("l", modifiers: [.command, .option])
|
||
Divider()
|
||
ForEach(Array(state.settings.ftpDestinations.enumerated()), id: \.element.id) { idx, d in
|
||
if idx == 0 {
|
||
Button("FTP: \(d.name)") { state.upload(to: d.id.uuidString) }.keyboardShortcut("u", modifiers: [.command, .shift])
|
||
} else {
|
||
Button("FTP: \(d.name)") { state.upload(to: d.id.uuidString) }
|
||
}
|
||
}
|
||
Button("Zu Immich hochladen") { state.upload(to: "immich") }
|
||
.keyboardShortcut("m", modifiers: [.command, .shift])
|
||
.disabled(!state.settings.immich.enabled)
|
||
Divider()
|
||
Button("Aufgaben-Fenster") { state.openWindow("tasks") }.keyboardShortcut("u", modifiers: [.command, .option])
|
||
}
|
||
}
|
||
}
|