1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-07 19:59:14 -04:00

Add clipboard editor shortcuts and hints

This commit is contained in:
Nachum Barcohen
2026-03-01 01:36:29 +02:00
committed by purian23
parent 584d57a8de
commit 8abdff3220
3 changed files with 62 additions and 6 deletions
@@ -169,8 +169,37 @@ DankModal {
borderColor: Theme.outlineMedium
borderWidth: 1
enableShadow: true
closeOnEscapeKey: mode !== "editor"
onBackgroundClicked: hide()
modalFocusScope.Keys.onPressed: function (event) {
if (mode === "history" && (event.modifiers & Qt.ControlModifier) && (event.key === Qt.Key_Tab || event.key === Qt.Key_Backtab)) {
activeTab = activeTab === "recents" ? "saved" : "recents";
event.accepted = true;
return;
}
if (mode === "history" && (event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_S) {
const entries = activeTab === "saved" ? pinnedEntries : unpinnedEntries;
if (entries && entries.length > 0) {
const index = ClipboardService.selectedIndex >= 0 && ClipboardService.selectedIndex < entries.length ? ClipboardService.selectedIndex : 0;
const entry = entries[index];
if (activeTab === "saved") {
unpinEntry(entry);
} else {
pinEntry(entry);
}
}
event.accepted = true;
return;
}
if (mode === "history" && (event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_E) {
const entries = activeTab === "saved" ? pinnedEntries : unpinnedEntries;
if (entries && entries.length > 0) {
const index = ClipboardService.selectedIndex >= 0 && ClipboardService.selectedIndex < entries.length ? ClipboardService.selectedIndex : 0;
editEntry(entries[index]);
}
event.accepted = true;
return;
}
keyboardController.handleKey(event);
}
content: clipboardContent
@@ -238,6 +267,13 @@ DankModal {
scale: 0.98
visible: opacity > 0.01
enabled: clipboardHistoryModal.mode === "editor"
focus: clipboardHistoryModal.mode === "editor"
Shortcut {
sequences: ["Escape"]
enabled: clipboardHistoryModal.mode === "editor"
onActivated: clipboardHistoryModal.mode = "history"
}
property var entry: null
property string editorText: ""
@@ -378,9 +414,20 @@ DankModal {
selectByMouse: true
Keys.forwardTo: [clipboardHistoryModal.modalFocusScope]
onTextChanged: editorView.editorText = text
Keys.onEscapePressed: function (event) {
clipboardHistoryModal.mode = "history";
event.accepted = true;
Keys.onPressed: function (event) {
const hasCtrl = (event.modifiers & Qt.ControlModifier) !== 0;
const hasShift = (event.modifiers & Qt.ShiftModifier) !== 0;
if (hasCtrl && event.key === Qt.Key_S) {
editorView.saveEntry(hasShift ? "close" : "history");
event.accepted = true;
return;
}
if (hasCtrl && hasShift && event.key === Qt.Key_V) {
editorView.saveEntry("paste");
event.accepted = true;
return;
}
}
}
@@ -69,7 +69,9 @@ QtObject {
function handleKey(event) {
switch (event.key) {
case Qt.Key_Escape:
if (ClipboardService.keyboardNavigationActive) {
if (modal.mode === "editor") {
modal.mode = "history";
} else if (ClipboardService.keyboardNavigationActive) {
ClipboardService.keyboardNavigationActive = false;
} else {
modal.hide();
@@ -10,7 +10,7 @@ Rectangle {
readonly property string hintsText: {
if (!wtypeAvailable)
return I18n.tr("Ctrl+Tab: Switch Tab • Ctrl+S: Pin/Unpin • Shift+Del: Clear All • Esc: Close");
return enterToPaste ? I18n.tr("Ctrl+Tab: Switch Tab • Ctrl+S: Pin/Unpin • Shift+Enter: Copy • Shift+Del: Clear All • Esc: Close", "Keyboard hints when enter-to-paste is enabled") : I18n.tr("Ctrl+Tab: Switch Tab • Ctrl+S: Pin/Unpin • Shift+Enter: Paste • Shift+Del: Clear All • Esc: Close");
return enterToPaste ? I18n.tr("Ctrl+Tab: Switch Tabs • Ctrl+S: Pin/Unpin • Shift+Enter: Copy • Shift+Del: Clear All • F10: Help • Esc: Close", "Keyboard hints when enter-to-paste is enabled") : I18n.tr("Ctrl+Tab: Switch Tabs • Ctrl+S: Pin/Unpin • Shift+Enter: Paste • Shift+Del: Clear All • F10: Help • Esc: Close");
}
height: ClipboardConstants.keyboardHintsHeight
@@ -22,13 +22,17 @@ Rectangle {
z: 100
Column {
width: parent.width - Theme.spacingL * 2
anchors.centerIn: parent
spacing: 2
StyledText {
text: keyboardHints.enterToPaste ? I18n.tr("↑/↓: Navigate • Enter: Paste • Del: Delete • F10: Help", "Keyboard hints when enter-to-paste is enabled") : I18n.tr("↑/↓: Navigate • Enter/Ctrl+C: Copy • Del: Delete • F10: Help")
text: keyboardHints.enterToPaste ? I18n.tr("↑/↓: Navigate • Enter: Paste • Ctrl+C: Copy • Del: Delete • Ctrl+E: Edit • Ctrl+S: Pin/Unpin • F10: Help", "Keyboard hints when enter-to-paste is enabled") : I18n.tr("↑/↓: Navigate • Enter/Ctrl+C: Copy • Del: Delete • Ctrl+E: Edit • Ctrl+S: Pin/Unpin • F10: Help")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
width: parent.width
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
}
@@ -36,6 +40,9 @@ Rectangle {
text: keyboardHints.hintsText
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
width: parent.width
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
}
}