clipboard history: images

This commit is contained in:
end-4
2025-05-28 00:09:38 +02:00
parent f04d5f6202
commit 442ddc1a7b
6 changed files with 123 additions and 12 deletions
@@ -1,4 +1,5 @@
import "root:/"
import "root:/services"
import "root:/modules/common"
import "root:/modules/common/widgets"
import QtQuick
@@ -191,6 +192,7 @@ Scope {
GlobalStates.overviewOpen = false;
return;
}
Cliphist.refresh()
for (let i = 0; i < overviewVariants.instances.length; i++) {
let panelWindow = overviewVariants.instances[i];
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
@@ -25,6 +25,7 @@ RippleButton {
property string fontType: entry?.fontType ?? "main"
property string itemClickActionName: entry?.clickActionName
property string materialSymbol: entry?.materialSymbol ?? ""
property string cliphistRawString: entry?.cliphistRawString ?? ""
property string highlightPrefix: `<u><font color="${Appearance.m3colors.m3primary}">`
property string highlightSuffix: `</font></u>`
@@ -62,8 +63,8 @@ RippleButton {
if (!root.itemName) return [];
// Regular expression to match URLs
const urlRegex = /https?:\/\/[^\s<>"{}|\\^`[\]]+/gi;
const matches = root.itemName.match(urlRegex)
.filter(url => !url.includes("…")) // Elided = invalid
const matches = root.itemName?.match(urlRegex)
?.filter(url => !url.includes("…")) // Elided = invalid
return matches ? matches : [];
}
@@ -143,6 +144,7 @@ RippleButton {
// Main text
ColumnLayout {
id: contentColumn
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
spacing: 0
@@ -173,6 +175,15 @@ RippleButton {
text: `${root.displayContent}`
}
}
Loader {
active: root.cliphistRawString && /^\d+\t\[\[.*binary data.*\d+x\d+.*\]\]$/.test(root.cliphistRawString)
sourceComponent: CliphistImage {
Layout.fillWidth: true
entry: root.cliphistRawString
maxWidth: contentColumn.width
maxHeight: 140
}
}
}
// Action text
@@ -275,7 +275,7 @@ Item { // Wrapper
clip: true
topMargin: 10
bottomMargin: 10
spacing: 0
spacing: 2
KeyNavigation.up: searchBar
onFocusChanged: {
@@ -305,11 +305,13 @@ Item { // Wrapper
const searchString = root.searchingText.slice(ConfigOptions.search.prefix.clipboard.length);
return Cliphist.fuzzyQuery(searchString).map(entry => {
return {
cliphistRawString: entry,
name: entry.replace(/^\s*\S+\s+/, ""),
clickActionName: qsTr("Copy"),
clickActionName: "",
type: `#${entry.match(/^\s*(\S+)/)?.[1] || ""}`,
execute: () => {
Hyprland.dispatch(`exec echo '${StringUtils.shellSingleQuoteEscape(entry)}' | cliphist decode | wl-copy`);
Cliphist.refresh()
}
};
}).filter(Boolean);