Lichtkasten v0.1: Culling, IPTC (PM-kompatibel), Vorlagen, FTP/Immich, Lightroom-Bridge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
Lichtkasten DevandClaude Opus 5.5 committed 2026-11-03 22:40:28 +00:00
commit e13cbf416d
37 files changed
+4431

No files matched your search

@@ -0,0 +1,270 @@
import SwiftUI
import LichtkastenCore
struct SettingsView: View {
var body: some View {
TabView {
GeneralSettings().tabItem { Label("Allgemein", systemImage: "gearshape") }
FTPSettings().tabItem { Label("FTP", systemImage: "server.rack") }
ImmichSettingsView().tabItem { Label("Immich", systemImage: "photo.stack") }
LightroomSettingsView().tabItem { Label("Lightroom", systemImage: "camera.aperture") }
CodesSettings().tabItem { Label("Codes", systemImage: "character.textbox") }
}
.padding(16)
}
}
struct GeneralSettings: View {
@EnvironmentObject var state: AppState
var body: some View {
Form {
Section("Tastatur") {
Picker("Belegung", selection: $state.settings.keyScheme) {
ForEach(KeyScheme.allCases, id: \.self) { Text($0.rawValue).tag($0) }
}
Toggle("Nach Bewertung/Tag automatisch zum nächsten Bild", isOn: $state.settings.autoAdvance)
Text("T = Tag · Leertaste = Vorschau · Z = 100 % · Pfeile = Navigation · ⌘⌥A = alle auswählen")
.font(.caption).foregroundStyle(.secondary)
}
Section("exiftool") {
HStack {
TextField("Pfad (leer = automatisch)", text: $state.settings.exiftoolPath)
Button("Neu verbinden") { state.resetExifTool() }
}
if let url = ExifTool.locate(custom: state.settings.exiftoolPath) {
Label("Gefunden: \(url.path)", systemImage: "checkmark.circle.fill").foregroundStyle(.green)
} else {
Label("Nicht gefunden – Terminal: brew install exiftool", systemImage: "xmark.octagon.fill").foregroundStyle(.red)
}
}
Section("Variablen") {
TextField("Datumsformat für {date}", text: $state.settings.dateFormat)
Text("z. B. dd.MM.yyyy → 03.11.2026 · d. MMMM yyyy → 3. November 2026")
.font(.caption).foregroundStyle(.secondary)
}
}
.formStyle(.grouped)
}
}
struct FTPSettings: View {
@EnvironmentObject var state: AppState
@State private var selected: UUID?
@State private var password = ""
@State private var testResult = ""
@State private var testing = false
private var index: Int? { state.settings.ftpDestinations.firstIndex { $0.id == selected } }
var body: some View {
HSplitView {
VStack(spacing: 0) {
List(selection: $selected) {
ForEach(state.settings.ftpDestinations) { d in Text(d.name).tag(d.id) }
}
HStack {
Button { let d = FTPDestination(); state.settings.ftpDestinations.append(d); selected = d.id } label: { Image(systemName: "plus") }
Button {
if let i = index { Keychain.set("", account: state.settings.ftpDestinations[i].keychainAccount)
state.settings.ftpDestinations.remove(at: i); selected = nil }
} label: { Image(systemName: "minus") }.disabled(index == nil)
Spacer()
}
.buttonStyle(.borderless).padding(6)
}
.frame(minWidth: 170, maxWidth: 220)
if let i = index {
Form {
TextField("Name", text: $state.settings.ftpDestinations[i].name)
Picker("Protokoll", selection: Binding(
get: { state.settings.ftpDestinations[i].proto },
set: { p in
state.settings.ftpDestinations[i].proto = p
state.settings.ftpDestinations[i].port = p.defaultPort
})) {
ForEach(FTPProtocol.allCases, id: \.self) { Text($0.rawValue).tag($0) }
}
TextField("Server", text: $state.settings.ftpDestinations[i].host)
TextField("Port", value: $state.settings.ftpDestinations[i].port, format: .number.grouping(.never))
TextField("Benutzer", text: $state.settings.ftpDestinations[i].username)
SecureField("Passwort (Schlüsselbund)", text: $password)
.onSubmit { Keychain.set(password, account: state.settings.ftpDestinations[i].keychainAccount) }
.onChange(of: password) { _, p in Keychain.set(p, account: state.settings.ftpDestinations[i].keychainAccount) }
if state.settings.ftpDestinations[i].proto == .sftp {
TextField("SSH-Schlüssel (optional)", text: $state.settings.ftpDestinations[i].sshKeyPath)
}
TextField("Zielordner", text: $state.settings.ftpDestinations[i].remoteDirectory)
Picker("Dateien", selection: $state.settings.ftpDestinations[i].variant) {
ForEach(UploadVariant.allCases, id: \.self) { Text($0.rawValue).tag($0) }
}
TextField("Umbenennen (leer = Originalname)", text: $state.settings.ftpDestinations[i].renamePattern)
Toggle("Passiver Modus", isOn: $state.settings.ftpDestinations[i].passive)
Toggle("Mit .part hochladen und danach umbenennen", isOn: $state.settings.ftpDestinations[i].uploadWithTempName)
Toggle("TLS-Zertifikat nicht prüfen (nur wenn nötig)", isOn: $state.settings.ftpDestinations[i].allowInsecureTLS)
HStack {
Button("Verbindung testen") { test(state.settings.ftpDestinations[i]) }.disabled(testing)
if testing { ProgressView().controlSize(.small) }
Text(testResult).font(.caption).lineLimit(3)
}
}
.formStyle(.grouped)
.onAppear { password = Keychain.get(state.settings.ftpDestinations[i].keychainAccount) ?? "" }
.onChange(of: selected) { _, _ in
testResult = ""
if let i = index { password = Keychain.get(state.settings.ftpDestinations[i].keychainAccount) ?? "" }
}
} else {
Text("Server hinzufügen oder auswählen").foregroundStyle(.secondary).frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
}
private func test(_ d: FTPDestination) {
testing = true
testResult = ""
Task {
do {
try await FTPUploader().testConnection(d, password: Keychain.get(d.keychainAccount))
testResult = "✅ Verbindung OK"
} catch { testResult = "❌ " + error.localizedDescription }
testing = false
}
}
}
struct ImmichSettingsView: View {
@EnvironmentObject var state: AppState
@State private var apiKey = ""
@State private var result = ""
var body: some View {
Form {
Toggle("Immich-Upload aktivieren", isOn: $state.settings.immich.enabled)
TextField("Server-URL", text: $state.settings.immich.serverURL, prompt: Text("https://immich.example.de"))
SecureField("API-Schlüssel (Schlüsselbund)", text: $apiKey)
.onChange(of: apiKey) { _, k in Keychain.set(k, account: ImmichSettings.keychainAccount); state.uploads.resetImmich() }
TextField("Album (leer = keins, wird angelegt)", text: $state.settings.immich.albumName)
Picker("Dateien", selection: $state.settings.immich.variant) {
ForEach(UploadVariant.allCases, id: \.self) { Text($0.rawValue).tag($0) }
}
HStack {
Button("Verbindung testen") { test() }
Text(result).font(.caption)
}
Text("API-Schlüssel in Immich: Konto-Einstellungen → API-Schlüssel. Benötigte Rechte: asset.upload, album.read, album.create, albumAsset.create.")
.font(.caption).foregroundStyle(.secondary)
}
.formStyle(.grouped)
.onAppear { apiKey = Keychain.get(ImmichSettings.keychainAccount) ?? "" }
.onChange(of: state.settings.immich) { _, _ in state.uploads.resetImmich() }
}
private func test() {
result = "…"
Task {
do {
let c = try ImmichClient(settings: state.settings.immich, apiKey: apiKey)
result = "✅ Angemeldet als \(try await c.testConnection())"
} catch { result = "❌ " + error.localizedDescription }
}
}
}
struct LightroomSettingsView: View {
@EnvironmentObject var state: AppState
@State private var pluginMessage = ""
var body: some View {
Form {
Section("Lichtkasten-Bridge-Plugin") {
HStack {
if LightroomBridge.pluginIsAlive {
Label("Plugin aktiv (Lightroom läuft)", systemImage: "checkmark.circle.fill").foregroundStyle(.green)
} else if LightroomBridge.pluginInstalled {
Label("Installiert – Lightroom starten", systemImage: "pause.circle").foregroundStyle(.orange)
} else {
Label("Nicht installiert", systemImage: "xmark.circle").foregroundStyle(.red)
}
Spacer()
Button(LightroomBridge.pluginInstalled ? "Neu installieren" : "Plugin installieren") { install() }
}
if !pluginMessage.isEmpty { Text(pluginMessage).font(.caption) }
Text("Ohne Plugin öffnet ⌘⇧L den normalen Importdialog von Lightroom.")
.font(.caption).foregroundStyle(.secondary)
}
Section("Import") {
TextField("Entwicklungsvorgabe (exakter Name, optional „Ordner/Name“)", text: $state.settings.lightroom.developPreset)
TextField("Sammlung (leer = keine)", text: $state.settings.lightroom.collection)
}
Section("JPEG-Export (⌘⌥L)") {
HStack {
TextField("Exportordner (leer = Unterordner „Export“)", text: $state.settings.lightroom.exportFolder)
Button("Wählen …") {
let p = NSOpenPanel(); p.canChooseDirectories = true; p.canChooseFiles = false; p.canCreateDirectories = true
if p.runModal() == .OK, let u = p.url { state.settings.lightroom.exportFolder = u.path }
}
}
Stepper("JPEG-Qualität: \(state.settings.lightroom.jpegQuality)", value: $state.settings.lightroom.jpegQuality, in: 50...100, step: 5)
TextField("Lange Kante in px (0 = volle Größe)", value: $state.settings.lightroom.longEdge, format: .number.grouping(.never))
Picker("Ausgabeschärfung", selection: $state.settings.lightroom.sharpening) {
Text("Keine").tag("none"); Text("Bildschirm").tag("screen"); Text("Matt").tag("matte"); Text("Glanz").tag("glossy")
}
Picker("Farbraum", selection: $state.settings.lightroom.colorSpace) {
Text("sRGB").tag("sRGB"); Text("Adobe RGB").tag("AdobeRGB")
}
Toggle("Original-IPTC nach Export erneut schreiben (PM-identischer Aufbau)", isOn: $state.settings.lightroom.rewriteIPTCAfterExport)
}
Section("Nach dem Export automatisch hochladen") {
ForEach(state.settings.ftpDestinations) { d in
Toggle("FTP: \(d.name)", isOn: uploadBinding(d.id.uuidString))
}
Toggle("Immich", isOn: uploadBinding("immich")).disabled(!state.settings.immich.enabled)
}
}
.formStyle(.grouped)
}
private func uploadBinding(_ id: String) -> Binding<Bool> {
Binding(get: { state.settings.lightroom.autoUploadTargets.contains(id) },
set: { on in
state.settings.lightroom.autoUploadTargets.removeAll { $0 == id }
if on { state.settings.lightroom.autoUploadTargets.append(id) }
})
}
private func install() {
guard let bundle = Bundle.main.url(forResource: "LichtkastenBridge", withExtension: "lrplugin") else {
pluginMessage = "Plugin nicht im App-Bundle gefunden. Bitte LightroomPlugin/LichtkastenBridge.lrplugin über Lightroom → Zusatzmodul-Manager hinzufügen."
return
}
do {
try LightroomBridge.installPlugin(from: bundle)
pluginMessage = "Installiert. Lightroom Classic bitte neu starten."
} catch { pluginMessage = error.localizedDescription }
}
}
struct CodesSettings: View {
@EnvironmentObject var state: AppState
@State private var testInput = "\\bvb\\ gegen \\s04\\"
var body: some View {
Form {
Section("Code-Ersetzung (wie Photo Mechanic)") {
HStack {
Text("\(state.codes.table.count) Codes geladen")
Spacer()
Button("Datei laden …") { state.importCodeReplacements() }
Button("Leeren") { state.codes = CodeReplacements() }
}
Text("Tab-getrennte Textdatei: Code ⇥ Ersetzung ⇥ weitere Spalten. Im Text: \\code\\ oder \\code#2\\ für Spalte 2.")
.font(.caption).foregroundStyle(.secondary)
TextField("Test", text: $testInput)
Text(state.codes.expand(testInput)).font(.callout).textSelection(.enabled)
}
}
.formStyle(.grouped)
}
}