mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-18 09:05:24 -04:00
fix(clipboard): paste selected history entry (#2660)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -39,6 +39,9 @@ Singleton {
|
||||
|
||||
Process {
|
||||
id: wtypeProcess
|
||||
// TODO: This is only a paste shortcut fallback. It assumes the target
|
||||
// application accepts Ctrl+V, which is false for many terminals.
|
||||
// Replace with a more reliable target-aware paste strategy.
|
||||
command: ["wtype", "-M", "ctrl", "-P", "v", "-p", "v", "-m", "ctrl"]
|
||||
running: false
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ Singleton {
|
||||
}
|
||||
|
||||
function closeClipboardHistory() {
|
||||
clipboardHistoryModal?.close();
|
||||
clipboardHistoryModal?.hide();
|
||||
}
|
||||
|
||||
function unloadClipboardHistoryPopout() {
|
||||
|
||||
Reference in New Issue
Block a user