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:
5
CHANGELOG.MD
Normal file
5
CHANGELOG.MD
Normal 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
|
||||
@@ -158,5 +158,6 @@ Item {
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
visible: modal.showKeyboardHints
|
||||
wtypeAvailable: modal.wtypeAvailable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user