mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-08 04:09:15 -04:00
Add clipboard editor shortcuts and hints
This commit is contained in:
committed by
purian23
parent
584d57a8de
commit
8abdff3220
@@ -169,8 +169,37 @@ DankModal {
|
|||||||
borderColor: Theme.outlineMedium
|
borderColor: Theme.outlineMedium
|
||||||
borderWidth: 1
|
borderWidth: 1
|
||||||
enableShadow: true
|
enableShadow: true
|
||||||
|
closeOnEscapeKey: mode !== "editor"
|
||||||
onBackgroundClicked: hide()
|
onBackgroundClicked: hide()
|
||||||
modalFocusScope.Keys.onPressed: function (event) {
|
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);
|
keyboardController.handleKey(event);
|
||||||
}
|
}
|
||||||
content: clipboardContent
|
content: clipboardContent
|
||||||
@@ -238,6 +267,13 @@ DankModal {
|
|||||||
scale: 0.98
|
scale: 0.98
|
||||||
visible: opacity > 0.01
|
visible: opacity > 0.01
|
||||||
enabled: clipboardHistoryModal.mode === "editor"
|
enabled: clipboardHistoryModal.mode === "editor"
|
||||||
|
focus: clipboardHistoryModal.mode === "editor"
|
||||||
|
|
||||||
|
Shortcut {
|
||||||
|
sequences: ["Escape"]
|
||||||
|
enabled: clipboardHistoryModal.mode === "editor"
|
||||||
|
onActivated: clipboardHistoryModal.mode = "history"
|
||||||
|
}
|
||||||
|
|
||||||
property var entry: null
|
property var entry: null
|
||||||
property string editorText: ""
|
property string editorText: ""
|
||||||
@@ -378,9 +414,20 @@ DankModal {
|
|||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
Keys.forwardTo: [clipboardHistoryModal.modalFocusScope]
|
Keys.forwardTo: [clipboardHistoryModal.modalFocusScope]
|
||||||
onTextChanged: editorView.editorText = text
|
onTextChanged: editorView.editorText = text
|
||||||
Keys.onEscapePressed: function (event) {
|
Keys.onPressed: function (event) {
|
||||||
clipboardHistoryModal.mode = "history";
|
const hasCtrl = (event.modifiers & Qt.ControlModifier) !== 0;
|
||||||
event.accepted = true;
|
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) {
|
function handleKey(event) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Escape:
|
case Qt.Key_Escape:
|
||||||
if (ClipboardService.keyboardNavigationActive) {
|
if (modal.mode === "editor") {
|
||||||
|
modal.mode = "history";
|
||||||
|
} else if (ClipboardService.keyboardNavigationActive) {
|
||||||
ClipboardService.keyboardNavigationActive = false;
|
ClipboardService.keyboardNavigationActive = false;
|
||||||
} else {
|
} else {
|
||||||
modal.hide();
|
modal.hide();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Rectangle {
|
|||||||
readonly property string hintsText: {
|
readonly property string hintsText: {
|
||||||
if (!wtypeAvailable)
|
if (!wtypeAvailable)
|
||||||
return I18n.tr("Ctrl+Tab: Switch Tab • Ctrl+S: Pin/Unpin • Shift+Del: Clear All • Esc: Close");
|
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
|
height: ClipboardConstants.keyboardHintsHeight
|
||||||
@@ -22,13 +22,17 @@ Rectangle {
|
|||||||
z: 100
|
z: 100
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
width: parent.width - Theme.spacingL * 2
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
||||||
StyledText {
|
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
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
|
width: parent.width
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +40,9 @@ Rectangle {
|
|||||||
text: keyboardHints.hintsText
|
text: keyboardHints.hintsText
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
|
width: parent.width
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user