Copy clipboard history selection with Shift Return

This commit is contained in:
David Heinemeier Hansson
2026-05-29 13:15:00 +02:00
parent cf3a481224
commit bb0d9dd2e3
4 changed files with 66 additions and 5 deletions
+18 -1
View File
@@ -175,6 +175,12 @@ Item {
root.applySelected(row)
}
function copyIndex(index) {
if (index < 0 || index >= displayModel.count) return
var row = displayModel.get(index)
root.copySelected(row)
}
function applySelected(row) {
if (!row) return
root.opened = false
@@ -185,6 +191,16 @@ Item {
}
}
function copySelected(row) {
if (!row) return
root.opened = false
if (row.entryType === "image") {
Quickshell.execDetached([root.omarchyPath + "/bin/omarchy-clipboard-paste-file", "--copy-only", row.mime, row.path])
} else if (row.fullText) {
Quickshell.execDetached([root.omarchyPath + "/bin/omarchy-clipboard-paste-text", "--copy-only", "--history-index", String(row.index)])
}
}
Component.onCompleted: initProc.running = true
ListModel { id: displayModel }
@@ -295,7 +311,8 @@ Item {
root.select(6)
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (root.cursorActive) root.activateIndex(root.selectedIndex)
if (root.cursorActive && (event.modifiers & Qt.ShiftModifier)) root.copyIndex(root.selectedIndex)
else if (root.cursorActive) root.activateIndex(root.selectedIndex)
else if (displayModel.count > 0) root.cursorActive = true
event.accepted = true
} else if (event.text && event.text.length === 1 && event.text.charCodeAt(0) >= 32 && event.text.charCodeAt(0) !== 127) {