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
@@ -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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user