From 2cc313855b0885d8714babd4f82ea27702af7a9a Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 18 Jul 2025 12:36:25 +0700 Subject: [PATCH] launcher: clipboard: delete button --- .../ii/modules/overview/SearchItem.qml | 44 ++++++++++++++++++- .../ii/modules/overview/SearchWidget.qml | 13 +++++- .config/quickshell/ii/services/Cliphist.qml | 24 +++++++++- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/.config/quickshell/ii/modules/overview/SearchItem.qml b/.config/quickshell/ii/modules/overview/SearchItem.qml index e7b33acea..1fb23b277 100644 --- a/.config/quickshell/ii/modules/overview/SearchItem.qml +++ b/.config/quickshell/ii/modules/overview/SearchItem.qml @@ -14,7 +14,7 @@ RippleButton { property var entry property string query property bool entryShown: entry?.shown ?? true - property string itemType: entry?.type + property string itemType: entry?.type ?? Translation.tr("App") property string itemName: entry?.name property string itemIcon: entry?.icon ?? "" property var itemExecute: entry?.execute @@ -221,5 +221,47 @@ RippleButton { horizontalAlignment: Text.AlignRight text: root.itemClickActionName } + + RowLayout { + spacing: 4 + Repeater { + model: (root.entry.actions ?? []).slice(0, 4) + delegate: RippleButton { + id: actionButton + required property var modelData + implicitHeight: 34 + implicitWidth: 34 + + contentItem: Item { + id: actionContentItem + anchors.centerIn: parent + Loader { + anchors.centerIn: parent + active: !(actionButton.modelData.icon && actionButton.modelData.icon !== "") + sourceComponent: MaterialSymbol { + text: "video_settings" + font.pixelSize: Appearance.font.pixelSize.hugeass + color: Appearance.m3colors.m3onSurface + } + } + Loader { + anchors.centerIn: parent + active: actionButton.modelData.icon && actionButton.modelData.icon !== "" + sourceComponent: IconImage { + source: Quickshell.iconPath(actionButton.modelData.icon) + implicitSize: 20 + } + } + } + + onClicked: modelData.execute() + + StyledToolTip { + content: modelData.name + } + } + } + } + } } diff --git a/.config/quickshell/ii/modules/overview/SearchWidget.qml b/.config/quickshell/ii/modules/overview/SearchWidget.qml index 3ec0b0bdd..851f5e377 100644 --- a/.config/quickshell/ii/modules/overview/SearchWidget.qml +++ b/.config/quickshell/ii/modules/overview/SearchWidget.qml @@ -294,8 +294,17 @@ Item { // Wrapper clickActionName: "", type: `#${entry.match(/^\s*(\S+)/)?.[1] || ""}`, execute: () => { - Quickshell.execDetached(["bash", "-c", `echo '${StringUtils.shellSingleQuoteEscape(entry)}' | cliphist decode | wl-copy`]); - } + Cliphist.copy(entry) + }, + actions: [ + { + name: "Delete", + icon: "delete", + execute: () => { + Cliphist.deleteEntry(entry); + } + } + ] }; }).filter(Boolean); } diff --git a/.config/quickshell/ii/services/Cliphist.qml b/.config/quickshell/ii/services/Cliphist.qml index ea4400bb9..0fe7ad71a 100644 --- a/.config/quickshell/ii/services/Cliphist.qml +++ b/.config/quickshell/ii/services/Cliphist.qml @@ -4,7 +4,7 @@ pragma ComponentBehavior: Bound import "root:/modules/common/functions/fuzzysort.js" as Fuzzy import "root:/modules/common/functions/levendist.js" as Levendist import qs.modules.common -import qs +import qs.modules.common.functions import QtQuick import Quickshell import Quickshell.Io @@ -42,6 +42,28 @@ Singleton { readProc.running = true } + function copy(entry) { + Quickshell.execDetached(["bash", "-c", `echo '${StringUtils.shellSingleQuoteEscape(entry)}' | cliphist decode | wl-copy`]); + } + + Process { + id: deleteProc + property string entry: "" + command: ["bash", "-c", `echo '${StringUtils.shellSingleQuoteEscape(deleteProc.entry)}' | cliphist delete`] + function deleteEntry(entry) { + deleteProc.entry = entry; + deleteProc.running = true; + deleteProc.entry = ""; + } + onExited: (exitCode, exitStatus) => { + root.refresh(); + } + } + + function deleteEntry(entry) { + deleteProc.deleteEntry(entry); + } + Connections { target: Quickshell function onClipboardTextChanged() {