1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

clipboard: add shift+enter to paste from clipboard history modal

fixes #358
This commit is contained in:
bbedward
2025-12-12 15:29:10 -05:00
parent 0ff9fdb365
commit d46302588a
5 changed files with 68 additions and 6 deletions

5
CHANGELOG.MD Normal file
View File

@@ -0,0 +1,5 @@
# 1.2.0
- Added clipboard and clipboard history integration
- Added swipe to dismiss notification popups and from center
- Added paste from clipboard history view - requires wtype

View File

@@ -158,5 +158,6 @@ Item {
anchors.right: parent.right
anchors.margins: Theme.spacingL
visible: modal.showKeyboardHints
wtypeAvailable: modal.wtypeAvailable
}
}

View File

@@ -2,6 +2,7 @@ pragma ComponentBehavior: Bound
import QtQuick
import Quickshell.Hyprland
import Quickshell.Io
import qs.Common
import qs.Modals.Common
import qs.Services
@@ -26,6 +27,50 @@ DankModal {
property int activeImageLoads: 0
readonly property int maxConcurrentLoads: 3
readonly property bool clipboardAvailable: DMSService.isConnected && DMSService.capabilities.includes("clipboard")
property bool wtypeAvailable: false
Process {
id: wtypeCheck
command: ["which", "wtype"]
running: true
onExited: exitCode => {
clipboardHistoryModal.wtypeAvailable = (exitCode === 0);
}
}
Process {
id: wtypeProcess
command: ["wtype", "-M", "ctrl", "-P", "v", "-p", "v", "-m", "ctrl"]
running: false
}
Timer {
id: pasteTimer
interval: 200
repeat: false
onTriggered: wtypeProcess.running = true
}
function pasteSelected() {
if (!keyboardNavigationActive || clipboardEntries.length === 0 || selectedIndex < 0 || selectedIndex >= clipboardEntries.length) {
return;
}
if (!wtypeAvailable) {
ToastService.showError(I18n.tr("wtype not available - install wtype for paste support"));
return;
}
const entry = clipboardEntries[selectedIndex];
DMSService.sendRequest("clipboard.copyEntry", {
"id": entry.id
}, function (response) {
if (response.error) {
ToastService.showError(I18n.tr("Failed to copy entry"));
return;
}
instantClose();
pasteTimer.start();
});
}
function updateFilteredModel() {
const query = searchText.trim();

View File

@@ -114,11 +114,21 @@ QtObject {
}
}
if (event.modifiers & Qt.ShiftModifier && event.key === Qt.Key_Delete) {
modal.clearAll();
modal.hide();
event.accepted = true;
return;
if (event.modifiers & Qt.ShiftModifier) {
switch (event.key) {
case Qt.Key_Delete:
modal.clearAll();
modal.hide();
event.accepted = true;
return;
case Qt.Key_Return:
case Qt.Key_Enter:
if (modal.keyboardNavigationActive) {
modal.pasteSelected();
event.accepted = true;
}
return;
}
}
if (modal.keyboardNavigationActive) {

View File

@@ -5,7 +5,8 @@ import qs.Widgets
Rectangle {
id: keyboardHints
readonly property string hintsText: I18n.tr("Shift+Del: Clear All • Esc: Close")
property bool wtypeAvailable: false
readonly property string hintsText: wtypeAvailable ? I18n.tr("Shift+Enter: Paste • Shift+Del: Clear All • Esc: Close") : I18n.tr("Shift+Del: Clear All • Esc: Close")
height: ClipboardConstants.keyboardHintsHeight
radius: Theme.cornerRadius