1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-18 17:15:20 -04:00

fix(clipboard): paste selected history entry (#2660)

This commit is contained in:
jbwfu
2026-06-18 12:57:07 +08:00
committed by GitHub
parent 085ce01da6
commit b925010cb3
6 changed files with 74 additions and 8 deletions
@@ -15,6 +15,12 @@ Item {
property var entry: null
property string editorText: ""
function releaseTextInputFocus() {
if (editField) {
editField.focus = false;
}
}
function decodeEntryData(data) {
if (!data) {
return "";
@@ -61,16 +61,46 @@ FocusScope {
}
}
function releaseTextInputFocus() {
// Drop text-input focus before hiding the Wayland surface.
if (searchField) {
searchField.setFocus(false);
}
if (editorView) {
editorView.releaseTextInputFocus();
}
root.forceActiveFocus();
}
function requestClose(instant) {
releaseTextInputFocus();
if (instant) {
root.instantCloseRequested();
} else {
root.closeRequested();
}
}
function hide() {
closeRequested();
requestClose(false);
}
function pasteSelected() {
ClipboardService.pasteSelected(() => root.instantCloseRequested());
const entry = selectedEntry();
if (!entry)
return;
ClipboardService.pasteEntry(entry, () => root.requestClose(true));
}
function copyEntry(entry) {
ClipboardService.copyEntry(entry, () => root.closeRequested());
ClipboardService.copyEntry(entry, () => root.requestClose(false));
}
function selectedEntry() {
const entries = activeTab === "saved" ? pinnedEntries : unpinnedEntries;
if (!entries || entries.length === 0 || selectedIndex < 0 || selectedIndex >= entries.length)
return null;
return entries[selectedIndex];
}
function deleteEntry(entry) {
@@ -45,8 +45,22 @@ DankModal {
});
}
function releaseTextInputFocus() {
contentLoader.item?.releaseTextInputFocus();
}
function hide() {
close();
releaseTextInputFocus();
Qt.callLater(function () {
clipboardHistoryModal.close();
});
}
function instantHide() {
releaseTextInputFocus();
Qt.callLater(function () {
clipboardHistoryModal.instantClose();
});
}
onDialogClosed: {
@@ -68,6 +82,11 @@ DankModal {
enableShadow: true
closeOnEscapeKey: (contentLoader.item?.mode ?? "history") !== "editor"
onBackgroundClicked: hide()
onShouldBeVisibleChanged: {
if (!shouldBeVisible) {
releaseTextInputFocus();
}
}
Ref {
service: ClipboardService
@@ -112,7 +131,7 @@ DankModal {
ClipboardHistoryContent {
clearConfirmDialog: clearConfirmDialog
onCloseRequested: clipboardHistoryModal.hide()
onInstantCloseRequested: clipboardHistoryModal.instantClose()
onInstantCloseRequested: clipboardHistoryModal.instantHide()
}
}
}
@@ -37,8 +37,15 @@ DankPopout {
});
}
function releaseTextInputFocus() {
contentLoader.item?.releaseTextInputFocus();
}
function hide() {
close();
releaseTextInputFocus();
Qt.callLater(function () {
root.close();
});
}
function clearAll() {
@@ -57,6 +64,7 @@ DankPopout {
onShouldBeVisibleChanged: {
if (!shouldBeVisible) {
releaseTextInputFocus();
return;
}
if (clipboardAvailable) {
@@ -134,7 +142,7 @@ DankPopout {
clearConfirmDialog: clearConfirmDialog
onCloseRequested: root.hide()
onInstantCloseRequested: root.close()
onInstantCloseRequested: root.hide()
Component.onCompleted: {
activeTab = root.activeTab;