mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-19 01:25:21 -04:00
fix(clipboard): paste selected history entry (#2660)
This commit is contained in:
@@ -15,6 +15,12 @@ Item {
|
|||||||
property var entry: null
|
property var entry: null
|
||||||
property string editorText: ""
|
property string editorText: ""
|
||||||
|
|
||||||
|
function releaseTextInputFocus() {
|
||||||
|
if (editField) {
|
||||||
|
editField.focus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function decodeEntryData(data) {
|
function decodeEntryData(data) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return "";
|
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() {
|
function hide() {
|
||||||
closeRequested();
|
requestClose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pasteSelected() {
|
function pasteSelected() {
|
||||||
ClipboardService.pasteSelected(() => root.instantCloseRequested());
|
const entry = selectedEntry();
|
||||||
|
if (!entry)
|
||||||
|
return;
|
||||||
|
ClipboardService.pasteEntry(entry, () => root.requestClose(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyEntry(entry) {
|
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) {
|
function deleteEntry(entry) {
|
||||||
|
|||||||
@@ -45,8 +45,22 @@ DankModal {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function releaseTextInputFocus() {
|
||||||
|
contentLoader.item?.releaseTextInputFocus();
|
||||||
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
close();
|
releaseTextInputFocus();
|
||||||
|
Qt.callLater(function () {
|
||||||
|
clipboardHistoryModal.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function instantHide() {
|
||||||
|
releaseTextInputFocus();
|
||||||
|
Qt.callLater(function () {
|
||||||
|
clipboardHistoryModal.instantClose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onDialogClosed: {
|
onDialogClosed: {
|
||||||
@@ -68,6 +82,11 @@ DankModal {
|
|||||||
enableShadow: true
|
enableShadow: true
|
||||||
closeOnEscapeKey: (contentLoader.item?.mode ?? "history") !== "editor"
|
closeOnEscapeKey: (contentLoader.item?.mode ?? "history") !== "editor"
|
||||||
onBackgroundClicked: hide()
|
onBackgroundClicked: hide()
|
||||||
|
onShouldBeVisibleChanged: {
|
||||||
|
if (!shouldBeVisible) {
|
||||||
|
releaseTextInputFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ref {
|
Ref {
|
||||||
service: ClipboardService
|
service: ClipboardService
|
||||||
@@ -112,7 +131,7 @@ DankModal {
|
|||||||
ClipboardHistoryContent {
|
ClipboardHistoryContent {
|
||||||
clearConfirmDialog: clearConfirmDialog
|
clearConfirmDialog: clearConfirmDialog
|
||||||
onCloseRequested: clipboardHistoryModal.hide()
|
onCloseRequested: clipboardHistoryModal.hide()
|
||||||
onInstantCloseRequested: clipboardHistoryModal.instantClose()
|
onInstantCloseRequested: clipboardHistoryModal.instantHide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,15 @@ DankPopout {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function releaseTextInputFocus() {
|
||||||
|
contentLoader.item?.releaseTextInputFocus();
|
||||||
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
close();
|
releaseTextInputFocus();
|
||||||
|
Qt.callLater(function () {
|
||||||
|
root.close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAll() {
|
function clearAll() {
|
||||||
@@ -57,6 +64,7 @@ DankPopout {
|
|||||||
|
|
||||||
onShouldBeVisibleChanged: {
|
onShouldBeVisibleChanged: {
|
||||||
if (!shouldBeVisible) {
|
if (!shouldBeVisible) {
|
||||||
|
releaseTextInputFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (clipboardAvailable) {
|
if (clipboardAvailable) {
|
||||||
@@ -134,7 +142,7 @@ DankPopout {
|
|||||||
|
|
||||||
clearConfirmDialog: clearConfirmDialog
|
clearConfirmDialog: clearConfirmDialog
|
||||||
onCloseRequested: root.hide()
|
onCloseRequested: root.hide()
|
||||||
onInstantCloseRequested: root.close()
|
onInstantCloseRequested: root.hide()
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
activeTab = root.activeTab;
|
activeTab = root.activeTab;
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ Singleton {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: wtypeProcess
|
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"]
|
command: ["wtype", "-M", "ctrl", "-P", "v", "-p", "v", "-m", "ctrl"]
|
||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeClipboardHistory() {
|
function closeClipboardHistory() {
|
||||||
clipboardHistoryModal?.close();
|
clipboardHistoryModal?.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function unloadClipboardHistoryPopout() {
|
function unloadClipboardHistoryPopout() {
|
||||||
|
|||||||
Reference in New Issue
Block a user