PM-Oberfläche: Favoriten/Navigator/Aufgaben, Tabs, PM-Filter, PM-Kacheln, IPTC-Layout wie PM, ⌘I Mass-Edit, ⌘U Upload, Code-Ersetzung live, 8 Farbklassen, paralleles + gecachtes Metadaten-Laden, BILDER/INPUT+SENT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
1 parent
d100249c12
commit
c0ee93995f
18 files changed
+1311
-515
No files matched your search
@@ -35,36 +35,34 @@ open build/Lichtkasten.app
|
||||
|
||||
Zum Entwickeln `Package.swift` in Xcode öffnen und das Scheme **Lichtkasten** starten. `swift test` führt die Core-Tests aus.
|
||||
|
||||
## Tastatur
|
||||
## Tastatur (Photo-Mechanic-Belegung)
|
||||
|
||||
| Taste | Funktion |
|
||||
|---|---|
|
||||
| 1–5 / 0 | Sterne setzen / entfernen |
|
||||
| ⌥1–5 / ⌥0 | Farbklasse (PM-Belegung). Bei Lightroom-Belegung stattdessen 6–9 = Rot/Gelb/Grün/Blau |
|
||||
| 1–8 / 0 | Farbklasse (Rot, Gelb, Grün, Blau, Magenta, Cyan, Orange, Grau) / keine |
|
||||
| ⌥1–5 / ⌥0 | Sterne / keine Sterne |
|
||||
| T | Tag umschalten |
|
||||
| I oder ⌘I | IPTC-Info-Fenster (wie PM) |
|
||||
| ⌘⌥I | IPTC-Seitenleiste für die Mehrfachauswahl |
|
||||
| Leertaste / ↩ | Vorschau ↔ Kontaktabzug, Z = 100 % |
|
||||
| ⌘E | In Lightroom Classic bearbeiten (Import + Entwickeln-Modul) |
|
||||
| ⌘⇧L | Nur in Lightroom importieren |
|
||||
| ⌘⌥L | Lightroom: Vorgabe + JPEG-Export in den SENT-Ordner |
|
||||
| ⌘⌥S | Zwischen RAW- und SENT-Ordner wechseln |
|
||||
| ⌘⇧I / ⌘⇧V | Vorlage anwenden / letzte Vorlage erneut anwenden |
|
||||
| ⌘⇧U / ⌘⇧M | Upload zum ersten FTP-Profil / zu Immich |
|
||||
| ⌘⌥U | Aufgaben-Fenster |
|
||||
| ⌘G | Ingest (öffnet sich auch automatisch, sobald eine Karte erkannt wird) |
|
||||
| I | IPTC-Info für das aktuelle Bild (Fenster wie PM, mit „Speichern & →“) |
|
||||
| ⌘I | IPTC für alle ausgewählten Bilder (Mass-Edit mit PM-Häkchen) |
|
||||
| ⌘U | Upload-Fenster · ⌘⇧U = sofort zum ersten FTP-Profil |
|
||||
| ⌘E | In Lightroom Classic bearbeiten |
|
||||
| ⌘⌥L | Lightroom: Vorgabe + JPEG-Export nach SENT |
|
||||
| ⌘⌥S | INPUT ⇄ SENT |
|
||||
| ⌘T | Neuer Tab · ⌘G Ingest · ⌘⌥U Aufgaben · ⌘⇧K Code-Ersetzungen |
|
||||
| Leertaste | Vorschau, Z = 100 % |
|
||||
|
||||
**IPTC-Info-Fenster:** ⌘⌥← / ⌘⌥→ = Speichern & vorheriges/nächstes Bild, ⌘↩ = OK, Esc = Abbrechen.
|
||||
Bei Mehrfachauswahl blättert das Fenster durch die Auswahl.
|
||||
Unter Einstellungen → Allgemein lässt sich auf die Lightroom-Belegung umstellen (0–5 = Sterne, 6–9 = Farben).
|
||||
|
||||
## Workflow RAW → SENT → FTP
|
||||
## Workflow INPUT → SENT → FTP
|
||||
|
||||
1. Karte einstecken. Das Ingest-Fenster öffnet sich, der Ingest läuft im Hintergrund (Aufgaben-Fenster ⌘⌥U).
|
||||
2. Im RAW-Ordner mit 1–5 und T sichten.
|
||||
3. Mit ⌘⌥L wendet Lightroom dein Preset an und exportiert die JPEGs nach `SENT`. Lichtkasten schreibt danach das
|
||||
Original-IPTC und öffnet den SENT-Ordner. Neue Dateien erscheinen live.
|
||||
4. Im SENT-Ordner mit **I** beschriften und mit „Speichern, Hochladen & →“ Bild für Bild hochladen.
|
||||
Alternativ alles auswählen und ⌘⇧U drücken.
|
||||
1. Karte einstecken. Das Ingest-Fenster öffnet sich, Ziel ist `~/Desktop/BILDER/INPUT`. Der Ingest läuft im Hintergrund.
|
||||
2. Sichten mit 1–8 (Farben), ⌥1–5 (Sterne) und T. Filter für Tag, Sterne und Farbklassen gibt es wie in PM über dem Kontaktabzug.
|
||||
3. Mit ⌘I das IPTC für alle ausgewählten Bilder setzen (Ereignis, Ort, Stichwörter …). Danach die Beschreibung mit **I** pro Bild anpassen.
|
||||
4. Mit ⌘⌥L exportiert Lightroom die JPEGs nach `~/Desktop/BILDER/SENT`, der Ordner öffnet sich automatisch.
|
||||
5. Mit ⌘U hochladen, oder im Info-Fenster Bild für Bild mit „Speichern, Hochladen & →“.
|
||||
|
||||
Metadaten werden mit mehreren exiftool-Prozessen parallel gelesen und pro Ordner zwischengespeichert
|
||||
(`~/Library/Caches/Lichtkasten`). Beim zweiten Öffnen eines Ordners sind sie sofort da.
|
||||
|
||||
## Lightroom-Bridge
|
||||
|
||||
|
||||
@@ -23,19 +23,33 @@ struct LichtkastenApp: App {
|
||||
.environmentObject(state)
|
||||
.environmentObject(state.uploads)
|
||||
.environmentObject(state.tasks)
|
||||
.frame(minWidth: 1000, minHeight: 640)
|
||||
.frame(minWidth: 1100, minHeight: 680)
|
||||
}
|
||||
.commands { AppCommands(state: state) }
|
||||
|
||||
// PM: "IPTC Info" as its own window (I / ⌘I)
|
||||
// PM: "Metadata (IPTC) Info" for one image (I)
|
||||
Window("IPTC-Info", id: "iptc") {
|
||||
IPTCInfoWindow()
|
||||
.environmentObject(state)
|
||||
.frame(minWidth: 980, minHeight: 640)
|
||||
.frame(minWidth: 1020, minHeight: 680)
|
||||
}
|
||||
.defaultSize(width: 1180, height: 760)
|
||||
.defaultSize(width: 1240, height: 860)
|
||||
|
||||
// PM: Tasks window – ingest, uploads, Lightroom
|
||||
// ⌘I – mass edit for the selection (PM template layout with checkboxes)
|
||||
Window("IPTC für Auswahl", id: "iptc-batch") {
|
||||
BatchEditWindow()
|
||||
.environmentObject(state)
|
||||
.frame(minWidth: 1200, minHeight: 700)
|
||||
}
|
||||
.defaultSize(width: 1400, height: 900)
|
||||
|
||||
// ⌘U – upload dialog
|
||||
Window("Hochladen", id: "upload") {
|
||||
UploadWindow().environmentObject(state)
|
||||
}
|
||||
.windowResizability(.contentSize)
|
||||
|
||||
// PM: Tasks window
|
||||
Window("Aufgaben", id: "tasks") {
|
||||
TasksWindow()
|
||||
.environmentObject(state)
|
||||
@@ -45,10 +59,16 @@ struct LichtkastenApp: App {
|
||||
}
|
||||
.defaultSize(width: 760, height: 520)
|
||||
|
||||
Window("Code-Ersetzungen", id: "codes") {
|
||||
CodesWindow()
|
||||
.environmentObject(state)
|
||||
.frame(minWidth: 640, minHeight: 480)
|
||||
}
|
||||
|
||||
Settings {
|
||||
SettingsView()
|
||||
.environmentObject(state)
|
||||
.frame(width: 720, height: 560)
|
||||
.frame(width: 760, height: 600)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +79,7 @@ struct AppCommands: Commands {
|
||||
var body: some Commands {
|
||||
CommandGroup(after: .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")
|
||||
@@ -73,27 +94,28 @@ struct AppCommands: Commands {
|
||||
Button("Auswahl aufheben") { state.deselectAll() }.keyboardShortcut("d")
|
||||
Divider()
|
||||
Button("Tag umschalten (T)") { state.toggleTag() }
|
||||
Menu("Bewertung") {
|
||||
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) }
|
||||
}
|
||||
}
|
||||
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() }
|
||||
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 }) {
|
||||
@@ -102,22 +124,23 @@ struct AppCommands: Commands {
|
||||
}.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-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) }
|
||||
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("FTP: \(d.name)") { state.upload(to: d.id.uuidString) }.keyboardShortcut("u", modifiers: [.command, .shift])
|
||||
Button("Sofort hochladen: \(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("Sofort hochladen: \(d.name)") { state.upload(to: d.id.uuidString) }
|
||||
}
|
||||
}
|
||||
Button("Zu Immich hochladen") { state.upload(to: "immich") }
|
||||
|
||||
@@ -2,23 +2,37 @@ import AppKit
|
||||
import SwiftUI
|
||||
import LichtkastenCore
|
||||
|
||||
enum ItemFilter: Hashable {
|
||||
case all, tagged, untagged, minRating(Int), label(ColorLabel)
|
||||
/// PM toolbar filters: Tag popup, star toggles, color class toggles.
|
||||
enum TagFilter: String, CaseIterable { case all = "Alle", tagged = "Getaggt", untagged = "Nicht getaggt" }
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .all: return "Alle"
|
||||
case .tagged: return "Getaggt"
|
||||
case .untagged: return "Nicht getaggt"
|
||||
case .minRating(let n): return "≥ \(n) ★"
|
||||
case .label(let l): return l.germanName
|
||||
struct PMFilter: Equatable {
|
||||
var tag: TagFilter = .all
|
||||
var ratingOn = false
|
||||
var ratings: Set<Int> = [] // 0…5
|
||||
var colorOn = false
|
||||
var colors: Set<Int> = [] // 0 = keine Farbklasse, 1…8
|
||||
|
||||
var isActive: Bool { tag != .all || (ratingOn && !ratings.isEmpty) || (colorOn && !colors.isEmpty) }
|
||||
|
||||
func matches(_ item: PhotoItem) -> Bool {
|
||||
switch tag {
|
||||
case .all: break
|
||||
case .tagged: if !item.tagged { return false }
|
||||
case .untagged: if item.tagged { return false }
|
||||
}
|
||||
if ratingOn && !ratings.isEmpty && !ratings.contains(item.rating) { return false }
|
||||
if colorOn && !colors.isEmpty && !colors.contains(item.label?.pmColorClass ?? 0) { return false }
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
enum SortOrder: String, CaseIterable {
|
||||
case captureTime = "Aufnahmezeit"
|
||||
case filename = "Dateiname"
|
||||
case fileDate = "Dateidatum"
|
||||
case colorClass = "Farbklasse"
|
||||
case rating = "Bewertung"
|
||||
case tagged = "Tag"
|
||||
}
|
||||
|
||||
/// Request to open a separate window (handled in ContentView, which has `openWindow`).
|
||||
@@ -39,8 +53,11 @@ final class AppState: ObservableObject {
|
||||
@Published var folder: URL?
|
||||
@Published var selection: Set<String> = []
|
||||
@Published var cursorID: String?
|
||||
@Published var filter: ItemFilter = .all { didSet { rebuildVisible() } }
|
||||
@Published var filter = PMFilter() { didSet { if filter != oldValue { rebuildVisible() } } }
|
||||
@Published var sortOrder: SortOrder = .captureTime { didSet { rebuildVisible() } }
|
||||
@Published var reverseSort = false { didSet { rebuildVisible() } }
|
||||
/// Open folders as tabs (like PM's contact sheet tabs).
|
||||
@Published var tabs: [URL] = []
|
||||
@Published var searchText = "" { didSet { rebuildVisible() } }
|
||||
@Published private(set) var visible: [PhotoItem] = []
|
||||
@Published var previewMode = false
|
||||
@@ -101,6 +118,16 @@ final class AppState: ObservableObject {
|
||||
|
||||
/// First launch: agency FTP profiles (host/user are placeholders – adjust in Settings → FTP).
|
||||
private func seedDefaultsIfNeeded() {
|
||||
// Leon's folder layout: ~/Desktop/BILDER/INPUT (ingest) and ~/Desktop/BILDER/SENT (JPEG export)
|
||||
if !UserDefaults.standard.bool(forKey: "seededBILDER") {
|
||||
UserDefaults.standard.set(true, forKey: "seededBILDER")
|
||||
let bilder = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Desktop/BILDER")
|
||||
let input = bilder.appendingPathComponent("INPUT").path, sent = bilder.appendingPathComponent("SENT").path
|
||||
for p in [input, sent] where !settings.favoriteFolders.contains(p) { settings.favoriteFolders.append(p) }
|
||||
if settings.ingest.primaryDestination.isEmpty { settings.ingest.primaryDestination = input }
|
||||
settings.lightroom.exportTarget = .fixed
|
||||
if settings.lightroom.exportFolder.isEmpty { settings.lightroom.exportFolder = sent }
|
||||
}
|
||||
guard settings.ftpDestinations.isEmpty, !UserDefaults.standard.bool(forKey: "seededFTP") else { return }
|
||||
UserDefaults.standard.set(true, forKey: "seededFTP")
|
||||
let host = "beautifulsports.ftp.xxx.com"
|
||||
@@ -133,6 +160,8 @@ final class AppState: ObservableObject {
|
||||
func resetExifTool() {
|
||||
exiftoolInstance?.shutdown()
|
||||
exiftoolInstance = nil
|
||||
readPool?.shutdown()
|
||||
readPool = nil
|
||||
}
|
||||
|
||||
// MARK: Folder loading
|
||||
@@ -146,7 +175,29 @@ final class AppState: ObservableObject {
|
||||
if panel.runModal() == .OK, let url = panel.url { open(folder: url) }
|
||||
}
|
||||
|
||||
func open(folder url: URL) {
|
||||
private struct TabSnapshot { var items: [PhotoItem]; var selection: Set<String>; var cursor: String? }
|
||||
private var tabSnapshots: [URL: TabSnapshot] = [:]
|
||||
|
||||
/// Opens a folder in the current tab (or switches to its tab if it is already open).
|
||||
func open(folder url: URL, newTab: Bool = false) {
|
||||
if let current = folder {
|
||||
tabSnapshots[current] = TabSnapshot(items: items, selection: selection, cursor: cursorID)
|
||||
}
|
||||
if !tabs.contains(url) {
|
||||
if newTab || tabs.isEmpty { tabs.append(url) }
|
||||
else if let cur = folder, let i = tabs.firstIndex(of: cur) { tabs[i] = url; tabSnapshots[cur] = nil }
|
||||
else { tabs.append(url) }
|
||||
}
|
||||
if let snap = tabSnapshots[url] {
|
||||
folder = url
|
||||
setItems(snap.items)
|
||||
selection = snap.selection
|
||||
cursorID = snap.cursor
|
||||
folderWatcher.watch(url)
|
||||
refreshFolder()
|
||||
statusText = "\(items.count) Bilder"
|
||||
return
|
||||
}
|
||||
folder = url
|
||||
settings.recentFolders.removeAll { $0 == url.path }
|
||||
settings.recentFolders.insert(url.path, at: 0)
|
||||
@@ -165,7 +216,41 @@ final class AppState: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func reload() { if let f = folder { open(folder: f) } }
|
||||
func reload() {
|
||||
guard let f = folder else { return }
|
||||
tabSnapshots[f] = nil
|
||||
metadataCache = nil
|
||||
let keep = (selection, cursorID)
|
||||
folder = nil
|
||||
open(folder: f)
|
||||
selection = keep.0.filter { indexByID[$0] != nil }
|
||||
cursorID = keep.1
|
||||
}
|
||||
|
||||
func closeTab(_ url: URL) {
|
||||
guard let i = tabs.firstIndex(of: url) else { return }
|
||||
tabs.remove(at: i)
|
||||
tabSnapshots[url] = nil
|
||||
if folder == url {
|
||||
folder = nil
|
||||
folderWatcher.watch(nil)
|
||||
if let next = tabs.isEmpty ? nil : tabs[min(i, tabs.count - 1)] {
|
||||
open(folder: next)
|
||||
} else {
|
||||
setItems([]); selection = []; cursorID = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func newTab() {
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseDirectories = true
|
||||
panel.canChooseFiles = false
|
||||
if panel.runModal() == .OK, let url = panel.url { open(folder: url, newTab: true) }
|
||||
}
|
||||
|
||||
/// Selected files total size (status bar).
|
||||
var selectedBytes: Int64 { selectedItems.reduce(0) { $0 + $1.fileSize } }
|
||||
|
||||
/// Re-scans the open folder, keeps loaded metadata/selection and reads only new files.
|
||||
func refreshFolder() {
|
||||
@@ -217,7 +302,10 @@ final class AppState: ObservableObject {
|
||||
func rawFolder(forSent sent: URL) -> URL {
|
||||
let parent = sent.deletingLastPathComponent()
|
||||
switch settings.lightroom.exportTarget {
|
||||
case .sentInside, .fixed: return parent
|
||||
case .sentInside: return parent
|
||||
case .fixed:
|
||||
let input = settings.ingest.primaryDestination
|
||||
return input.isEmpty ? parent : URL(fileURLWithPath: input)
|
||||
case .sentSibling:
|
||||
// pick the sibling that contains RAW files (e.g. "RAW"), else the parent
|
||||
let siblings = (try? FileManager.default.contentsOfDirectory(at: parent, includingPropertiesForKeys: [.isDirectoryKey])) ?? []
|
||||
@@ -305,15 +393,7 @@ final class AppState: ObservableObject {
|
||||
}
|
||||
|
||||
private func rebuildVisible() {
|
||||
var list = items.filter { item in
|
||||
switch filter {
|
||||
case .all: return true
|
||||
case .tagged: return item.tagged
|
||||
case .untagged: return !item.tagged
|
||||
case .minRating(let n): return item.rating >= n
|
||||
case .label(let l): return item.label == l
|
||||
}
|
||||
}
|
||||
var list = items.filter { filter.matches($0) }
|
||||
let q = searchText.trimmingCharacters(in: .whitespaces).lowercased()
|
||||
if !q.isEmpty {
|
||||
list = list.filter { item in
|
||||
@@ -327,43 +407,89 @@ final class AppState: ObservableObject {
|
||||
list.sort { $0.filename.localizedStandardCompare($1.filename) == .orderedAscending }
|
||||
case .captureTime:
|
||||
list.sort { ($0.captureDate ?? $0.modified, $0.filename) < ($1.captureDate ?? $1.modified, $1.filename) }
|
||||
case .fileDate:
|
||||
list.sort { ($0.modified, $0.filename) < ($1.modified, $1.filename) }
|
||||
case .colorClass:
|
||||
list.sort { ($0.label?.pmColorClass ?? 99, $0.filename) < ($1.label?.pmColorClass ?? 99, $1.filename) }
|
||||
case .rating:
|
||||
list.sort { (-$0.rating, $0.filename) < (-$1.rating, $1.filename) }
|
||||
case .tagged:
|
||||
list.sort { ($0.tagged ? 0 : 1, $0.filename) < ($1.tagged ? 0 : 1, $1.filename) }
|
||||
}
|
||||
if reverseSort { list.reverse() }
|
||||
visible = list
|
||||
visibleIndex = Dictionary(uniqueKeysWithValues: list.enumerated().map { ($1.id, $0) })
|
||||
}
|
||||
|
||||
private var readPool: ExifToolPool?
|
||||
private var metadataCache: MetadataCache?
|
||||
private var metadataGeneration = 0
|
||||
|
||||
/// Cache first (instant), then the remaining files with several exiftool processes in parallel.
|
||||
func loadMetadata(for snapshot: [PhotoItem]) async {
|
||||
guard let et = requireExifTool(), !snapshot.isEmpty else { return }
|
||||
guard !snapshot.isEmpty, let folder else { return }
|
||||
guard let exe = ExifTool.locate(custom: settings.exiftoolPath) else { _ = requireExifTool(); return }
|
||||
if readPool == nil { readPool = ExifToolPool(executable: exe) }
|
||||
if metadataCache == nil || metadataCacheFolder != folder {
|
||||
metadataCache?.save()
|
||||
metadataCache = MetadataCache(folder: folder)
|
||||
metadataCacheFolder = folder
|
||||
}
|
||||
guard let pool = readPool, let cache = metadataCache else { return }
|
||||
metadataGeneration += 1
|
||||
let generation = metadataGeneration
|
||||
loadingMetadata = true
|
||||
defer { loadingMetadata = false }
|
||||
let chunkSize = 40
|
||||
var start = 0
|
||||
while start < snapshot.count {
|
||||
let chunk = Array(snapshot[start..<min(start + chunkSize, snapshot.count)])
|
||||
start += chunkSize
|
||||
var files: [URL] = []
|
||||
for item in chunk {
|
||||
files.append(item.primary)
|
||||
if item.kind.usesSidecar, FileManager.default.fileExists(atPath: item.sidecarURL.path) {
|
||||
files.append(item.sidecarURL)
|
||||
}
|
||||
}
|
||||
do {
|
||||
let meta = try await et.readMetadata(files: files)
|
||||
for item in chunk {
|
||||
guard let idx = indexByID[item.id] else { continue }
|
||||
let sidecar = item.kind.usesSidecar ? meta[item.sidecarURL.path] : nil
|
||||
items[idx].apply(fileMeta: meta[item.primary.path] ?? [:], sidecarMeta: sidecar)
|
||||
}
|
||||
rebuildVisible()
|
||||
statusText = "Metadaten: \(min(start, snapshot.count))/\(snapshot.count)"
|
||||
} catch {
|
||||
statusText = "Fehler beim Lesen: \(error.localizedDescription)"
|
||||
|
||||
// 1. cache hits
|
||||
var missing: [PhotoItem] = []
|
||||
for item in snapshot {
|
||||
if let e = cache.lookup(item), let idx = indexByID[item.id] {
|
||||
items[idx].apply(fileMeta: e.file, sidecarMeta: e.sidecar)
|
||||
} else {
|
||||
missing.append(item)
|
||||
}
|
||||
}
|
||||
statusText = "\(items.count) Bilder"
|
||||
rebuildVisible()
|
||||
statusText = missing.isEmpty ? "\(items.count) Bilder" : "Metadaten: \(snapshot.count - missing.count)/\(snapshot.count)"
|
||||
|
||||
// 2. read the rest in parallel
|
||||
if !missing.isEmpty {
|
||||
var groups: [[URL]] = []
|
||||
var byPrimary: [String: PhotoItem] = [:]
|
||||
for item in missing {
|
||||
var g = [item.primary]
|
||||
byPrimary[item.primary.path] = item
|
||||
if item.kind.usesSidecar, FileManager.default.fileExists(atPath: item.sidecarURL.path) { g.append(item.sidecarURL) }
|
||||
groups.append(g)
|
||||
}
|
||||
final class Counter: @unchecked Sendable { var n = 0 }
|
||||
let done = Counter()
|
||||
done.n = snapshot.count - missing.count
|
||||
let total = snapshot.count
|
||||
await pool.readMetadata(groups: groups) { [weak self] meta in
|
||||
await MainActor.run {
|
||||
guard let self, self.metadataGeneration == generation else { return }
|
||||
for (path, fileMeta) in meta {
|
||||
guard let item = byPrimary[path], let idx = self.indexByID[item.id] else { continue }
|
||||
let sidecar = item.kind.usesSidecar ? meta[item.sidecarURL.path] : nil
|
||||
self.items[idx].apply(fileMeta: fileMeta, sidecarMeta: sidecar)
|
||||
cache.store(item, file: fileMeta, sidecar: sidecar)
|
||||
done.n += 1
|
||||
}
|
||||
self.rebuildVisible()
|
||||
self.statusText = "Metadaten: \(done.n)/\(total)"
|
||||
}
|
||||
}
|
||||
cache.save()
|
||||
}
|
||||
if metadataGeneration == generation {
|
||||
loadingMetadata = false
|
||||
statusText = "\(items.count) Bilder"
|
||||
}
|
||||
}
|
||||
|
||||
private var metadataCacheFolder: URL?
|
||||
|
||||
// MARK: Selection
|
||||
|
||||
func item(_ id: String) -> PhotoItem? { indexByID[id].map { items[$0] } }
|
||||
@@ -424,26 +550,26 @@ final class AppState: ObservableObject {
|
||||
return selectedItems
|
||||
}
|
||||
|
||||
private func advanceIfSingle(_ count: Int) {
|
||||
if settings.autoAdvance && count == 1 { moveCursor(by: 1) }
|
||||
private func advanceIfSingle(_ count: Int, _ allowed: Bool = true) {
|
||||
if allowed && settings.autoAdvance && count == 1 { moveCursor(by: 1) }
|
||||
}
|
||||
|
||||
func setRating(_ n: Int) {
|
||||
let targets = actionTargets
|
||||
func setRating(_ n: Int, advance: Bool = true, only: PhotoItem? = nil) {
|
||||
let targets = only.map { [$0] } ?? actionTargets
|
||||
guard !targets.isEmpty, let w = writer else { return }
|
||||
mutate(targets) { $0.rating = n }
|
||||
Task { for t in targets { do { try await w.writeRating(n, to: t) } catch { report(error) } } }
|
||||
advanceIfSingle(targets.count)
|
||||
advanceIfSingle(targets.count, advance)
|
||||
}
|
||||
|
||||
func setLabel(_ l: ColorLabel?) {
|
||||
let targets = actionTargets
|
||||
func setLabel(_ l: ColorLabel?, advance: Bool = true, only: PhotoItem? = nil) {
|
||||
let targets = only.map { [$0] } ?? actionTargets
|
||||
guard !targets.isEmpty, let w = writer else { return }
|
||||
// Same label again toggles it off (LR behaviour).
|
||||
let newLabel: ColorLabel? = targets.allSatisfy({ $0.label == l }) ? nil : l
|
||||
mutate(targets) { $0.label = newLabel }
|
||||
Task { for t in targets { do { try await w.writeLabel(newLabel, to: t) } catch { report(error) } } }
|
||||
advanceIfSingle(targets.count)
|
||||
advanceIfSingle(targets.count, advance)
|
||||
}
|
||||
|
||||
func toggleTag() {
|
||||
@@ -518,7 +644,7 @@ final class AppState: ObservableObject {
|
||||
|
||||
func applyTemplateAndWait(_ template: IPTCTemplate, to targets: [PhotoItem]) async {
|
||||
guard !targets.isEmpty, let w = writer else { return }
|
||||
settings.lastTemplateID = template.id
|
||||
if templates.contains(where: { $0.id == template.id }) { settings.lastTemplateID = template.id }
|
||||
statusText = "Wende Vorlage „\(template.name)“ an …"
|
||||
do {
|
||||
let result = try await w.apply(template: template, to: targets, codes: codes, dateFormat: settings.dateFormat)
|
||||
|
||||
@@ -47,16 +47,22 @@ final class KeyboardMonitor {
|
||||
if c == "z", state.previewMode { state.zoom100.toggle(); return true }
|
||||
guard let digit = c.wholeNumberValue else { return false }
|
||||
|
||||
// Number keys = stars in both schemes (like PM with "number keys set rating").
|
||||
if !mods.contains(.option), digit <= 5 { state.setRating(digit); return true }
|
||||
switch state.settings.keyScheme {
|
||||
case .photoMechanic:
|
||||
// PM: 1–8 = color class, 0 = none · ⌥1–5 = stars, ⌥0 = no stars
|
||||
if mods.contains(.option) {
|
||||
guard digit <= 5 else { return false }
|
||||
state.setRating(digit)
|
||||
} else if digit == 0 {
|
||||
state.setLabel(nil)
|
||||
} else if let l = ColorLabel(pmColorClass: digit) {
|
||||
state.setLabel(l)
|
||||
} else { return false }
|
||||
case .lightroom:
|
||||
if digit <= 5 { state.setRating(digit); return true }
|
||||
let map: [Int: ColorLabel] = [6: .red, 7: .yellow, 8: .green, 9: .blue]
|
||||
guard let l = map[digit] else { return false }
|
||||
state.setLabel(l)
|
||||
case .photoMechanic:
|
||||
guard mods.contains(.option) else { return false }
|
||||
if digit == 0 { state.setLabel(nil) } else if let l = ColorLabel(pmColorClass: digit) { state.setLabel(l) } else { return false }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ enum KeyScheme: String, Codable, CaseIterable {
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .photoMechanic: return "Photo Mechanic: 1–5 = Sterne, 0 = keine, ⌥1–5 = Farbklasse"
|
||||
case .lightroom: return "Lightroom: 1–5 = Sterne, 6–9 = Rot/Gelb/Grün/Blau"
|
||||
case .photoMechanic: return "Photo Mechanic: 1–8 = Farbklasse, 0 = keine, ⌥1–5 = Sterne"
|
||||
case .lightroom: return "Lightroom: 0–5 = Sterne, 6–9 = Rot/Gelb/Grün/Blau"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import SwiftUI
|
||||
import LichtkastenCore
|
||||
|
||||
/// ⌘I – mass edit for all selected images in PM's template layout (checkbox = write this field).
|
||||
/// Typical use: set event, location, keywords for all, then fine-tune each caption with I.
|
||||
struct BatchEditWindow: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
@State private var texts: FieldTexts = [:]
|
||||
@State private var mixed: Set<String> = []
|
||||
@State private var applied: Set<String> = []
|
||||
@State private var keywordMode: ListMergeMode = .replace
|
||||
@State private var dateFromCapture = false
|
||||
@State private var saving = false
|
||||
@State private var showSave = false
|
||||
@State private var templateName = ""
|
||||
|
||||
private var targets: [PhotoItem] { state.selectedItems }
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
HStack {
|
||||
Text(targets.count == 1 ? "1 Bild ausgewählt" : "\(targets.count) Bilder ausgewählt").font(.headline)
|
||||
Spacer()
|
||||
Picker("Stichwörter", selection: $keywordMode) {
|
||||
ForEach(ListMergeMode.allCases, id: \.self) { Text($0.rawValue).tag($0) }
|
||||
}
|
||||
.fixedSize()
|
||||
Toggle("Datum = Aufnahmezeit", isOn: $dateFromCapture)
|
||||
}
|
||||
.padding(12)
|
||||
Divider()
|
||||
ScrollView {
|
||||
PMMetadataForm(texts: $texts, columns: 2, mixed: mixed, applied: $applied, codes: state.codes)
|
||||
.padding(14)
|
||||
}
|
||||
Divider()
|
||||
HStack(spacing: 8) {
|
||||
Button("Leeren") { texts = [:]; applied = [] }
|
||||
Menu("Laden …") {
|
||||
ForEach(state.templates) { t in Button(t.name) { load(template: t) } }
|
||||
if state.templates.isEmpty { Text("Noch keine Vorlagen") }
|
||||
Divider()
|
||||
Button("Photo-Mechanic-Vorlage importieren …") { state.importPMTemplate() }
|
||||
}
|
||||
.fixedSize()
|
||||
Button("Speichern …") { templateName = ""; showSave = true }
|
||||
Button("Variablen …") { state.openWindow("codes") }
|
||||
.help("Variablen und Code-Ersetzungen")
|
||||
Spacer()
|
||||
if saving { ProgressView().controlSize(.small) }
|
||||
Button("Auf Auswahl anwenden") { apply() }
|
||||
.keyboardShortcut(.return, modifiers: .command)
|
||||
.buttonStyle(.borderedProminent)
|
||||
.disabled(applied.isEmpty || targets.isEmpty || saving)
|
||||
Button("Schließen") { dismissWindow(id: "iptc-batch") }.keyboardShortcut(.cancelAction)
|
||||
}
|
||||
.padding(12)
|
||||
}
|
||||
.navigationTitle("IPTC für Auswahl bearbeiten")
|
||||
.onAppear(perform: loadFromSelection)
|
||||
.onChange(of: state.selection) { _, _ in if applied.isEmpty { loadFromSelection() } }
|
||||
.alert("Als Vorlage speichern", isPresented: $showSave) {
|
||||
TextField("Name", text: $templateName)
|
||||
Button("Speichern") {
|
||||
state.templates.append(IPTCTemplate(name: templateName.isEmpty ? "Neue Vorlage" : templateName,
|
||||
values: IPTCValues(texts: texts), listMergeMode: keywordMode,
|
||||
appliedFields: applied, dateFromCapture: dateFromCapture))
|
||||
}
|
||||
Button("Abbrechen", role: .cancel) {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows the values all selected images share; differing fields stay empty ("mehrere Werte").
|
||||
private func loadFromSelection() {
|
||||
guard let first = targets.first else { texts = [:]; mixed = []; return }
|
||||
var t = first.iptc.texts()
|
||||
var m = Set<String>()
|
||||
for item in targets.dropFirst() {
|
||||
let other = item.iptc.texts()
|
||||
for f in IPTCField.all where (other[f.id] ?? "") != (t[f.id] ?? "") || m.contains(f.id) {
|
||||
m.insert(f.id)
|
||||
t[f.id] = ""
|
||||
}
|
||||
}
|
||||
texts = t
|
||||
mixed = m
|
||||
applied = []
|
||||
}
|
||||
|
||||
private func load(template t: IPTCTemplate) {
|
||||
let tt = t.values.texts()
|
||||
for f in IPTCField.all {
|
||||
let use = t.appliedFields?.contains(f.id) ?? !t.values.isEmpty(f)
|
||||
if use { texts[f.id] = tt[f.id] ?? ""; applied.insert(f.id) }
|
||||
}
|
||||
keywordMode = t.listMergeMode
|
||||
dateFromCapture = t.dateFromCapture
|
||||
}
|
||||
|
||||
private func apply() {
|
||||
let template = IPTCTemplate(name: "Mass-Edit", values: IPTCValues(texts: texts), listMergeMode: keywordMode,
|
||||
appliedFields: applied, dateFromCapture: dateFromCapture)
|
||||
let items = targets
|
||||
saving = true
|
||||
Task {
|
||||
await state.applyTemplateAndWait(template, to: items)
|
||||
saving = false
|
||||
loadFromSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
import LichtkastenCore
|
||||
|
||||
/// PM "Code Replacements": table editor, import/export of PM's tab-delimited file, live test.
|
||||
struct CodesWindow: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@State private var rows: [Row] = []
|
||||
@State private var selection: Set<Row.ID> = []
|
||||
@State private var test = "\\vfl\\ gegen \\tsg\\"
|
||||
|
||||
struct Row: Identifiable, Hashable {
|
||||
let id = UUID()
|
||||
var code: String
|
||||
var columns: String // replacement columns separated by " | "
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
HStack {
|
||||
Text("Code-Ersetzungen").font(.title3.bold())
|
||||
Spacer()
|
||||
Text("Trennzeichen:")
|
||||
TextField("", text: Binding(get: { String(state.codes.delimiter) },
|
||||
set: { if let c = $0.last { state.codes.delimiter = c } }))
|
||||
.frame(width: 30)
|
||||
}
|
||||
Text("Tippe im IPTC-Feld \\code\\ – sobald das schließende Trennzeichen getippt wird, ersetzt Lichtkasten den Code (wie PM). \\code#2\\ nimmt Spalte 2.")
|
||||
.font(.caption).foregroundStyle(.secondary)
|
||||
HStack {
|
||||
Text("Code").frame(width: 140, alignment: .leading)
|
||||
Text("Ersetzung (weitere Spalten mit „ | “ trennen)")
|
||||
}
|
||||
.font(.caption.bold())
|
||||
List(selection: $selection) {
|
||||
ForEach($rows) { $r in
|
||||
HStack {
|
||||
TextField("", text: $r.code).frame(width: 140)
|
||||
TextField("", text: $r.columns)
|
||||
}
|
||||
.tag(r.id)
|
||||
}
|
||||
}
|
||||
.onChange(of: rows) { _, _ in commit() }
|
||||
HStack {
|
||||
Button { rows.append(Row(code: "", columns: "")) } label: { Image(systemName: "plus") }
|
||||
Button { rows.removeAll { selection.contains($0.id) }; commit() } label: { Image(systemName: "minus") }
|
||||
.disabled(selection.isEmpty)
|
||||
Spacer()
|
||||
Button("Datei laden (PM-Format) …") { state.importCodeReplacements(); load() }
|
||||
Button("Exportieren …") { export() }
|
||||
}
|
||||
Divider()
|
||||
HStack {
|
||||
TextField("Test", text: $test).textFieldStyle(.roundedBorder)
|
||||
Image(systemName: "arrow.right")
|
||||
Text(state.codes.expand(test)).textSelection(.enabled).frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
Divider()
|
||||
DisclosureGroup("Variablen") {
|
||||
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())], alignment: .leading) {
|
||||
ForEach(VariableExpander.documented, id: \.0) { v in
|
||||
HStack { Text(v.0).font(.system(.caption, design: .monospaced)).textSelection(.enabled); Text(v.1).font(.caption).foregroundStyle(.secondary) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(16)
|
||||
.onAppear(perform: load)
|
||||
}
|
||||
|
||||
private func load() {
|
||||
rows = state.codes.table.sorted { $0.key < $1.key }.map { Row(code: $0.key, columns: $0.value.joined(separator: " | ")) }
|
||||
}
|
||||
|
||||
private func commit() {
|
||||
var table: [String: [String]] = [:]
|
||||
for r in rows where !r.code.trimmingCharacters(in: .whitespaces).isEmpty {
|
||||
table[r.code.trimmingCharacters(in: .whitespaces).lowercased()] =
|
||||
r.columns.components(separatedBy: " | ").map { $0.trimmingCharacters(in: .whitespaces) }
|
||||
}
|
||||
if table != state.codes.table { state.codes.table = table }
|
||||
}
|
||||
|
||||
private func export() {
|
||||
let p = NSSavePanel()
|
||||
p.nameFieldStringValue = "Codes.txt"
|
||||
guard p.runModal() == .OK, let url = p.url else { return }
|
||||
let text = state.codes.table.sorted { $0.key < $1.key }
|
||||
.map { ([$0.key] + $0.value).joined(separator: "\t") }.joined(separator: "\n") + "\n"
|
||||
try? text.write(to: url, atomically: true, encoding: .utf8)
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ struct ContactSheetView: View {
|
||||
}
|
||||
.padding(10)
|
||||
}
|
||||
.background(Color(nsColor: .underPageBackgroundColor))
|
||||
.background(Color(white: 0.22))
|
||||
.onChange(of: state.cursorID) { _, id in
|
||||
if let id { proxy.scrollTo(id) }
|
||||
}
|
||||
@@ -60,7 +60,8 @@ struct ItemContextMenu: View {
|
||||
let item: PhotoItem
|
||||
|
||||
var body: some View {
|
||||
Button("IPTC-Info …") { ensureSelected(); state.openWindow("iptc") }
|
||||
Button("IPTC-Info … (I)") { ensureSelected(); state.openWindow("iptc") }
|
||||
Button("IPTC für Auswahl … (⌘I)") { ensureSelected(); state.openWindow("iptc-batch") }
|
||||
Button("Tag umschalten") { ensureSelected(); state.toggleTag() }
|
||||
Menu("Bewertung") {
|
||||
ForEach(0...5, id: \.self) { n in
|
||||
@@ -68,7 +69,8 @@ struct ItemContextMenu: View {
|
||||
}
|
||||
}
|
||||
Menu("Farbmarkierung") {
|
||||
ForEach(ColorLabel.allCases, id: \.self) { l in Button(l.germanName) { ensureSelected(); state.setLabel(l) } }
|
||||
ForEach(ColorLabel.allCases, id: \.self) { l in Button("\(l.pmColorClass) – \(l.germanName)") { ensureSelected(); state.setLabel(l) } }
|
||||
Button("0 – Keine") { ensureSelected(); state.setLabel(nil) }
|
||||
}
|
||||
Divider()
|
||||
Button("In Lightroom bearbeiten (⌘E)") { ensureSelected(); state.sendToLightroom(export: false, develop: true) }
|
||||
@@ -98,64 +100,89 @@ struct ThumbnailCell: View, Equatable {
|
||||
a.item == b.item && a.size == b.size && a.selected == b.selected && a.isCursor == b.isCursor && a.imageURL == b.imageURL
|
||||
}
|
||||
|
||||
private static let captionField = IPTCField.byID["caption"]!
|
||||
/// PM shows the selection as a pale yellow card.
|
||||
private static let selectedFill = Color(red: 0.93, green: 0.96, blue: 0.68)
|
||||
|
||||
private var dateLine: String {
|
||||
guard let d = item.captureDate else { return "" }
|
||||
return ThumbnailCell.dateFormatter.string(from: d)
|
||||
}
|
||||
|
||||
private static let dateFormatter: DateFormatter = {
|
||||
let f = DateFormatter()
|
||||
f.dateFormat = "dd.MM.yyyy - HH:mm:ss"
|
||||
return f
|
||||
}()
|
||||
|
||||
private var cameraLine: String {
|
||||
var lens: [String] = []
|
||||
if let fl = item.exif["FocalLength"] { lens.append(fl.replacingOccurrences(of: ".0 mm", with: "mm").replacingOccurrences(of: " mm", with: "mm")) }
|
||||
if let f = item.exif["FNumber"] { lens.append(f) }
|
||||
let left = lens.joined(separator: " ")
|
||||
let model = item.exif["Model"] ?? ""
|
||||
return [left, model].filter { !$0.isEmpty }.joined(separator: " - ")
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 4) {
|
||||
let textColor: Color = selected ? .black : .primary
|
||||
VStack(spacing: 2) {
|
||||
ZStack {
|
||||
Rectangle().fill(Color.black.opacity(0.25))
|
||||
if let image {
|
||||
Image(nsImage: image).resizable().interpolation(.medium).scaledToFit()
|
||||
.shadow(color: .black.opacity(0.4), radius: 2, y: 1)
|
||||
} else {
|
||||
ProgressView().controlSize(.small)
|
||||
}
|
||||
}
|
||||
.frame(width: size - 12, height: (size - 12) * 0.72)
|
||||
.clipped()
|
||||
.frame(width: size - 14, height: (size - 14) * 0.75)
|
||||
.padding(.top, 6)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
Text(item.filename).lineLimit(1).truncationMode(.middle)
|
||||
Text(dateLine).lineLimit(1)
|
||||
Text(item.iptc.text["headline"] ?? " ").lineLimit(1).truncationMode(.middle)
|
||||
Text(cameraLine.isEmpty ? " " : cameraLine).lineLimit(1)
|
||||
}
|
||||
.font(.system(size: 11))
|
||||
.foregroundStyle(textColor)
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
HStack(spacing: 6) {
|
||||
// PM: color class bar with the rating dots/stars inside
|
||||
ZStack {
|
||||
Capsule().fill(item.label?.color ?? Color.gray.opacity(0.35))
|
||||
HStack(spacing: 6) {
|
||||
ForEach(1...5, id: \.self) { n in
|
||||
if n <= item.rating {
|
||||
Image(systemName: "star.fill").font(.system(size: 8))
|
||||
} else {
|
||||
Circle().frame(width: 3, height: 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
.foregroundStyle(item.label == nil ? Color.primary.opacity(0.6) : Color.white)
|
||||
}
|
||||
.frame(height: 12)
|
||||
|
||||
HStack(spacing: 4) {
|
||||
Button(action: onTagClick) {
|
||||
Image(systemName: item.tagged ? "checkmark.square.fill" : "square")
|
||||
.foregroundStyle(item.tagged ? Color.accentColor : .secondary)
|
||||
.font(.system(size: 14))
|
||||
.foregroundStyle(item.tagged ? (selected ? Color.black : Color.white) : Color.secondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Tag (T)")
|
||||
|
||||
Text(item.filename).font(.caption).lineLimit(1).truncationMode(.middle)
|
||||
Spacer(minLength: 2)
|
||||
if !item.companions.isEmpty {
|
||||
Text("+\(item.companions.map { $0.pathExtension.uppercased() }.joined(separator: "+"))")
|
||||
.font(.system(size: 9, weight: .semibold))
|
||||
.padding(.horizontal, 3)
|
||||
.background(RoundedRectangle(cornerRadius: 3).fill(Color.secondary.opacity(0.25)))
|
||||
}
|
||||
}
|
||||
HStack(spacing: 1) {
|
||||
ForEach(1...5, id: \.self) { n in
|
||||
Image(systemName: n <= item.rating ? "star.fill" : "star")
|
||||
.font(.system(size: 9))
|
||||
.foregroundStyle(n <= item.rating ? Color.yellow : Color.secondary.opacity(0.4))
|
||||
}
|
||||
Spacer()
|
||||
if !item.iptc.isEmpty(Self.captionField) {
|
||||
Image(systemName: "text.alignleft").font(.system(size: 9)).foregroundStyle(.secondary)
|
||||
.help("Hat Bildunterschrift")
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.bottom, 6)
|
||||
}
|
||||
.padding(6)
|
||||
.frame(width: size)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.fill(selected ? Color.accentColor.opacity(0.35) : Color.gray.opacity(0.14))
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
.fill(selected ? ThumbnailCell.selectedFill : Color(white: 0.30))
|
||||
)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.strokeBorder(item.label.map(\.color) ?? .clear, lineWidth: 3)
|
||||
)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.strokeBorder(isCursor ? Color.white.opacity(0.9) : .clear, lineWidth: 1)
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
.strokeBorder(isCursor ? Color.accentColor : .clear, lineWidth: 2)
|
||||
)
|
||||
.task(id: imageURL) {
|
||||
image = ImageLoader.shared.cachedThumbnail(imageURL)
|
||||
@@ -171,7 +198,10 @@ extension ColorLabel {
|
||||
case .yellow: return .yellow
|
||||
case .green: return .green
|
||||
case .blue: return .blue
|
||||
case .purple: return .purple
|
||||
case .purple: return Color(red: 0.85, green: 0.2, blue: 0.85)
|
||||
case .cyan: return .cyan
|
||||
case .orange: return .orange
|
||||
case .gray: return Color(white: 0.45)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import SwiftUI
|
||||
import LichtkastenCore
|
||||
|
||||
/// Main browser window in Photo Mechanic's layout:
|
||||
/// sidebar (Favorites / Navigator / Tasks) · tabs · filter bar · contact sheet · status bar.
|
||||
struct ContentView: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@EnvironmentObject var uploads: UploadQueue
|
||||
@@ -9,10 +11,13 @@ struct ContentView: View {
|
||||
|
||||
var body: some View {
|
||||
NavigationSplitView {
|
||||
SidebarView()
|
||||
.navigationSplitViewColumnWidth(min: 180, ideal: 220)
|
||||
PMSidebar()
|
||||
.navigationSplitViewColumnWidth(min: 200, ideal: 260, max: 420)
|
||||
} detail: {
|
||||
VStack(spacing: 0) {
|
||||
TabBar()
|
||||
if state.folder != nil { ContactSheetHeader() }
|
||||
Divider()
|
||||
if state.folder == nil {
|
||||
EmptyStateView()
|
||||
} else if state.previewMode {
|
||||
@@ -20,11 +25,7 @@ struct ContentView: View {
|
||||
} else {
|
||||
ContactSheetView()
|
||||
}
|
||||
StatusBar()
|
||||
}
|
||||
.inspector(isPresented: $state.showInspector) {
|
||||
IPTCInspectorView()
|
||||
.inspectorColumnWidth(min: 300, ideal: 360, max: 520)
|
||||
PMStatusBar()
|
||||
}
|
||||
}
|
||||
.navigationTitle(state.folder?.lastPathComponent ?? "Lichtkasten")
|
||||
@@ -36,7 +37,7 @@ struct ContentView: View {
|
||||
if let req { openWindow(id: req.id) }
|
||||
}
|
||||
.sheet(isPresented: $state.showTemplatePicker) { TemplatePickerSheet() }
|
||||
.sheet(isPresented: $state.showTemplateManager) { TemplateManagerView().frame(minWidth: 900, minHeight: 620) }
|
||||
.sheet(isPresented: $state.showTemplateManager) { TemplateManagerView().frame(minWidth: 1280, minHeight: 760) }
|
||||
.sheet(isPresented: $state.showIngest) { IngestView() }
|
||||
.alert(item: $state.alert) { a in
|
||||
Alert(title: Text(a.title), message: Text(a.message), dismissButton: .default(Text("OK")))
|
||||
@@ -49,7 +50,7 @@ struct EmptyStateView: View {
|
||||
var body: some View {
|
||||
VStack(spacing: 16) {
|
||||
Image(systemName: "photo.on.rectangle.angled").font(.system(size: 56)).foregroundStyle(.secondary)
|
||||
Text("Ordner öffnen oder Karte ingesten").font(.title2)
|
||||
Text("Ordner in Favoriten oder Navigator wählen").font(.title2)
|
||||
HStack {
|
||||
Button("Ordner öffnen … (⌘O)") { state.chooseFolder() }
|
||||
Button("Ingest … (⌘G)") { state.showIngest = true }
|
||||
@@ -60,6 +61,8 @@ struct EmptyStateView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Toolbar (actions only – filters live in the contact sheet header like PM)
|
||||
|
||||
struct MainToolbar: ToolbarContent {
|
||||
@EnvironmentObject var state: AppState
|
||||
@EnvironmentObject var uploads: UploadQueue
|
||||
@@ -67,65 +70,34 @@ struct MainToolbar: ToolbarContent {
|
||||
|
||||
var body: some ToolbarContent {
|
||||
ToolbarItemGroup(placement: .navigation) {
|
||||
Button { state.chooseFolder() } label: { Label("Öffnen", systemImage: "folder") }
|
||||
Button { state.toggleRawSent() } label: {
|
||||
Label(state.isInSentFolder ? "RAW" : state.sentFolderName,
|
||||
systemImage: state.isInSentFolder ? "camera" : "paperplane")
|
||||
}
|
||||
.help(state.isInSentFolder ? "Zum RAW-Ordner (⌘⌥S)" : "Zum \(state.sentFolderName)-Ordner (⌘⌥S)")
|
||||
.help(state.isInSentFolder ? "Zum RAW/INPUT-Ordner (⌘⌥S)" : "Zum \(state.sentFolderName)-Ordner (⌘⌥S)")
|
||||
.disabled(state.folder == nil)
|
||||
}
|
||||
ToolbarItemGroup(placement: .primaryAction) {
|
||||
Picker("Filter", selection: $state.filter) {
|
||||
Text("Alle").tag(ItemFilter.all)
|
||||
Text("Getaggt").tag(ItemFilter.tagged)
|
||||
Text("Nicht getaggt").tag(ItemFilter.untagged)
|
||||
Divider()
|
||||
ForEach(1...5, id: \.self) { n in Text("≥ \(n) ★").tag(ItemFilter.minRating(n)) }
|
||||
Divider()
|
||||
ForEach(ColorLabel.allCases, id: \.self) { l in Text(l.germanName).tag(ItemFilter.label(l)) }
|
||||
}
|
||||
.frame(width: 130)
|
||||
.help("Filter")
|
||||
|
||||
Picker("Sortierung", selection: $state.sortOrder) {
|
||||
ForEach(SortOrder.allCases, id: \.self) { Text($0.rawValue).tag($0) }
|
||||
}
|
||||
.frame(width: 130)
|
||||
|
||||
Slider(value: $state.settings.thumbnailSize, in: 110...420)
|
||||
.frame(width: 110)
|
||||
.help("Vorschaugröße")
|
||||
|
||||
Button { state.showTemplatePicker = true } label: { Label("Vorlage", systemImage: "text.badge.plus") }
|
||||
.help("IPTC-Vorlage anwenden (⌘⇧I)")
|
||||
|
||||
Button { state.showIngest = true } label: { Label("Ingest", systemImage: "sdcard") }
|
||||
.help("Ingest (⌘G)")
|
||||
Button { state.openWindow("iptc") } label: { Label("Info", systemImage: "info.circle") }
|
||||
.help("IPTC-Info für ein Bild (I)")
|
||||
Button { state.openWindow("iptc-batch") } label: { Label("Auswahl", systemImage: "square.stack.3d.up") }
|
||||
.help("IPTC für alle ausgewählten Bilder (⌘I)")
|
||||
Menu {
|
||||
Button("Bearbeiten (⌘E)") { state.sendToLightroom(export: false, develop: true) }
|
||||
Button("Nur importieren (⌘⇧L)") { state.sendToLightroom(export: false) }
|
||||
Button("Importieren + Vorgabe + JPEG (⌘⌥L)") { state.sendToLightroom(export: true) }
|
||||
Button("Vorgabe + JPEG nach SENT (⌘⌥L)") { state.sendToLightroom(export: true) }
|
||||
} label: {
|
||||
Label("Lightroom", systemImage: "square.and.arrow.up.on.square")
|
||||
Label("Lightroom", systemImage: "camera.aperture")
|
||||
} primaryAction: {
|
||||
state.sendToLightroom(export: false, develop: true)
|
||||
}
|
||||
.help("Auswahl an Lightroom Classic senden")
|
||||
|
||||
Menu {
|
||||
ForEach(state.settings.ftpDestinations) { d in
|
||||
Button("FTP: \(d.name)") { state.upload(to: d.id.uuidString) }
|
||||
}
|
||||
if state.settings.immich.enabled {
|
||||
Button("Immich") { state.upload(to: "immich") }
|
||||
}
|
||||
Divider()
|
||||
Button("Aufgaben-Fenster …") { state.openWindow("tasks") }
|
||||
} label: {
|
||||
.help("In Lightroom Classic bearbeiten (⌘E)")
|
||||
Button { state.openWindow("upload") } label: {
|
||||
Label(uploads.activeCount > 0 ? "Upload (\(uploads.activeCount))" : "Upload", systemImage: "icloud.and.arrow.up")
|
||||
}
|
||||
|
||||
Button { state.openWindow("iptc") } label: { Label("IPTC", systemImage: "info.circle") }
|
||||
.help("IPTC-Info (I / ⌘I)")
|
||||
.help("Upload-Fenster (⌘U)")
|
||||
Button { state.openWindow("tasks") } label: {
|
||||
Label(tasks.runningCount > 0 ? "Aufgaben (\(tasks.runningCount))" : "Aufgaben", systemImage: "list.bullet.rectangle")
|
||||
}
|
||||
@@ -133,83 +105,341 @@ struct MainToolbar: ToolbarContent {
|
||||
}
|
||||
}
|
||||
|
||||
struct StatusBar: View {
|
||||
// MARK: - Tabs
|
||||
|
||||
struct TabBar: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(state.tabs, id: \.self) { url in
|
||||
let active = state.folder == url
|
||||
HStack(spacing: 6) {
|
||||
Button { state.closeTab(url) } label: { Image(systemName: "xmark.circle.fill") }
|
||||
.buttonStyle(.plain).foregroundStyle(.secondary)
|
||||
Image(systemName: "folder.fill").foregroundStyle(.secondary)
|
||||
Text(url.lastPathComponent).lineLimit(1)
|
||||
if active {
|
||||
Text("\(state.visible.count)")
|
||||
.font(.caption.monospacedDigit())
|
||||
.padding(.horizontal, 5)
|
||||
.background(Capsule().fill(Color.secondary.opacity(0.3)))
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 3)
|
||||
.background(RoundedRectangle(cornerRadius: 5).fill(active ? Color.secondary.opacity(0.28) : Color.clear))
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { state.open(folder: url) }
|
||||
.help(url.path)
|
||||
}
|
||||
Button { state.newTab() } label: { Image(systemName: "plus.circle") }
|
||||
.buttonStyle(.plain)
|
||||
.help("Neuer Tab")
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 4)
|
||||
.background(.bar)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - PM filter bar
|
||||
|
||||
struct ContactSheetHeader: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 12) {
|
||||
Slider(value: $state.settings.thumbnailSize, in: 140...460)
|
||||
.frame(width: 140)
|
||||
.help("Vorschaugröße")
|
||||
|
||||
Picker("", selection: $state.sortOrder) {
|
||||
ForEach(SortOrder.allCases, id: \.self) { Text($0.rawValue).tag($0) }
|
||||
}
|
||||
.labelsHidden()
|
||||
.frame(width: 140)
|
||||
Toggle("Umkehren", isOn: $state.reverseSort).toggleStyle(.checkbox)
|
||||
|
||||
Picker("", selection: $state.filter.tag) {
|
||||
ForEach(TagFilter.allCases, id: \.self) { Text($0.rawValue).tag($0) }
|
||||
}
|
||||
.labelsHidden()
|
||||
.frame(width: 130)
|
||||
|
||||
Spacer(minLength: 8)
|
||||
|
||||
// Stars filter (PM: checkbox + 0★…5★ toggles)
|
||||
Toggle("", isOn: $state.filter.ratingOn).toggleStyle(.checkbox).labelsHidden()
|
||||
.help("Nach Sternen filtern")
|
||||
HStack(spacing: 0) {
|
||||
ForEach(0...5, id: \.self) { n in
|
||||
let on = state.filter.ratings.contains(n)
|
||||
Button { toggle(rating: n) } label: {
|
||||
Text("\(n)★").font(.system(size: 11, weight: on ? .bold : .regular))
|
||||
.frame(width: 30, height: 20)
|
||||
.background(on ? Color.accentColor.opacity(0.45) : Color.secondary.opacity(0.15))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
.opacity(state.filter.ratingOn ? 1 : 0.5)
|
||||
|
||||
// Color class filter (PM: checkbox + color swatches, last = no color)
|
||||
Toggle("", isOn: $state.filter.colorOn).toggleStyle(.checkbox).labelsHidden()
|
||||
.help("Nach Farbklasse filtern")
|
||||
HStack(spacing: 0) {
|
||||
ForEach(ColorLabel.allCases, id: \.self) { l in
|
||||
swatch(l.color, n: l.pmColorClass, help: "\(l.pmColorClass) – \(l.germanName)")
|
||||
}
|
||||
swatch(.clear, n: 0, help: "Ohne Farbklasse")
|
||||
}
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
.opacity(state.filter.colorOn ? 1 : 0.5)
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
|
||||
private func swatch(_ c: Color, n: Int, help: String) -> some View {
|
||||
let on = state.filter.colors.contains(n)
|
||||
return Button { toggle(color: n) } label: {
|
||||
ZStack {
|
||||
if n == 0 {
|
||||
Image(systemName: "checkerboard.rectangle").font(.system(size: 12)).foregroundStyle(.secondary)
|
||||
} else {
|
||||
c
|
||||
}
|
||||
if on { Image(systemName: "checkmark").font(.system(size: 10, weight: .bold)).foregroundStyle(.white).shadow(radius: 1) }
|
||||
}
|
||||
.frame(width: 20, height: 20)
|
||||
.overlay(Rectangle().stroke(on ? Color.white : Color.clear, lineWidth: 1.5))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help(help)
|
||||
}
|
||||
|
||||
private func toggle(rating n: Int) {
|
||||
if state.filter.ratings.contains(n) { state.filter.ratings.remove(n) } else { state.filter.ratings.insert(n) }
|
||||
state.filter.ratingOn = !state.filter.ratings.isEmpty
|
||||
}
|
||||
|
||||
private func toggle(color n: Int) {
|
||||
if state.filter.colors.contains(n) { state.filter.colors.remove(n) } else { state.filter.colors.insert(n) }
|
||||
state.filter.colorOn = !state.filter.colors.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Status bar
|
||||
|
||||
struct PMStatusBar: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@EnvironmentObject var uploads: UploadQueue
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 12) {
|
||||
if state.loadingMetadata { ProgressView().controlSize(.small) }
|
||||
Text(state.statusText).lineLimit(1)
|
||||
Text(summary).lineLimit(1).truncationMode(.middle)
|
||||
Spacer()
|
||||
if state.lrPendingCount > 0 {
|
||||
Label("LR: \(state.lrPendingCount) Auftrag/Aufträge", systemImage: "hourglass")
|
||||
}
|
||||
if uploads.activeCount > 0 {
|
||||
Label("\(uploads.activeCount) Uploads", systemImage: "arrow.up.circle")
|
||||
.onTapGesture { state.openWindow("tasks") }
|
||||
}
|
||||
if state.lrPendingCount > 0 { Label("LR: \(state.lrPendingCount)", systemImage: "hourglass") }
|
||||
if uploads.failedCount > 0 {
|
||||
Label("\(uploads.failedCount) fehlgeschlagen", systemImage: "exclamationmark.triangle.fill")
|
||||
Label("\(uploads.failedCount) Upload(s) fehlgeschlagen", systemImage: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(.red)
|
||||
.onTapGesture { state.openWindow("tasks") }
|
||||
}
|
||||
Text("\(state.selection.count) / \(state.visible.count) ausgewählt")
|
||||
.foregroundStyle(.secondary)
|
||||
if !state.statusText.isEmpty { Text(state.statusText).foregroundStyle(.secondary).lineLimit(1) }
|
||||
}
|
||||
.font(.callout)
|
||||
.font(.system(size: 11))
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 5)
|
||||
.padding(.vertical, 4)
|
||||
.background(.bar)
|
||||
}
|
||||
|
||||
/// "Ausgewählt 1 von 2189 (3,22 MB) | 2189 gesamt | /Users/…/datei.jpg" like PM.
|
||||
private var summary: String {
|
||||
let sel = state.selectedItems.count
|
||||
let size = ByteCountFormatter.string(fromByteCount: state.selectedBytes, countStyle: .file)
|
||||
var parts = ["Ausgewählt \(sel) von \(state.visible.count) (\(size))", "\(state.items.count) gesamt"]
|
||||
if state.filter.isActive { parts.append("Filter aktiv") }
|
||||
if let c = state.cursorItem { parts.append(c.primary.path) }
|
||||
return parts.joined(separator: " | ")
|
||||
}
|
||||
}
|
||||
|
||||
struct SidebarView: View {
|
||||
// MARK: - Sidebar: Favorites / Navigator / Tasks
|
||||
|
||||
struct PMSidebar: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@EnvironmentObject var tasks: TaskCenter
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Section("Favoriten") {
|
||||
ForEach(state.settings.favoriteFolders, id: \.self) { path in
|
||||
folderRow(path)
|
||||
.contextMenu { Button("Aus Favoriten entfernen") { state.settings.favoriteFolders.removeAll { $0 == path } } }
|
||||
}
|
||||
if let f = state.folder, !state.settings.favoriteFolders.contains(f.path) {
|
||||
Button { state.settings.favoriteFolders.append(f.path) } label: {
|
||||
Label("Aktuellen Ordner merken", systemImage: "star")
|
||||
VSplitView {
|
||||
panel("Favoriten") {
|
||||
List {
|
||||
ForEach(state.settings.favoriteFolders, id: \.self) { path in
|
||||
folderRow(URL(fileURLWithPath: path))
|
||||
.contextMenu {
|
||||
Button("In neuem Tab öffnen") { state.open(folder: URL(fileURLWithPath: path), newTab: true) }
|
||||
Button("Aus Favoriten entfernen") { state.settings.favoriteFolders.removeAll { $0 == path } }
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.onMove { state.settings.favoriteFolders.move(fromOffsets: $0, toOffset: $1) }
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
} accessory: {
|
||||
if let f = state.folder, !state.settings.favoriteFolders.contains(f.path) {
|
||||
Button { state.settings.favoriteFolders.append(f.path) } label: { Image(systemName: "plus") }
|
||||
.buttonStyle(.borderless).help("Aktuellen Ordner zu Favoriten")
|
||||
}
|
||||
}
|
||||
Section("Zuletzt") {
|
||||
ForEach(state.settings.recentFolders, id: \.self) { folderRow($0) }
|
||||
}
|
||||
Section("Wechseldatenträger") {
|
||||
ForEach(volumes(), id: \.self) { v in
|
||||
Button { state.showIngest = true } label: { Label(v.lastPathComponent, systemImage: "sdcard") }
|
||||
.buttonStyle(.borderless)
|
||||
.frame(minHeight: 90, idealHeight: 160)
|
||||
|
||||
panel("Navigator") {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ForEach(navigatorRoots(), id: \.self) { FolderTreeRow(url: $0, depth: 0) }
|
||||
}
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
} accessory: { EmptyView() }
|
||||
.frame(minHeight: 150, idealHeight: 320)
|
||||
|
||||
panel("Aufgaben") {
|
||||
if tasks.tasks.isEmpty {
|
||||
Text("Keine Aufgaben").font(.caption).foregroundStyle(.secondary)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
} else {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
ForEach(tasks.tasks.prefix(12)) { t in MiniTaskRow(task: t) }
|
||||
}
|
||||
.padding(8)
|
||||
}
|
||||
}
|
||||
} accessory: {
|
||||
Button { state.openWindow("tasks") } label: { Image(systemName: "arrow.up.forward.app") }
|
||||
.buttonStyle(.borderless).help("Aufgaben-Fenster (⌘⌥U)")
|
||||
}
|
||||
.frame(minHeight: 80, idealHeight: 150)
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
}
|
||||
|
||||
private func folderRow(_ path: String) -> some View {
|
||||
let url = URL(fileURLWithPath: path)
|
||||
return Button { state.open(folder: url) } label: {
|
||||
Label(url.lastPathComponent, systemImage: state.folder?.path == path ? "folder.fill" : "folder")
|
||||
private func panel<C: View, A: View>(_ title: String, @ViewBuilder content: () -> C, @ViewBuilder accessory: () -> A) -> some View {
|
||||
VStack(spacing: 0) {
|
||||
HStack {
|
||||
Text(title).font(.system(size: 12, weight: .semibold))
|
||||
Spacer()
|
||||
accessory()
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 5)
|
||||
.background(Color.secondary.opacity(0.12))
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
private func folderRow(_ url: URL) -> some View {
|
||||
Button { state.open(folder: url) } label: {
|
||||
Label(url.lastPathComponent, systemImage: state.folder == url ? "folder.fill" : "folder")
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.help(path)
|
||||
.help(url.path)
|
||||
}
|
||||
|
||||
private func volumes() -> [URL] {
|
||||
let keys: [URLResourceKey] = [.volumeIsRemovableKey]
|
||||
let vols = FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: keys, options: [.skipHiddenVolumes]) ?? []
|
||||
return vols.filter { v in
|
||||
(try? v.resourceValues(forKeys: Set(keys)).volumeIsRemovable) == true
|
||||
|| FileManager.default.fileExists(atPath: v.appendingPathComponent("DCIM").path)
|
||||
/// Like PM: volumes, home, and the usual home folders.
|
||||
private func navigatorRoots() -> [URL] {
|
||||
let fm = FileManager.default
|
||||
let home = fm.homeDirectoryForCurrentUser
|
||||
var roots: [URL] = []
|
||||
let vols = fm.mountedVolumeURLs(includingResourceValuesForKeys: nil, options: [.skipHiddenVolumes]) ?? []
|
||||
roots += vols
|
||||
roots.append(home)
|
||||
for name in ["Desktop", "Pictures", "Documents", "Downloads"] {
|
||||
let u = home.appendingPathComponent(name)
|
||||
if fm.fileExists(atPath: u.path) { roots.append(u) }
|
||||
}
|
||||
let nextcloud = home.appendingPathComponent("Nextcloud")
|
||||
if fm.fileExists(atPath: nextcloud.path) { roots.append(nextcloud) }
|
||||
return roots
|
||||
}
|
||||
}
|
||||
|
||||
struct MiniTaskRow: View {
|
||||
let task: BackgroundTask
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: task.systemImage).foregroundStyle(.secondary)
|
||||
Text(task.title).font(.caption).lineLimit(1)
|
||||
}
|
||||
if task.isRunning {
|
||||
if task.total > 0 { ProgressView(value: task.progress).controlSize(.small) } else { ProgressView().controlSize(.small) }
|
||||
} else {
|
||||
Text(task.detail).font(.caption2).foregroundStyle(.secondary).lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Lazily expanding folder tree (children are only read when a row is opened).
|
||||
struct FolderTreeRow: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
let url: URL
|
||||
let depth: Int
|
||||
@State private var expanded = false
|
||||
@State private var children: [URL]?
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
HStack(spacing: 4) {
|
||||
Button {
|
||||
expanded.toggle()
|
||||
if expanded && children == nil { children = Self.subfolders(of: url) }
|
||||
} label: {
|
||||
Image(systemName: expanded ? "chevron.down" : "chevron.right")
|
||||
.font(.system(size: 9, weight: .bold))
|
||||
.frame(width: 12)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
Image(systemName: depth == 0 && url.path.hasPrefix("/Volumes") ? "externaldrive" : "folder")
|
||||
.foregroundStyle(.secondary)
|
||||
Text(displayName).lineLimit(1)
|
||||
.fontWeight(state.folder == url ? .semibold : .regular)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.leading, CGFloat(depth) * 14 + 6)
|
||||
.padding(.vertical, 2)
|
||||
.background(state.folder == url ? Color.accentColor.opacity(0.25) : Color.clear)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(count: 1) { state.open(folder: url) }
|
||||
.contextMenu {
|
||||
Button("In neuem Tab öffnen") { state.open(folder: url, newTab: true) }
|
||||
Button("Zu Favoriten") { if !state.settings.favoriteFolders.contains(url.path) { state.settings.favoriteFolders.append(url.path) } }
|
||||
Button("Im Finder zeigen") { NSWorkspace.shared.activateFileViewerSelecting([url]) }
|
||||
}
|
||||
if expanded, let children {
|
||||
ForEach(children, id: \.self) { FolderTreeRow(url: $0, depth: depth + 1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var displayName: String {
|
||||
let fm = FileManager.default
|
||||
if url == fm.homeDirectoryForCurrentUser { return "@" + url.lastPathComponent }
|
||||
return fm.displayName(atPath: url.path)
|
||||
}
|
||||
|
||||
static func subfolders(of url: URL) -> [URL] {
|
||||
let keys: [URLResourceKey] = [.isDirectoryKey, .isPackageKey]
|
||||
let list = (try? FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: keys, options: [.skipsHiddenFiles])) ?? []
|
||||
return list.filter {
|
||||
let v = try? $0.resourceValues(forKeys: Set(keys))
|
||||
return v?.isDirectory == true && v?.isPackage != true
|
||||
}
|
||||
.sorted { $0.lastPathComponent.localizedStandardCompare($1.lastPathComponent) == .orderedAscending }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,208 +17,159 @@ extension IPTCValues {
|
||||
}
|
||||
}
|
||||
|
||||
/// The field layout used everywhere (inspector + template editor) – PM Stationery Pad order.
|
||||
struct IPTCFieldsForm: View {
|
||||
/// PM's blue section header bar.
|
||||
struct PMSectionHeader: View {
|
||||
let title: String
|
||||
var body: some View {
|
||||
Text(title)
|
||||
.font(.system(size: 13, weight: .semibold))
|
||||
.foregroundStyle(.white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 3)
|
||||
.background(
|
||||
Capsule().fill(LinearGradient(colors: [Color(red: 0.30, green: 0.55, blue: 0.90), Color(red: 0.14, green: 0.38, blue: 0.75)],
|
||||
startPoint: .top, endPoint: .bottom))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The metadata form in Photo Mechanic's layout: blue section bars, labels left, big caption box,
|
||||
/// optional PM checkboxes ("apply this field"), two columns for template / mass edit, one for the info window.
|
||||
struct PMMetadataForm: View {
|
||||
@Binding var texts: FieldTexts
|
||||
var columns = 2
|
||||
var mixed: Set<String> = []
|
||||
var dirty: Set<String> = []
|
||||
var onEdit: (String) -> Void = { _ in }
|
||||
/// PM-style "apply" checkboxes (template editor only).
|
||||
/// PM checkboxes; nil = no checkboxes (info window).
|
||||
var applied: Binding<Set<String>>? = nil
|
||||
@AppStorage("collapsedIPTCSections") private var collapsedRaw = ""
|
||||
var codes: CodeReplacements? = nil
|
||||
var onEdit: (String) -> Void = { _ in }
|
||||
/// Extra rows (e.g. "Image Preferences → Label") inserted after Image Content.
|
||||
var extraAfterContent: AnyView? = nil
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
ForEach(IPTCSection.allCases, id: \.self) { section in
|
||||
let fields = IPTCField.all.filter { $0.section == section }
|
||||
DisclosureGroup(isExpanded: expandedBinding(section)) {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
ForEach(fields) { field in
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
if let applied {
|
||||
Toggle("", isOn: Binding(
|
||||
get: { applied.wrappedValue.contains(field.id) },
|
||||
set: { on in
|
||||
if on { applied.wrappedValue.insert(field.id) } else { applied.wrappedValue.remove(field.id) }
|
||||
}))
|
||||
.toggleStyle(.checkbox)
|
||||
.labelsHidden()
|
||||
.padding(.top, 16)
|
||||
.help("Feld beim Anwenden schreiben (wie das Häkchen in Photo Mechanic)")
|
||||
}
|
||||
FieldRow(field: field, text: binding(field), isMixed: mixed.contains(field.id) && !dirty.contains(field.id),
|
||||
isDirty: dirty.contains(field.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 4)
|
||||
} label: {
|
||||
Text(section.rawValue).font(.headline)
|
||||
}
|
||||
if columns == 2 {
|
||||
HStack(alignment: .top, spacing: 18) {
|
||||
column(0)
|
||||
column(1)
|
||||
}
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
ForEach(IPTCSection.allCases, id: \.self) { sectionView($0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func expandedBinding(_ s: IPTCSection) -> Binding<Bool> {
|
||||
Binding(get: { !collapsedRaw.components(separatedBy: "|").contains(s.rawValue) },
|
||||
set: { expanded in
|
||||
var set = Set(collapsedRaw.components(separatedBy: "|").filter { !$0.isEmpty })
|
||||
if expanded { set.remove(s.rawValue) } else { set.insert(s.rawValue) }
|
||||
collapsedRaw = set.sorted().joined(separator: "|")
|
||||
})
|
||||
private func column(_ c: Int) -> some View {
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
ForEach(IPTCSection.allCases.filter { $0.column == c }, id: \.self) { sectionView($0) }
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .top)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func sectionView(_ section: IPTCSection) -> some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
PMSectionHeader(title: section.rawValue)
|
||||
ForEach(IPTCField.all.filter { $0.section == section }) { field in
|
||||
PMFieldRow(field: field, text: binding(field),
|
||||
isMixed: mixed.contains(field.id) && !dirty.contains(field.id),
|
||||
isDirty: dirty.contains(field.id),
|
||||
applied: appliedBinding(field))
|
||||
}
|
||||
if section == .imageContent, let extra = extraAfterContent { extra }
|
||||
}
|
||||
}
|
||||
|
||||
private func appliedBinding(_ f: IPTCField) -> Binding<Bool>? {
|
||||
guard let applied else { return nil }
|
||||
return Binding(get: { applied.wrappedValue.contains(f.id) },
|
||||
set: { on in if on { applied.wrappedValue.insert(f.id) } else { applied.wrappedValue.remove(f.id) } })
|
||||
}
|
||||
|
||||
private func binding(_ f: IPTCField) -> Binding<String> {
|
||||
Binding(get: { texts[f.id] ?? "" },
|
||||
set: { texts[f.id] = $0; onEdit(f.id) })
|
||||
set: { new in
|
||||
var value = new
|
||||
// PM code replacement while typing: "\bvb\" expands as soon as the closing delimiter is typed.
|
||||
if let codes, !codes.table.isEmpty, new.last == codes.delimiter, new.count > (texts[f.id]?.count ?? 0) {
|
||||
value = codes.expand(new)
|
||||
}
|
||||
texts[f.id] = value
|
||||
// Editing a field ticks its checkbox (PM behaviour).
|
||||
applied?.wrappedValue.insert(f.id)
|
||||
onEdit(f.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct FieldRow: View {
|
||||
struct PMFieldRow: View {
|
||||
let field: IPTCField
|
||||
@Binding var text: String
|
||||
let isMixed: Bool
|
||||
let isDirty: Bool
|
||||
let applied: Binding<Bool>?
|
||||
|
||||
private static let variableFields: Set<String> = ["caption", "headline", "objectName", "instructions", "event",
|
||||
"transmissionReference", "keywords"]
|
||||
private var height: CGFloat? {
|
||||
switch field.id {
|
||||
case "caption": return 210
|
||||
case "keywords": return 130
|
||||
case "headline", "altText", "extDescription", "personInImage", "instructions", "usageTerms": return 62
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(spacing: 4) {
|
||||
Text(field.label).font(.caption).foregroundStyle(isDirty ? Color.accentColor : .secondary)
|
||||
if field.kind == .list { Text("(Komma-getrennt)").font(.caption2).foregroundStyle(.tertiary) }
|
||||
Spacer()
|
||||
if let max = field.iimMaxBytes {
|
||||
let used = text.utf8.count
|
||||
if used > 0 {
|
||||
Text("\(used)/\(max)")
|
||||
.font(.caption2.monospacedDigit())
|
||||
.foregroundStyle(used > max && !text.contains("{") ? .red : .secondary)
|
||||
.help("IPTC-IIM-Limit in Bytes. Agenturen kürzen oder lehnen längere Werte ab.")
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
if let applied {
|
||||
Toggle("", isOn: applied).toggleStyle(.checkbox).labelsHidden().padding(.top, 3)
|
||||
}
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(field.pmLabel + ":")
|
||||
.font(.system(size: 12))
|
||||
.foregroundStyle(isDirty ? Color.accentColor : .primary)
|
||||
.help(field.label)
|
||||
if let max = field.iimMaxBytes, text.utf8.count > max, !text.contains("{") {
|
||||
Text("\(text.utf8.count)/\(max)").font(.caption2.monospacedDigit()).foregroundStyle(.red)
|
||||
.help("IPTC-IIM-Limit in Bytes – Agenturen kürzen längere Werte.")
|
||||
}
|
||||
}
|
||||
.frame(width: 150, alignment: .leading)
|
||||
.padding(.top, 3)
|
||||
|
||||
Group {
|
||||
if let h = height {
|
||||
TextEditor(text: $text)
|
||||
.font(.system(size: 13))
|
||||
.scrollContentBackground(.hidden)
|
||||
.padding(4)
|
||||
.background(Color(nsColor: .textBackgroundColor))
|
||||
.overlay(alignment: .topLeading) {
|
||||
if isMixed && text.isEmpty {
|
||||
Text("‹mehrere Werte›").foregroundStyle(.tertiary).padding(8).allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
.overlay(RoundedRectangle(cornerRadius: 3).stroke(Color.secondary.opacity(0.4)))
|
||||
.frame(height: h)
|
||||
} else {
|
||||
TextField(isMixed ? "‹mehrere Werte›" : "", text: $text)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Menu {
|
||||
Section("Variablen") {
|
||||
ForEach(VariableExpander.documented, id: \.0) { v in
|
||||
Button("\(v.0) – \(v.1)") { text += v.0 }
|
||||
}
|
||||
}
|
||||
if Self.variableFields.contains(field.id) {
|
||||
Menu {
|
||||
ForEach(VariableExpander.documented, id: \.0) { v in
|
||||
Button("\(v.0) – \(v.1)") { text += v.0 }
|
||||
}
|
||||
} label: { Image(systemName: "curlybraces") }
|
||||
.menuStyle(.borderlessButton)
|
||||
.menuIndicator(.hidden)
|
||||
.fixedSize()
|
||||
.help("Variable einfügen")
|
||||
}
|
||||
}
|
||||
if field.kind == .multiline || field.id == "keywords" {
|
||||
TextField(isMixed ? "‹mehrere Werte›" : "", text: $text, axis: .vertical)
|
||||
.lineLimit(field.id == "caption" ? 4...12 : 2...6)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
} else {
|
||||
TextField(isMixed ? "‹mehrere Werte›" : "", text: $text)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
}
|
||||
Button("Feld leeren") { text = "" }
|
||||
} label: { Image(systemName: "chevron.down") }
|
||||
.menuStyle(.borderlessButton)
|
||||
.menuIndicator(.hidden)
|
||||
.frame(width: 22)
|
||||
.padding(.top, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Right-hand inspector: edit IPTC of the current selection.
|
||||
struct IPTCInspectorView: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@State private var texts: FieldTexts = [:]
|
||||
@State private var mixed: Set<String> = []
|
||||
@State private var dirty: Set<String> = []
|
||||
@State private var loadedSelection: [String] = []
|
||||
@State private var newTemplateName = ""
|
||||
@State private var showSaveTemplate = false
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
header
|
||||
Divider()
|
||||
ScrollView {
|
||||
IPTCFieldsForm(texts: $texts, mixed: mixed, dirty: dirty) { dirty.insert($0) }
|
||||
.padding(12)
|
||||
}
|
||||
Divider()
|
||||
footer
|
||||
}
|
||||
.onAppear(perform: reload)
|
||||
.onChange(of: state.selection) { _, _ in reload() }
|
||||
.onChange(of: state.cursorID) { _, _ in if state.selection.isEmpty { reload() } }
|
||||
.onReceive(state.$items) { _ in
|
||||
// Refresh when metadata arrives / changes, unless the user is editing.
|
||||
if dirty.isEmpty { DispatchQueue.main.async { reload() } }
|
||||
}
|
||||
.alert("Als Vorlage speichern", isPresented: $showSaveTemplate) {
|
||||
TextField("Name", text: $newTemplateName)
|
||||
Button("Speichern") {
|
||||
let values = IPTCValues(texts: texts)
|
||||
state.templates.append(IPTCTemplate(name: newTemplateName.isEmpty ? "Neue Vorlage" : newTemplateName, values: values))
|
||||
}
|
||||
Button("Abbrechen", role: .cancel) {}
|
||||
}
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
HStack {
|
||||
let n = state.selectedItems.count
|
||||
VStack(alignment: .leading) {
|
||||
Text("IPTC").font(.headline)
|
||||
Text(n == 0 ? "Keine Auswahl" : n == 1 ? state.selectedItems[0].filename : "\(n) Bilder ausgewählt")
|
||||
.font(.caption).foregroundStyle(.secondary).lineLimit(1)
|
||||
}
|
||||
Spacer()
|
||||
Menu {
|
||||
ForEach(state.templates) { t in
|
||||
Button(t.name) { state.applyTemplate(t) }
|
||||
}
|
||||
if state.templates.isEmpty { Text("Noch keine Vorlagen") }
|
||||
Divider()
|
||||
Button("Vorlagen verwalten …") { state.showTemplateManager = true }
|
||||
Button("PM-Vorlage importieren …") { state.importPMTemplate() }
|
||||
} label: {
|
||||
Label("Vorlage", systemImage: "doc.on.clipboard")
|
||||
}
|
||||
.fixedSize()
|
||||
}
|
||||
.padding(12)
|
||||
}
|
||||
|
||||
private var footer: some View {
|
||||
HStack {
|
||||
Button("Als Vorlage …") { newTemplateName = ""; showSaveTemplate = true }
|
||||
Spacer()
|
||||
Button("Verwerfen") { dirty = []; reload() }.disabled(dirty.isEmpty)
|
||||
Button("Übernehmen") {
|
||||
let fields = IPTCField.all.filter { dirty.contains($0.id) }
|
||||
state.applyIPTC(IPTCValues(texts: texts), fields: fields)
|
||||
dirty = []
|
||||
}
|
||||
.keyboardShortcut(.return, modifiers: .command)
|
||||
.buttonStyle(.borderedProminent)
|
||||
.disabled(dirty.isEmpty || state.selectedItems.isEmpty)
|
||||
}
|
||||
.padding(12)
|
||||
}
|
||||
|
||||
private func reload() {
|
||||
let items = state.selectedItems
|
||||
let ids = items.map(\.id)
|
||||
if ids != loadedSelection { dirty = [] }
|
||||
loadedSelection = ids
|
||||
guard dirty.isEmpty else { return }
|
||||
guard let first = items.first else { texts = [:]; mixed = []; return }
|
||||
var t = first.iptc.texts()
|
||||
var m = Set<String>()
|
||||
for item in items.dropFirst() {
|
||||
let other = item.iptc.texts()
|
||||
for f in IPTCField.all where (other[f.id] ?? "") != (t[f.id] ?? "") {
|
||||
m.insert(f.id)
|
||||
t[f.id] = ""
|
||||
}
|
||||
}
|
||||
texts = t
|
||||
mixed = m
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,8 @@ struct IPTCInfoWindow: View {
|
||||
HSplitView {
|
||||
VStack(spacing: 0) {
|
||||
ScrollView {
|
||||
IPTCFieldsForm(texts: $texts, dirty: dirty) { dirty.insert($0) }
|
||||
PMMetadataForm(texts: $texts, columns: 1, dirty: dirty, codes: state.codes,
|
||||
onEdit: { dirty.insert($0) }, extraAfterContent: AnyView(labelSection))
|
||||
.padding(14)
|
||||
}
|
||||
Divider()
|
||||
@@ -36,7 +37,7 @@ struct IPTCInfoWindow: View {
|
||||
}
|
||||
.padding(10)
|
||||
}
|
||||
.frame(minWidth: 480, idealWidth: 560)
|
||||
.frame(minWidth: 560, idealWidth: 640)
|
||||
|
||||
sidePanel.frame(minWidth: 380, idealWidth: 520)
|
||||
}
|
||||
@@ -47,6 +48,33 @@ struct IPTCInfoWindow: View {
|
||||
.task(id: item.map { state.previewURL(for: $0) }) { await loadImage() }
|
||||
}
|
||||
|
||||
/// PM "Image Preferences": color class label + stars of the current image.
|
||||
private var labelSection: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
PMSectionHeader(title: "Image Preferences")
|
||||
HStack {
|
||||
Text("Label:").frame(width: 150, alignment: .leading)
|
||||
Picker("", selection: Binding(
|
||||
get: { item?.label?.pmColorClass ?? 0 },
|
||||
set: { n in if let item { state.setLabel(n == 0 ? nil : ColorLabel(pmColorClass: n), advance: false, only: item) } })) {
|
||||
Text("Keine").tag(0)
|
||||
ForEach(ColorLabel.allCases, id: \.self) { l in
|
||||
Text("\(l.pmColorClass) – \(l.germanName) (\(l.pmName))").tag(l.pmColorClass)
|
||||
}
|
||||
}
|
||||
.labelsHidden()
|
||||
}
|
||||
HStack {
|
||||
Text("Rating:").frame(width: 150, alignment: .leading)
|
||||
Picker("", selection: Binding(get: { item?.rating ?? 0 }, set: { n in if let item { state.setRating(n, advance: false, only: item) } })) {
|
||||
ForEach(0...5, id: \.self) { n in Text(n == 0 ? "Keine" : String(repeating: "★", count: n)).tag(n) }
|
||||
}
|
||||
.labelsHidden()
|
||||
.pickerStyle(.segmented)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Right side (preview + PM buttons)
|
||||
|
||||
private var sidePanel: some View {
|
||||
|
||||
@@ -24,7 +24,7 @@ struct GeneralSettings: View {
|
||||
ForEach(KeyScheme.allCases, id: \.self) { Text($0.title).tag($0) }
|
||||
}
|
||||
Toggle("Nach Bewertung/Tag automatisch zum nächsten Bild", isOn: $state.settings.autoAdvance)
|
||||
Text("1–5 = Sterne · 0 = keine · T = Tag · I / ⌘I = IPTC-Info · ⌘E = in Lightroom bearbeiten · Leertaste = Vorschau · Z = 100 % · ⌘⌥S = RAW ⇄ SENT")
|
||||
Text("1–8 = Farbklasse · 0 = keine · ⌥1–5 = Sterne · T = Tag · I = IPTC-Info · ⌘I = IPTC für Auswahl · ⌘U = Hochladen · ⌘E = Lightroom · ⌘⌥S = INPUT ⇄ SENT")
|
||||
.font(.caption).foregroundStyle(.secondary)
|
||||
}
|
||||
Section("Ingest") {
|
||||
|
||||
@@ -127,10 +127,11 @@ struct TemplateManagerView: View {
|
||||
}
|
||||
Divider()
|
||||
ScrollView {
|
||||
IPTCFieldsForm(texts: $texts, onEdit: { _ in save() },
|
||||
PMMetadataForm(texts: $texts, columns: 2,
|
||||
applied: state.templates[i].appliedFields == nil ? nil : Binding(
|
||||
get: { state.templates[i].appliedFields ?? [] },
|
||||
set: { state.templates[i].appliedFields = $0 }))
|
||||
set: { state.templates[i].appliedFields = $0 }),
|
||||
codes: state.codes, onEdit: { _ in save() })
|
||||
.padding(.trailing, 8)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import SwiftUI
|
||||
import LichtkastenCore
|
||||
|
||||
/// ⌘U – PM "Upload Photos" dialog for the selected images.
|
||||
struct UploadWindow: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
@AppStorage("lastUploadTarget") private var target = ""
|
||||
|
||||
private var destination: FTPDestination? { state.settings.ftpDestinations.first { $0.id.uuidString == target } }
|
||||
|
||||
private var variant: UploadVariant {
|
||||
target == "immich" ? state.settings.immich.variant : destination?.variant ?? .jpeg
|
||||
}
|
||||
|
||||
private var files: [URL] { state.selectedItems.flatMap { state.uploadFiles(for: $0, variant: variant) } }
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
Text("Bilder hochladen").font(.title3.bold())
|
||||
Form {
|
||||
Picker("Ziel", selection: $target) {
|
||||
Text("– bitte wählen –").tag("")
|
||||
ForEach(state.settings.ftpDestinations) { d in Text(d.name).tag(d.id.uuidString) }
|
||||
if state.settings.immich.enabled { Text("Immich").tag("immich") }
|
||||
}
|
||||
if let d = destination {
|
||||
LabeledContent("Server", value: "\(d.proto.rawValue) · \(d.host):\(d.port)")
|
||||
if let i = state.settings.ftpDestinations.firstIndex(where: { $0.id == d.id }) {
|
||||
TextField("Zielordner", text: $state.settings.ftpDestinations[i].remoteDirectory)
|
||||
TextField("Umbenennen (leer = Originalname)", text: $state.settings.ftpDestinations[i].renamePattern)
|
||||
Picker("Dateien", selection: $state.settings.ftpDestinations[i].variant) {
|
||||
ForEach(UploadVariant.allCases, id: \.self) { Text($0.rawValue).tag($0) }
|
||||
}
|
||||
}
|
||||
if d.username.isEmpty || Keychain.get(d.keychainAccount) == nil {
|
||||
Label("Benutzer/Passwort fehlen – Einstellungen → FTP", systemImage: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(.orange)
|
||||
}
|
||||
} else if target == "immich" {
|
||||
LabeledContent("Server", value: state.settings.immich.serverURL)
|
||||
LabeledContent("Album", value: state.settings.immich.albumName.isEmpty ? "–" : state.settings.immich.albumName)
|
||||
}
|
||||
LabeledContent("Auswahl", value: "\(state.selectedItems.count) Bild(er) → \(files.count) Datei(en)")
|
||||
if files.count < state.selectedItems.count {
|
||||
Text("Einige Bilder haben kein JPEG – zuerst in Lightroom exportieren (⌘⌥L).")
|
||||
.font(.caption).foregroundStyle(.orange)
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
HStack {
|
||||
SettingsLink { Text("Server verwalten …") }
|
||||
Spacer()
|
||||
Button("Abbrechen") { dismissWindow(id: "upload") }.keyboardShortcut(.cancelAction)
|
||||
Button("Hochladen") {
|
||||
state.upload(to: target)
|
||||
state.openWindow("tasks")
|
||||
dismissWindow(id: "upload")
|
||||
}
|
||||
.keyboardShortcut(.defaultAction)
|
||||
.buttonStyle(.borderedProminent)
|
||||
.disabled(target.isEmpty || files.isEmpty)
|
||||
}
|
||||
}
|
||||
.padding(18)
|
||||
.frame(width: 560)
|
||||
.onAppear {
|
||||
if target.isEmpty, let first = state.settings.ftpDestinations.first { target = first.id.uuidString }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import Foundation
|
||||
|
||||
/// On-disk cache of exiftool results per folder (keyed by file size + modification date),
|
||||
/// so re-opening a folder with thousands of images is instant – like PM's preview/metadata cache.
|
||||
public final class MetadataCache: @unchecked Sendable {
|
||||
public struct Entry: Codable, Sendable {
|
||||
public var size: Int64
|
||||
public var mtime: Double
|
||||
public var sidecarMtime: Double?
|
||||
public var file: [String: MetadataValue]
|
||||
public var sidecar: [String: MetadataValue]?
|
||||
}
|
||||
|
||||
private let url: URL
|
||||
private var entries: [String: Entry] = [:]
|
||||
private let lock = NSLock()
|
||||
private var dirty = false
|
||||
|
||||
public static var directory: URL {
|
||||
let d = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
|
||||
.appendingPathComponent("Lichtkasten/metadata", isDirectory: true)
|
||||
try? FileManager.default.createDirectory(at: d, withIntermediateDirectories: true)
|
||||
return d
|
||||
}
|
||||
|
||||
public init(folder: URL) {
|
||||
// FNV-1a hash of the path as file name
|
||||
var h: UInt64 = 0xcbf29ce484222325
|
||||
for b in folder.standardizedFileURL.path.utf8 { h = (h ^ UInt64(b)) &* 0x100000001b3 }
|
||||
url = MetadataCache.directory.appendingPathComponent(String(h, radix: 16) + ".json")
|
||||
if let d = try? Data(contentsOf: url), let e = try? JSONDecoder().decode([String: Entry].self, from: d) {
|
||||
entries = e
|
||||
}
|
||||
}
|
||||
|
||||
static func stamp(_ u: URL) -> (Int64, Double)? {
|
||||
guard let a = try? FileManager.default.attributesOfItem(atPath: u.path) else { return nil }
|
||||
let size = (a[.size] as? NSNumber)?.int64Value ?? 0
|
||||
let m = (a[.modificationDate] as? Date)?.timeIntervalSince1970 ?? 0
|
||||
return (size, m)
|
||||
}
|
||||
|
||||
/// Valid cached entry for an item (file and sidecar unchanged), else nil.
|
||||
public func lookup(_ item: PhotoItem) -> Entry? {
|
||||
lock.lock(); let e = entries[item.primary.path]; lock.unlock()
|
||||
guard let e, let (size, m) = MetadataCache.stamp(item.primary), size == e.size, m == e.mtime else { return nil }
|
||||
if item.kind.usesSidecar {
|
||||
let sm = MetadataCache.stamp(item.sidecarURL)?.1
|
||||
if sm != e.sidecarMtime { return nil }
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
public func store(_ item: PhotoItem, file: [String: MetadataValue], sidecar: [String: MetadataValue]?) {
|
||||
guard let (size, m) = MetadataCache.stamp(item.primary) else { return }
|
||||
let sm = item.kind.usesSidecar ? MetadataCache.stamp(item.sidecarURL)?.1 : nil
|
||||
lock.lock()
|
||||
entries[item.primary.path] = Entry(size: size, mtime: m, sidecarMtime: sm, file: file, sidecar: sidecar)
|
||||
dirty = true
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
public func save() {
|
||||
lock.lock(); defer { lock.unlock() }
|
||||
guard dirty, let d = try? JSONEncoder().encode(entries) else { return }
|
||||
try? d.write(to: url, options: .atomic)
|
||||
dirty = false
|
||||
}
|
||||
}
|
||||
@@ -29,21 +29,29 @@ public enum FileKind: String, Sendable, Codable {
|
||||
public var supportsIIM: Bool { self == .jpeg || self == .tiff || self == .dng }
|
||||
}
|
||||
|
||||
/// Photo Mechanic color classes 1–8 (keys 1–8). Classes 1–5 map to Lightroom's label colors.
|
||||
public enum ColorLabel: String, CaseIterable, Codable, Sendable {
|
||||
case red = "Red", yellow = "Yellow", green = "Green", blue = "Blue", purple = "Purple"
|
||||
case cyan = "Cyan", orange = "Orange", gray = "Gray"
|
||||
|
||||
/// Value written to Lightroom's xmp:Label (LR default label set, German UI uses the same English keys
|
||||
/// only if the label set is "Lightroom-Standard"; see README).
|
||||
/// Value written to xmp:Label (Lightroom default label set understands Red…Purple).
|
||||
public var xmpValue: String { rawValue }
|
||||
/// Photo Mechanic color class number for compatibility.
|
||||
/// Photo Mechanic color class number.
|
||||
public var pmColorClass: Int { (ColorLabel.allCases.firstIndex(of: self) ?? 0) + 1 }
|
||||
/// PM's default class names.
|
||||
public var pmName: String {
|
||||
["Winner", "Winner alt", "Superior", "Superior alt", "Typical", "Typical alt", "Extras", "Trash"][pmColorClass - 1]
|
||||
}
|
||||
public var germanName: String {
|
||||
switch self {
|
||||
case .red: return "Rot"
|
||||
case .yellow: return "Gelb"
|
||||
case .green: return "Grün"
|
||||
case .blue: return "Blau"
|
||||
case .purple: return "Lila"
|
||||
case .purple: return "Magenta"
|
||||
case .cyan: return "Cyan"
|
||||
case .orange: return "Orange"
|
||||
case .gray: return "Grau"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +59,8 @@ public enum ColorLabel: String, CaseIterable, Codable, Sendable {
|
||||
let l = xmp.lowercased()
|
||||
let map: [String: ColorLabel] = ["red": .red, "rot": .red, "yellow": .yellow, "gelb": .yellow,
|
||||
"green": .green, "grün": .green, "blue": .blue, "blau": .blue,
|
||||
"purple": .purple, "lila": .purple, "violett": .purple]
|
||||
"purple": .purple, "lila": .purple, "violett": .purple, "magenta": .purple,
|
||||
"cyan": .cyan, "orange": .orange, "gray": .gray, "grey": .gray, "grau": .gray]
|
||||
guard let c = map[l] else { return nil }
|
||||
self = c
|
||||
}
|
||||
@@ -132,8 +141,9 @@ public struct PhotoItem: Identifiable, Hashable, Sendable {
|
||||
func xmp(_ tag: String) -> MetadataValue? { xmpSource[tag] ?? fileMeta[tag] }
|
||||
|
||||
rating = xmp("XMP-xmp:Rating")?.int ?? 0
|
||||
label = xmp("XMP-xmp:Label").flatMap { ColorLabel(xmp: $0.string) }
|
||||
?? xmp("XMP-photomech:ColorClass")?.int.flatMap { ColorLabel(pmColorClass: $0) }
|
||||
// PM color class first (it knows all 8 classes), then Lightroom's label.
|
||||
label = xmp("XMP-photomech:ColorClass")?.int.flatMap { ColorLabel(pmColorClass: $0) }
|
||||
?? xmp("XMP-xmp:Label").flatMap { ColorLabel(xmp: $0.string) }
|
||||
tagged = xmp("XMP-photomech:Tagged")?.bool ?? false
|
||||
|
||||
var values = IPTCValues()
|
||||
|
||||
@@ -119,9 +119,9 @@ public final class ExifTool: @unchecked Sendable {
|
||||
/// Keys for IPTC/XMP keep their group ("IPTC:Keywords"), EXIF keys are plain ("Model").
|
||||
public func readMetadata(files: [URL]) async throws -> [String: [String: MetadataValue]] {
|
||||
guard !files.isEmpty else { return [:] }
|
||||
var args = ["-json", "-G1", "-fast", "-a",
|
||||
var args = ["-json", "-G1", "-fast2", "-a",
|
||||
"-XMP-xmp:Rating#", "-XMP-xmp:Label", "-XMP-photomech:Tagged#", "-XMP-photomech:ColorClass#",
|
||||
"-Make", "-Model", "-LensModel", "-LensID", "-SerialNumber", "-ISO", "-ExposureTime", "-FNumber",
|
||||
"-Make", "-Model", "-LensModel", "-Lens", "-SerialNumber", "-ISO", "-ExposureTime", "-FNumber",
|
||||
"-FocalLength", "-DateTimeOriginal", "-CreateDate", "-SubSecTimeOriginal", "-OffsetTimeOriginal", "-ImageWidth", "-ImageHeight",
|
||||
"-Orientation#", "-Artist", "-GPSLatitude#", "-GPSLongitude#"]
|
||||
for f in IPTCField.all {
|
||||
@@ -152,7 +152,7 @@ public final class ExifTool: @unchecked Sendable {
|
||||
}
|
||||
|
||||
/// JSON values coming back from exiftool.
|
||||
public enum MetadataValue: Sendable, Hashable {
|
||||
public enum MetadataValue: Sendable, Hashable, Codable {
|
||||
case string(String)
|
||||
case number(Double)
|
||||
case bool(Bool)
|
||||
@@ -202,3 +202,36 @@ public enum MetadataValue: Sendable, Hashable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Several exiftool processes in parallel – reading 2000+ files is I/O + Perl bound, so this scales well on Apple Silicon.
|
||||
public final class ExifToolPool: @unchecked Sendable {
|
||||
public let workers: [ExifTool]
|
||||
|
||||
public init(executable: URL, count: Int = min(6, max(2, ProcessInfo.processInfo.activeProcessorCount / 2))) {
|
||||
workers = (0..<count).map { _ in ExifTool(executable: executable) }
|
||||
}
|
||||
|
||||
public var primary: ExifTool { workers[0] }
|
||||
|
||||
public func shutdown() { workers.forEach { $0.shutdown() } }
|
||||
|
||||
/// Reads file groups (RAW + its sidecar stay together) in chunks spread over all workers;
|
||||
/// `onChunk` is called as results arrive.
|
||||
public func readMetadata(groups: [[URL]], groupsPerChunk: Int = 50,
|
||||
onChunk: @escaping @Sendable ([String: [String: MetadataValue]]) async -> Void) async {
|
||||
let chunks: [[URL]] = stride(from: 0, to: groups.count, by: groupsPerChunk).map {
|
||||
groups[$0..<min($0 + groupsPerChunk, groups.count)].flatMap { $0 }
|
||||
}
|
||||
await withTaskGroup(of: Void.self) { group in
|
||||
for w in 0..<workers.count {
|
||||
let worker = workers[w]
|
||||
let mine = chunks.enumerated().filter { $0.offset % workers.count == w }.map(\.element)
|
||||
group.addTask {
|
||||
for chunk in mine {
|
||||
if let meta = try? await worker.readMetadata(files: chunk) { await onChunk(meta) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,13 +25,21 @@ public enum IPTCFieldKind: String, Codable, Sendable {
|
||||
case list // keywords etc. – stored as [String]
|
||||
}
|
||||
|
||||
/// Sections in Photo Mechanic's IPTC window order. `column` places them like PM (left / right).
|
||||
public enum IPTCSection: String, CaseIterable, Codable, Sendable {
|
||||
case description = "Beschreibung"
|
||||
case location = "Ort"
|
||||
case locationCreated = "Aufnahmeort (IPTC Ext)"
|
||||
case creator = "Urheber & Rechte"
|
||||
case contact = "Kontakt des Urhebers"
|
||||
case extended = "Erweitert (IPTC Core/Ext)"
|
||||
case imageContent = "Image Content"
|
||||
case imageRights = "Image Rights"
|
||||
case contact = "Creator Contact Info"
|
||||
case eventLocation = "Event and Location"
|
||||
case locationCreated = "Locations Taken and Shown"
|
||||
case status = "Status"
|
||||
|
||||
public var column: Int {
|
||||
switch self {
|
||||
case .imageContent, .imageRights, .contact: return 0
|
||||
case .eventLocation, .locationCreated, .status: return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// How an XMP property is stored inside rdf.
|
||||
@@ -72,88 +80,58 @@ public extension IPTCField {
|
||||
}
|
||||
|
||||
static let all: [IPTCField] = [
|
||||
// --- Beschreibung ---
|
||||
f("caption", "Bildunterschrift", pm: "Caption", .description, .multiline,
|
||||
// --- imageContent ---
|
||||
f("caption", "Beschreibung", pm: "Description/Caption", .imageContent, .multiline,
|
||||
iim: "IPTC:Caption-Abstract", xmp: "XMP-dc:Description", ns: XMPNamespace.dc, local: "description", container: .alt, max: 2000),
|
||||
f("captionWriter", "Verfasser Bildunterschrift", pm: "Caption Writer", .description,
|
||||
f("altText", "Alt-Text", pm: "Alt Text", .imageContent, .multiline,
|
||||
iim: nil, xmp: "XMP-iptcCore:AltTextAccessibility", ns: XMPNamespace.iptcCore, local: "AltTextAccessibility", container: .alt),
|
||||
f("extDescription", "Erweiterte Beschreibung", pm: "Extended Desc", .imageContent, .multiline,
|
||||
iim: nil, xmp: "XMP-iptcCore:ExtDescrAccessibility", ns: XMPNamespace.iptcCore, local: "ExtDescrAccessibility", container: .alt),
|
||||
f("captionWriter", "Verfasser", pm: "Description Writers", .imageContent,
|
||||
iim: "IPTC:Writer-Editor", xmp: "XMP-photoshop:CaptionWriter", ns: XMPNamespace.photoshop, local: "CaptionWriter", max: 32),
|
||||
f("headline", "Überschrift", pm: "Headline", .description,
|
||||
f("headline", "Überschrift", pm: "Headline", .imageContent, .multiline,
|
||||
iim: "IPTC:Headline", xmp: "XMP-photoshop:Headline", ns: XMPNamespace.photoshop, local: "Headline", max: 256),
|
||||
f("instructions", "Anweisungen", pm: "Special Instructions", .description, .multiline,
|
||||
iim: "IPTC:SpecialInstructions", xmp: "XMP-photoshop:Instructions", ns: XMPNamespace.photoshop, local: "Instructions", max: 256),
|
||||
f("transmissionReference", "Job-ID / Übertragungsreferenz", pm: "Transmission Reference", .description,
|
||||
iim: "IPTC:OriginalTransmissionReference", xmp: "XMP-photoshop:TransmissionReference", ns: XMPNamespace.photoshop, local: "TransmissionReference", max: 32),
|
||||
f("objectName", "Titel (Objektname)", pm: "Object Name", .description,
|
||||
iim: "IPTC:ObjectName", xmp: "XMP-dc:Title", ns: XMPNamespace.dc, local: "title", container: .alt, max: 64),
|
||||
f("keywords", "Stichwörter", pm: "Keywords", .description, .list,
|
||||
f("keywords", "Stichwörter", pm: "Keywords", .imageContent, .list,
|
||||
iim: "IPTC:Keywords", xmp: "XMP-dc:Subject", ns: XMPNamespace.dc, local: "subject", container: .bag, max: 64),
|
||||
f("category", "Kategorie", pm: "Category", .description,
|
||||
iim: "IPTC:Category", xmp: "XMP-photoshop:Category", ns: XMPNamespace.photoshop, local: "Category", max: 3),
|
||||
f("supplementalCategories", "Zusatzkategorien", pm: "Supplemental Categories", .description, .list,
|
||||
iim: "IPTC:SupplementalCategories", xmp: "XMP-photoshop:SupplementalCategories", ns: XMPNamespace.photoshop, local: "SupplementalCategories", container: .bag, max: 32),
|
||||
f("urgency", "Dringlichkeit", pm: "Urgency", .description,
|
||||
iim: "IPTC:Urgency", xmp: "XMP-photoshop:Urgency", ns: XMPNamespace.photoshop, local: "Urgency", max: 1),
|
||||
f("dateCreated", "Erstellungsdatum (JJJJ-MM-TT)", pm: "Date Created", .description,
|
||||
iim: "IPTC:DateCreated", xmp: "XMP-photoshop:DateCreated", ns: XMPNamespace.photoshop, local: "DateCreated", max: 8),
|
||||
|
||||
// --- Ort ---
|
||||
f("event", "Ereignis", pm: "Event", .location,
|
||||
iim: nil, xmp: "XMP-iptcExt:Event", ns: XMPNamespace.iptcExt, local: "Event", container: .alt),
|
||||
f("sublocation", "Ortsdetail", pm: "Location / Sublocation", .location,
|
||||
iim: "IPTC:Sub-location", xmp: "XMP-iptcCore:Location", ns: XMPNamespace.iptcCore, local: "Location", max: 32),
|
||||
f("city", "Stadt", pm: "City", .location,
|
||||
iim: "IPTC:City", xmp: "XMP-photoshop:City", ns: XMPNamespace.photoshop, local: "City", max: 32),
|
||||
f("state", "Bundesland", pm: "State / Province", .location,
|
||||
iim: "IPTC:Province-State", xmp: "XMP-photoshop:State", ns: XMPNamespace.photoshop, local: "State", max: 32),
|
||||
f("country", "Land", pm: "Country", .location,
|
||||
iim: "IPTC:Country-PrimaryLocationName", xmp: "XMP-photoshop:Country", ns: XMPNamespace.photoshop, local: "Country", max: 64),
|
||||
f("countryCode", "Ländercode (ISO)", pm: "Country Code", .location,
|
||||
iim: "IPTC:Country-PrimaryLocationCode", xmp: "XMP-iptcCore:CountryCode", ns: XMPNamespace.iptcCore, local: "CountryCode", max: 3),
|
||||
|
||||
// --- Aufnahmeort (Iptc4xmpExt:LocationCreated, Struktur in einer Bag) ---
|
||||
f("lcSublocation", "Ortsdetail", pm: "Location Created: Sublocation", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedSublocation", ns: XMPNamespace.iptcExt, local: "Sublocation"),
|
||||
f("lcCity", "Stadt", pm: "Location Created: City", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedCity", ns: XMPNamespace.iptcExt, local: "City"),
|
||||
f("lcState", "Bundesland", pm: "Location Created: State/Province", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedProvinceState", ns: XMPNamespace.iptcExt, local: "ProvinceState"),
|
||||
f("lcCountry", "Land", pm: "Location Created: Country", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedCountryName", ns: XMPNamespace.iptcExt, local: "CountryName"),
|
||||
f("lcCountryCode", "Ländercode", pm: "Location Created: Country Code", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedCountryCode", ns: XMPNamespace.iptcExt, local: "CountryCode"),
|
||||
f("lcWorldRegion", "Weltregion", pm: "Location Created: World Region", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedWorldRegion", ns: XMPNamespace.iptcExt, local: "WorldRegion"),
|
||||
|
||||
// --- Urheber & Rechte ---
|
||||
f("creator", "Fotograf", pm: "Photographer / Creator", .creator,
|
||||
f("personInImage", "Abgebildete Personen", pm: "Persons shown", .imageContent, .list,
|
||||
iim: nil, xmp: "XMP-iptcExt:PersonInImage", ns: XMPNamespace.iptcExt, local: "PersonInImage", container: .bag),
|
||||
f("orgName", "Organisation (Name)", pm: "Featured Org. Name", .imageContent, .list,
|
||||
iim: nil, xmp: "XMP-iptcExt:OrganisationInImageName", ns: XMPNamespace.iptcExt, local: "OrganisationInImageName", container: .bag),
|
||||
f("orgCode", "Organisation (Code)", pm: "Featured Org. Code", .imageContent, .list,
|
||||
iim: nil, xmp: "XMP-iptcExt:OrganisationInImageCode", ns: XMPNamespace.iptcExt, local: "OrganisationInImageCode", container: .bag),
|
||||
f("scene", "Szene", pm: "IPTC Scene", .imageContent, .list,
|
||||
iim: nil, xmp: "XMP-iptcCore:Scene", ns: XMPNamespace.iptcCore, local: "Scene", container: .bag),
|
||||
// --- imageRights ---
|
||||
f("creator", "Fotograf", pm: "Creator/Photographer", .imageRights,
|
||||
iim: "IPTC:By-line", xmp: "XMP-dc:Creator", ns: XMPNamespace.dc, local: "creator", container: .seq, max: 32),
|
||||
f("creatorJobTitle", "Position des Fotografen", pm: "Photographer's Title", .creator,
|
||||
f("creatorIdentity", "Urheber-ID", pm: "Creator's Identity", .imageRights,
|
||||
iim: nil, xmp: "XMP-photomech:CreatorIdentity", ns: XMPNamespace.photomechanic, local: "CreatorIdentity"),
|
||||
f("creatorJobTitle", "Position", pm: "Creator's Job Title", .imageRights,
|
||||
iim: "IPTC:By-lineTitle", xmp: "XMP-photoshop:AuthorsPosition", ns: XMPNamespace.photoshop, local: "AuthorsPosition", max: 32),
|
||||
f("credit", "Credit / Anbieter", pm: "Credit", .creator,
|
||||
f("credit", "Credit", pm: "Credit Line", .imageRights,
|
||||
iim: "IPTC:Credit", xmp: "XMP-photoshop:Credit", ns: XMPNamespace.photoshop, local: "Credit", max: 32),
|
||||
f("source", "Quelle", pm: "Source", .creator,
|
||||
f("source", "Quelle", pm: "Source", .imageRights,
|
||||
iim: "IPTC:Source", xmp: "XMP-photoshop:Source", ns: XMPNamespace.photoshop, local: "Source", max: 32),
|
||||
f("copyright", "Copyright-Vermerk", pm: "Copyright Notice", .creator,
|
||||
f("copyright", "Copyright", pm: "Copyright Notice", .imageRights,
|
||||
iim: "IPTC:CopyrightNotice", xmp: "XMP-dc:Rights", ns: XMPNamespace.dc, local: "rights", container: .alt, max: 128),
|
||||
f("copyrightMarked", "Copyright-Status (True = geschützt)", pm: "Copyright Status", .creator,
|
||||
f("copyrightMarked", "Copyright-Status", pm: "Copyright Status (True/False)", .imageRights,
|
||||
iim: nil, xmp: "XMP-xmpRights:Marked", ns: XMPNamespace.xmpRights, local: "Marked"),
|
||||
f("dataMining", "Data Mining (PLUS)", pm: "Data Mining", .creator,
|
||||
iim: nil, xmp: "XMP-plus:DataMining#", ns: XMPNamespace.plus, local: "DataMining"),
|
||||
f("usageTerms", "Nutzungsbedingungen", pm: "Rights Usage Terms", .creator, .multiline,
|
||||
f("usageTerms", "Nutzungsbedingungen", pm: "Rights Usage Terms", .imageRights, .multiline,
|
||||
iim: nil, xmp: "XMP-xmpRights:UsageTerms", ns: XMPNamespace.xmpRights, local: "UsageTerms", container: .alt),
|
||||
f("webStatement", "Copyright-URL", pm: "Copyright Info URL", .creator,
|
||||
f("webStatement", "Copyright-URL", pm: "Copyright Info URL", .imageRights,
|
||||
iim: nil, xmp: "XMP-xmpRights:WebStatement", ns: XMPNamespace.xmpRights, local: "WebStatement"),
|
||||
|
||||
// --- Kontakt (IPTC Core CreatorContactInfo) ---
|
||||
f("dataMining", "Data Mining", pm: "Data Mining (PLUS)", .imageRights,
|
||||
iim: nil, xmp: "XMP-plus:DataMining#", ns: XMPNamespace.plus, local: "DataMining"),
|
||||
// --- contact ---
|
||||
f("ciAddress", "Adresse", pm: "Address", .contact,
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorAddress", ns: XMPNamespace.iptcCore, local: "CiAdrExtadr"),
|
||||
f("ciCity", "Stadt", pm: "City (Contact)", .contact,
|
||||
f("ciCity", "Stadt", pm: "City", .contact,
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorCity", ns: XMPNamespace.iptcCore, local: "CiAdrCity"),
|
||||
f("ciRegion", "Bundesland", pm: "State (Contact)", .contact,
|
||||
f("ciRegion", "Bundesland", pm: "State/Province", .contact,
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorRegion", ns: XMPNamespace.iptcCore, local: "CiAdrRegion"),
|
||||
f("ciPostalCode", "PLZ", pm: "Postal Code", .contact,
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorPostalCode", ns: XMPNamespace.iptcCore, local: "CiAdrPcode"),
|
||||
f("ciCountry", "Land", pm: "Country (Contact)", .contact,
|
||||
f("ciCountry", "Land", pm: "Country", .contact,
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorCountry", ns: XMPNamespace.iptcCore, local: "CiAdrCtry"),
|
||||
f("ciPhone", "Telefon", pm: "Phone", .contact,
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorWorkTelephone", ns: XMPNamespace.iptcCore, local: "CiTelWork"),
|
||||
@@ -161,16 +139,53 @@ public extension IPTCField {
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorWorkEmail", ns: XMPNamespace.iptcCore, local: "CiEmailWork"),
|
||||
f("ciURL", "Website", pm: "Web URL", .contact,
|
||||
iim: nil, xmp: "XMP-iptcCore:CreatorWorkURL", ns: XMPNamespace.iptcCore, local: "CiUrlWork"),
|
||||
|
||||
// --- Erweitert ---
|
||||
f("intellectualGenre", "Genre", pm: "Intellectual Genre", .extended,
|
||||
iim: "IPTC:ObjectAttributeReference", xmp: "XMP-iptcCore:IntellectualGenre", ns: XMPNamespace.iptcCore, local: "IntellectualGenre", max: 68),
|
||||
f("scene", "Szenen-Code", pm: "IPTC Scene", .extended, .list,
|
||||
iim: nil, xmp: "XMP-iptcCore:Scene", ns: XMPNamespace.iptcCore, local: "Scene", container: .bag),
|
||||
f("subjectCode", "Themen-Code", pm: "IPTC Subject Code", .extended, .list,
|
||||
// --- eventLocation ---
|
||||
f("event", "Ereignis", pm: "Event", .eventLocation,
|
||||
iim: nil, xmp: "XMP-iptcExt:Event", ns: XMPNamespace.iptcExt, local: "Event", container: .alt),
|
||||
f("dateCreated", "Datum", pm: "Date", .eventLocation,
|
||||
iim: "IPTC:DateCreated", xmp: "XMP-photoshop:DateCreated", ns: XMPNamespace.photoshop, local: "DateCreated", max: 8),
|
||||
f("city", "Stadt", pm: "City", .eventLocation,
|
||||
iim: "IPTC:City", xmp: "XMP-photoshop:City", ns: XMPNamespace.photoshop, local: "City", max: 32),
|
||||
f("sublocation", "Ort", pm: "Location", .eventLocation,
|
||||
iim: "IPTC:Sub-location", xmp: "XMP-iptcCore:Location", ns: XMPNamespace.iptcCore, local: "Location", max: 32),
|
||||
f("state", "Bundesland", pm: "State/Province", .eventLocation,
|
||||
iim: "IPTC:Province-State", xmp: "XMP-photoshop:State", ns: XMPNamespace.photoshop, local: "State", max: 32),
|
||||
f("country", "Land", pm: "Country", .eventLocation,
|
||||
iim: "IPTC:Country-PrimaryLocationName", xmp: "XMP-photoshop:Country", ns: XMPNamespace.photoshop, local: "Country", max: 64),
|
||||
f("countryCode", "Ländercode", pm: "ISO Country Code", .eventLocation,
|
||||
iim: "IPTC:Country-PrimaryLocationCode", xmp: "XMP-iptcCore:CountryCode", ns: XMPNamespace.iptcCore, local: "CountryCode", max: 3),
|
||||
f("subjectCode", "Themen-Code", pm: "IPTC Subject Code", .eventLocation, .list,
|
||||
iim: "IPTC:SubjectReference", xmp: "XMP-iptcCore:SubjectCode", ns: XMPNamespace.iptcCore, local: "SubjectCode", container: .bag, max: 236),
|
||||
f("personInImage", "Abgebildete Personen", pm: "Person Shown", .extended, .list,
|
||||
iim: nil, xmp: "XMP-iptcExt:PersonInImage", ns: XMPNamespace.iptcExt, local: "PersonInImage", container: .bag),
|
||||
f("intellectualGenre", "Genre", pm: "Intellectual Genre", .eventLocation,
|
||||
iim: "IPTC:ObjectAttributeReference", xmp: "XMP-iptcCore:IntellectualGenre", ns: XMPNamespace.iptcCore, local: "IntellectualGenre", max: 68),
|
||||
// --- locationCreated ---
|
||||
f("lcSublocation", "Ortsdetail", pm: "Sublocation", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedSublocation", ns: XMPNamespace.iptcExt, local: "Sublocation"),
|
||||
f("lcCity", "Stadt", pm: "City", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedCity", ns: XMPNamespace.iptcExt, local: "City"),
|
||||
f("lcState", "Bundesland", pm: "State", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedProvinceState", ns: XMPNamespace.iptcExt, local: "ProvinceState"),
|
||||
f("lcCountry", "Land", pm: "Country", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedCountryName", ns: XMPNamespace.iptcExt, local: "CountryName"),
|
||||
f("lcCountryCode", "Ländercode", pm: "Country Code", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedCountryCode", ns: XMPNamespace.iptcExt, local: "CountryCode"),
|
||||
f("lcWorldRegion", "Weltregion", pm: "World Region", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedWorldRegion", ns: XMPNamespace.iptcExt, local: "WorldRegion"),
|
||||
f("lcLocationId", "Orts-ID", pm: "Location ID", .locationCreated,
|
||||
iim: nil, xmp: "XMP-iptcExt:LocationCreatedLocationId", ns: XMPNamespace.iptcExt, local: "LocationId"),
|
||||
// --- status ---
|
||||
f("objectName", "Titel", pm: "Title", .status,
|
||||
iim: "IPTC:ObjectName", xmp: "XMP-dc:Title", ns: XMPNamespace.dc, local: "title", container: .alt, max: 64),
|
||||
f("transmissionReference", "Job-ID", pm: "Job Identifier", .status,
|
||||
iim: "IPTC:OriginalTransmissionReference", xmp: "XMP-photoshop:TransmissionReference", ns: XMPNamespace.photoshop, local: "TransmissionReference", max: 32),
|
||||
f("instructions", "Anweisungen", pm: "Instructions", .status, .multiline,
|
||||
iim: "IPTC:SpecialInstructions", xmp: "XMP-photoshop:Instructions", ns: XMPNamespace.photoshop, local: "Instructions", max: 256),
|
||||
f("urgency", "Dringlichkeit", pm: "Urgency", .status,
|
||||
iim: "IPTC:Urgency", xmp: "XMP-photoshop:Urgency", ns: XMPNamespace.photoshop, local: "Urgency", max: 1),
|
||||
f("category", "Kategorie", pm: "Category", .status,
|
||||
iim: "IPTC:Category", xmp: "XMP-photoshop:Category", ns: XMPNamespace.photoshop, local: "Category", max: 3),
|
||||
f("supplementalCategories", "Zusatzkategorien", pm: "Supplemental Categories", .status, .list,
|
||||
iim: "IPTC:SupplementalCategories", xmp: "XMP-photoshop:SupplementalCategories", ns: XMPNamespace.photoshop, local: "SupplementalCategories", container: .bag, max: 32),
|
||||
]
|
||||
|
||||
/// Key in exiftool's JSON output (a trailing "#" only disables print conversion).
|
||||
|
||||
Reference in new issue
Block a user