Don't scroll when deleting clipboard history items (#2198)

This commit is contained in:
end-4
2025-10-14 09:22:14 +02:00
committed by GitHub
@@ -187,6 +187,7 @@ Item { // Wrapper
searchInput.text = searchInput.text.slice(0, searchInput.cursorPosition) + event.text + searchInput.text.slice(searchInput.cursorPosition); searchInput.text = searchInput.text.slice(0, searchInput.cursorPosition) + event.text + searchInput.text.slice(searchInput.cursorPosition);
searchInput.cursorPosition += 1; searchInput.cursorPosition += 1;
event.accepted = true; event.accepted = true;
root.focusFirstItem();
} }
} }
} }
@@ -315,9 +316,7 @@ Item { // Wrapper
model: ScriptModel { model: ScriptModel {
id: model id: model
onValuesChanged: { objectProp: "key"
root.focusFirstItem();
}
values: { values: {
// Search results are handled here // Search results are handled here
////////////////// Skip? ////////////////// ////////////////// Skip? //////////////////
@@ -334,11 +333,13 @@ Item { // Wrapper
if (mightBlurImage) { if (mightBlurImage) {
shouldBlurImage = shouldBlurImage && (containsUnsafeLink(array[index - 1]) || containsUnsafeLink(array[index + 1])); shouldBlurImage = shouldBlurImage && (containsUnsafeLink(array[index - 1]) || containsUnsafeLink(array[index + 1]));
} }
const type = `#${entry.match(/^\s*(\S+)/)?.[1] || ""}`
return { return {
key: type,
cliphistRawString: entry, cliphistRawString: entry,
name: StringUtils.cleanCliphistEntry(entry), name: StringUtils.cleanCliphistEntry(entry),
clickActionName: "", clickActionName: "",
type: `#${entry.match(/^\s*(\S+)/)?.[1] || ""}`, type: type,
execute: () => { execute: () => {
Cliphist.copy(entry) Cliphist.copy(entry)
}, },
@@ -367,9 +368,11 @@ Item { // Wrapper
// Clipboard // Clipboard
const searchString = StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.emojis); const searchString = StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.emojis);
return Emojis.fuzzyQuery(searchString).map(entry => { return Emojis.fuzzyQuery(searchString).map(entry => {
const emoji = entry.match(/^\s*(\S+)/)?.[1] || ""
return { return {
key: emoji,
cliphistRawString: entry, cliphistRawString: entry,
bigText: entry.match(/^\s*(\S+)/)?.[1] || "", bigText: emoji,
name: entry.replace(/^\s*\S+\s+/, ""), name: entry.replace(/^\s*\S+\s+/, ""),
clickActionName: "", clickActionName: "",
type: "Emoji", type: "Emoji",
@@ -383,6 +386,7 @@ Item { // Wrapper
////////////////// Init /////////////////// ////////////////// Init ///////////////////
nonAppResultsTimer.restart(); nonAppResultsTimer.restart();
const mathResultObject = { const mathResultObject = {
key: `Math result: ${root.mathResult}`,
name: root.mathResult, name: root.mathResult,
clickActionName: Translation.tr("Copy"), clickActionName: Translation.tr("Copy"),
type: Translation.tr("Math result"), type: Translation.tr("Math result"),
@@ -395,9 +399,11 @@ Item { // Wrapper
const appResultObjects = AppSearch.fuzzyQuery(StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.app)).map(entry => { const appResultObjects = AppSearch.fuzzyQuery(StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.app)).map(entry => {
entry.clickActionName = Translation.tr("Launch"); entry.clickActionName = Translation.tr("Launch");
entry.type = Translation.tr("App"); entry.type = Translation.tr("App");
entry.key = entry.execute
return entry; return entry;
}) })
const commandResultObject = { const commandResultObject = {
key: `cmd ${root.searchingText}`,
name: StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.shellCommand).replace("file://", ""), name: StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.shellCommand).replace("file://", ""),
clickActionName: Translation.tr("Run"), clickActionName: Translation.tr("Run"),
type: Translation.tr("Run command"), type: Translation.tr("Run command"),
@@ -413,6 +419,7 @@ Item { // Wrapper
} }
}; };
const webSearchResultObject = { const webSearchResultObject = {
key: `website ${root.searchingText}`,
name: StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.webSearch), name: StringUtils.cleanPrefix(root.searchingText, Config.options.search.prefix.webSearch),
clickActionName: Translation.tr("Search"), clickActionName: Translation.tr("Search"),
type: Translation.tr("Search the web"), type: Translation.tr("Search the web"),
@@ -430,6 +437,7 @@ Item { // Wrapper
const actionString = `${Config.options.search.prefix.action}${action.action}`; const actionString = `${Config.options.search.prefix.action}${action.action}`;
if (actionString.startsWith(root.searchingText) || root.searchingText.startsWith(actionString)) { if (actionString.startsWith(root.searchingText) || root.searchingText.startsWith(actionString)) {
return { return {
key: `Action ${actionString}`,
name: root.searchingText.startsWith(actionString) ? root.searchingText : actionString, name: root.searchingText.startsWith(actionString) ? root.searchingText : actionString,
clickActionName: Translation.tr("Run"), clickActionName: Translation.tr("Run"),
type: Translation.tr("Action"), type: Translation.tr("Action"),