Files
lichtkasten/Sources/Lichtkasten/LichtkastenApp.swift
T
Lichtkasten DevandClaude Opus 5.5 80d5b4181f Fokus-Ansicht in der Vorschau (F)
Blendet Werkzeugleiste, Tabs, Matchday-Kopf, Filterleiste und Seitenleiste aus – übrig bleiben Bild,
Filmstreifen mit Bildinfo und das IPTC-Panel rechts. Schalter unten neben dem Panel-Knopf, Taste F,
Bild-Menü; wird gemerkt, Seitenleiste kommt beim Verlassen wie vorher zurück.

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

199 lines
9.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import AppKit
import SwiftUI
import LichtkastenCore
final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationWillFinishLaunching(_ notification: Notification) {
// A helper process (curl, exiftool) that dies while we write to it must not kill the app (SIGPIPE).
signal(SIGPIPE, SIG_IGN)
}
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)
.lkWindow()
.frame(minWidth: 1100, minHeight: 680)
}
.commands { AppCommands(state: state) }
// PM: "Metadata (IPTC) Info" for one image (I)
Window("IPTC-Info", id: "iptc") {
IPTCInfoWindow()
.environmentObject(state)
.lkWindow()
.frame(minWidth: 1020, minHeight: 680)
}
.defaultSize(width: 1240, height: 860)
// ⌘I – mass edit for the selection (PM template layout with checkboxes)
Window("IPTC für Auswahl", id: "iptc-batch") {
BatchEditWindow()
.environmentObject(state)
.lkWindow()
.frame(minWidth: 1200, minHeight: 700)
}
.defaultSize(width: 1400, height: 900)
// ⌘U – upload dialog
Window("Hochladen", id: "upload") {
UploadWindow().environmentObject(state).lkWindow()
}
.windowResizability(.contentSize)
// Agentur-Check before uploading
Window("Agentur-Check", id: "check") {
PreflightWindow()
.environmentObject(state)
.lkWindow()
}
.defaultSize(width: 880, height: 660)
// PM: Tasks window
Window("Aufgaben", id: "tasks") {
TasksWindow()
.lkWindow()
.environmentObject(state)
.environmentObject(state.tasks)
.environmentObject(state.uploads)
.frame(minWidth: 620, minHeight: 360)
}
.defaultSize(width: 760, height: 520)
Window("Code-Ersetzungen", id: "codes") {
CodesWindow()
.environmentObject(state)
.lkWindow()
.frame(minWidth: 640, minHeight: 480)
}
Settings {
SettingsView()
.environmentObject(state)
.lkWindow()
.frame(width: 760, height: 600)
}
}
}
struct AppCommands: Commands {
@ObservedObject var state: AppState
var body: some Commands {
// Undo/redo of ratings, labels, tags and IPTC – text fields keep their own undo while typing.
CommandGroup(replacing: .undoRedo) {
Button(state.undoTitle.map { "Rückgängig: \($0)" } ?? "Rückgängig") { state.performUndo() }
.keyboardShortcut("z")
Button(state.redoTitle.map { "Wiederholen: \($0)" } ?? "Wiederholen") { state.performRedo() }
.keyboardShortcut("z", modifiers: [.command, .shift])
}
// Replaces "New Window" (⌘N) – ⌘N is "Save & previous" in the IPTC window like in PM.
CommandGroup(replacing: .newItem) {
Button("Ordner öffnen …") { state.chooseFolder() }.keyboardShortcut("o")
Button("Neuer Tab …") { state.newTab() }.keyboardShortcut("t")
Button("Ingest (von Karte kopieren) …") { state.showIngest = true }.keyboardShortcut("g")
.disabled(state.ingestRunning)
Button("Ordner neu laden") { state.reload() }.keyboardShortcut("r")
Divider()
Button("Neuer Spieltag …") { state.showSpieltag = true }.keyboardShortcut("n", modifiers: [.command, .shift])
Divider()
Button("Im Finder zeigen") {
NSWorkspace.shared.activateFileViewerSelecting(state.selectedItems.map(\.primary))
}.keyboardShortcut("r", modifiers: [.command, .shift])
}
CommandMenu("Bild") {
Button("Alle auswählen (⌘A)") { 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")
Button("In den Papierkorb … (⌘⌫)") { state.trashSelected() }
.disabled(state.selectedItems.isEmpty)
Divider()
Button("Tag umschalten (T)") { state.toggleTag() }
Menu("Farbklasse (1–8)") {
ForEach(ColorLabel.allCases, id: \.self) { l in
Button("\(l.pmColorClass) – \(l.germanName) (\(l.pmName))") { state.setLabel(l) }
}
Button("0 – Keine") { state.setLabel(nil) }
}
Menu("Bewertung (⌥1–5)") {
ForEach(0...5, id: \.self) { n in
Button(n == 0 ? "Keine" : String(repeating: "★", count: n)) { state.setRating(n) }
}
}
Divider()
Button("Trikotnummern erkennen") {
state.recognizeJerseys(state.selection.count > 1 ? state.selectedItems : nil, onlyNew: state.selection.count <= 1)
}
.keyboardShortcut("j", modifiers: [.command, .shift])
.disabled(state.folder == nil || state.jerseyRunning)
Button("Trikot-Vorschläge zurücksetzen") {
state.resetJerseySuggestions(state.selection.count > 1 ? state.selectedItems : nil)
}
.disabled(state.folder == nil || state.jerseyRunning)
Button("Trikot-Erkennung einrichten (Teams & Farben) …") { state.showJerseySetup = true }
Toggle("Matchday-Ansicht", isOn: $state.settings.jersey.matchday)
Toggle("Fokus-Ansicht in der Vorschau (F)", isOn: $state.focusMode)
Divider()
Button(state.previewMode ? "Kontaktabzug (Leertaste)" : "Vorschau (Leertaste)") { state.previewMode.toggle() }
Button(state.isInSentFolder ? "Zum INPUT/RAW-Ordner" : "Zum SENT-Ordner") { state.toggleRawSent() }
.keyboardShortcut("s", modifiers: [.command, .option])
.disabled(state.folder == nil)
}
CommandMenu("IPTC") {
Button("IPTC für Auswahl bearbeiten …") { state.openWindow("iptc-batch") }
.keyboardShortcut("i")
Button("IPTC-Info (einzeln) … (I)") { state.openWindow("iptc") }
Divider()
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("Code-Ersetzungen …") { state.openWindow("codes") }.keyboardShortcut("k", modifiers: [.command, .shift])
Button("Photo-Mechanic-Einstellungen importieren (alle) …") { state.showPMImport = true }
Button("Photo-Mechanic-Vorlage importieren …") { state.importPMTemplate() }
}
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 nach SENT") { state.sendToLightroom(export: true) }
.keyboardShortcut("l", modifiers: [.command, .option])
Divider()
Button("Hochladen …") { state.openWindow("upload") }.keyboardShortcut("u")
ForEach(Array(state.settings.ftpDestinations.enumerated()), id: \.element.id) { idx, d in
if idx == 0 {
Button("Sofort hochladen: \(d.name)") { state.upload(to: d.id.uuidString) }.keyboardShortcut("u", modifiers: [.command, .shift])
} else {
Button("Sofort hochladen: \(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])
}
}
}