Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Name a reset and a saved copy of settings in History as what they are

Țugui Dragoș334642b24aba
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 0161612c..4a84341e 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -130397,6 +130397,112 @@
}
}
},
+ "Reset of %@" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Resetování aplikace %@"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Zurücksetzen von „%@“"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Restablecimiento de %@"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Réinitialisation de %@"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Reimpostazione di %@"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@のリセット"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ 재설정 작업"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Opnieuw instellen van %@"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Wyzerowanie aplikacji %@"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Redefinição de %@"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Resetarea aplicației %@"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Сброс приложения «%@»"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nollställning av %@"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ Uygulamasının Sıfırlanması"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Скидання «%@»"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@的重置"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "「%@」的重置作業"
+ }
+ }
+ }
+ },
"Reset privacy permissions" : {
"localizations" : {
"cs" : {
@@ -140521,6 +140627,112 @@
}
}
},
+ "Settings Saved for %@" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nastavení uložená pro aplikaci %@"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Für „%@“ gesicherte Einstellungen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ajustes guardados de %@"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Réglages enregistrés de %@"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Impostazioni salvate per %@"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@用に保存された設定"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@의 저장된 설정"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bewaarde instellingen van %@"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Zachowane ustawienia aplikacji %@"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ajustes Salvos de %@"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Configurări salvate pentru %@"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Сохраненные настройки: %@"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sparade inställningar för %@"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ İçin Kaydedilen Ayarlar"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Збережені налаштування програми «%@»"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "为%@保存的设置"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "為%@儲存的設定"
+ }
+ }
+ }
+ },
"Settings…" : {
"localizations" : {
"cs" : {
@@ -173119,6 +173331,112 @@
}
}
},
+ "Undo Reset %@" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Odvolat resetování „%@“"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "„%@“ zurücksetzen widerrufen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Deshacer restablecimiento de %@"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Annuler la réinitialisation de %@"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Annulla reimpostazione di %@"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "“%@”のリセットを取り消す"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "‘%@’ 재설정 실행 취소"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Herstel opnieuw instellen van %@"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Cofnij Wyzeruj „%@”"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Desfazer Redefinir %@"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Infirmați resetarea „%@”"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Отменить сброс «%@»"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ångra nollställning av %@"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sıfırlamayı Geri Al: %@"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Відмінити скидання «%@»"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "撤销重置“%@”"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "還原重置「%@」"
+ }
+ }
+ }
+ },
"Unfinished Downloads" : {
"localizations" : {
"cs" : {
diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swift
index 60f63e39..d0d9881e 100644
--- a/Peel/Model/RemovalHistoryStore.swift
+++ b/Peel/Model/RemovalHistoryStore.swift
@@ -55,9 +55,24 @@ nonisolated struct RemovalBatch: Identifiable, Hashable {
if key.hasPrefix("casks."), let count = Int(key.dropFirst("casks.".count)) {
return String(inflecting: "^[\(count) cask](inflect: true)")
}
+ if key.hasPrefix("reset.") {
+ return String(localized: "Reset of \(String(key.dropFirst("reset.".count)))")
+ }
+ if key.hasPrefix("savedSettings.") {
+ return String(localized: "Settings Saved for \(String(key.dropFirst("savedSettings.".count)))")
+ }
return source
}
+ /// What Edit > Undo says for a removal of `parts` titled `title`: a reset is undone by name, anything else as a
+ /// removal.
+ static func undoTitle(of parts: [RemovalPart], title: String) -> String {
+ if parts.count == 1, let key = parts[0].sourceKey, key.hasPrefix("reset.") {
+ return String(localized: "Undo Reset \(String(key.dropFirst("reset.".count)))")
+ }
+ return String(localized: "Undo Remove \(title)")
+ }
+
var size: SizeTotal { records.totalSize }
@MainActor
@@ -102,7 +117,7 @@ final class RemovalHistoryStore {
var stats: LifetimeStats?
/// The last batch moved, for Undo. `@Environment(\.undoManager)` is nil in an app with no documents,
/// so the Edit menu's own item is replaced by one that asks this (`PeelCommands`).
- private(set) var undoable: (records: [RemovalRecord], source: String)?
+ private(set) var undoable: (records: [RemovalRecord], title: String)?
/// The last batch moved in this session, which the removal bar briefly reports.
private(set) var justMoved: RemovalBatch?
/// Whether the helper can act. The window keeps this current, so Undo in the Edit menu can use the helper.
@@ -243,27 +258,22 @@ final class RemovalHistoryStore {
/// totals, and Undo.
func finish(_ removal: RemovalInProgress) {
guard !removal.records.isEmpty else { return }
- let moved = RemovalBatch(
- id: removal.batch,
- parts: RemovalPart.of(removal.records.map { ($0.date, $0.part) }),
- date: .now,
- records: removal.records
- )
+ let parts = RemovalPart.of(removal.records.map { ($0.date, $0.part) })
+ let moved = RemovalBatch(id: removal.batch, parts: parts, date: .now, records: removal.records)
justMoved = moved
AccessibilityNotification.Announcement(moved.movedAnnouncement).post()
stats?.reload()
- registerUndo(of: removal.records, source: moved.title)
+ registerUndo(of: removal.records, title: RemovalBatch.undoTitle(of: parts, title: moved.title))
}
/// Makes the last batch undoable, as Finder does after a move to the Trash: Command-Z puts it back, and the
- /// Edit menu names its source. Put Back in History does the same, and both refuse an item that has since
- /// left the Trash.
- private func registerUndo(of records: [RemovalRecord], source: String) {
- undoable = records.isEmpty ? nil : (records, source)
+ /// Edit menu names it. Put Back in History does the same, and both refuse an item that has since left the Trash.
+ private func registerUndo(of records: [RemovalRecord], title: String) {
+ undoable = records.isEmpty ? nil : (records, title)
}
- /// The name the Edit menu shows, and nil when there is nothing to undo.
- var undoName: String? { undoable?.source }
+ /// What the Edit menu shows, and nil when there is nothing to undo.
+ var undoTitle: String? { undoable?.title }
/// Puts the last batch back. Nothing happens while another Put Back runs, and the batch stays undoable: `restore`
/// takes one at a time and would drop this one without a word.
diff --git a/Peel/Navigation/PeelCommands.swift b/Peel/Navigation/PeelCommands.swift
index 2cddc005..77071a93 100644
--- a/Peel/Navigation/PeelCommands.swift
+++ b/Peel/Navigation/PeelCommands.swift
@@ -72,14 +72,14 @@ struct PeelCommands: Commands {
Button {
Task { await history?.undoLastRemoval() }
} label: {
- if let name = history?.undoName {
- Text("Undo Remove \(name)")
+ if let title = history?.undoTitle {
+ Text(verbatim: title)
} else {
Text("Undo")
}
}
.keyboardShortcut("z", modifiers: .command)
- .disabled(history?.undoName == nil || history?.isRestoring == true || sheetInFront.isShowing)
+ .disabled(history?.undoTitle == nil || history?.isRestoring == true || sheetInFront.isShowing)
Button("Redo") {}
.keyboardShortcut("z", modifiers: [.command, .shift])
.disabled(true)
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index 1e374af0..44a3a1f2 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -43,7 +43,13 @@ struct ResetSheet: View {
if !result.trashed.isEmpty {
changedFiles = true
}
- await history.record(result, tool: .applications, source: plan.app.name, sizes: sizes)
+ await history.record(
+ result,
+ tool: .applications,
+ source: "Reset of \(plan.app.name)",
+ sourceKey: "reset.\(plan.app.name)",
+ sizes: sizes
+ )
}
}
}
diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swift
index 11c63033..f717c100 100644
--- a/Peel/Views/Settings/SavedSettingsSection.swift
+++ b/Peel/Views/Settings/SavedSettingsSection.swift
@@ -156,7 +156,8 @@ struct SavedSettingsSection: View {
await history.record(
result,
tool: .applications,
- source: name,
+ source: "Settings Saved for \(name)",
+ sourceKey: "savedSettings.\(name)",
sizes: [URL: Int64](measured: [(copy.folder, size)])
)
}