Add Copy & Delete to the selection bar
Scissors icon next to the copy actions; a single item copies as-is (image included), a multi-selection copies as plain lines, then everything selected is deleted.
This commit is contained in:
@@ -705,6 +705,12 @@ struct PanelView: View {
|
||||
.font(.caption)
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
Button { copyAndDeleteSelection() } label: {
|
||||
Image(systemName: "scissors")
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
.help("Copy & Delete")
|
||||
Button { deleteSelection() } label: {
|
||||
Image(systemName: "trash")
|
||||
}
|
||||
@@ -729,6 +735,20 @@ struct PanelView: View {
|
||||
clearSelection()
|
||||
}
|
||||
|
||||
/// Same as the context menu's Copy & Delete, for the selection bar. A
|
||||
/// single image still copies as an image; a multi-selection copies as
|
||||
/// plain lines, same as Copy as Lines.
|
||||
private func copyAndDeleteSelection() {
|
||||
guard !selection.isEmpty else { return }
|
||||
if selection.count == 1, let id = selection.first, let item = store.item(id) {
|
||||
store.copy(item)
|
||||
} else {
|
||||
store.copyAsLines(ids: selection)
|
||||
}
|
||||
store.delete(ids: selection)
|
||||
clearSelection()
|
||||
}
|
||||
|
||||
private func copySelection(asList: Bool) {
|
||||
guard !selection.isEmpty else { return }
|
||||
if asList {
|
||||
|
||||
Reference in New Issue
Block a user