mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-02 02:22:06 -04:00
clipboard: add keybind to switch tabs and toggle pinned (#2262)
* clipboard: add keybind to switch tabs * clipboard: add bind to toggle pinned
This commit is contained in:
@@ -53,6 +53,19 @@ QtObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function togglePinSelected() {
|
||||||
|
const entries = modal.activeTab === "saved" ? ClipboardService.pinnedEntries : ClipboardService.unpinnedEntries;
|
||||||
|
if (!entries || entries.length === 0 || ClipboardService.selectedIndex < 0 || ClipboardService.selectedIndex >= entries.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const selectedEntry = entries[ClipboardService.selectedIndex];
|
||||||
|
if (modal.activeTab === "saved") {
|
||||||
|
modal.unpinEntry(selectedEntry);
|
||||||
|
} else {
|
||||||
|
modal.pinEntry(selectedEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleKey(event) {
|
function handleKey(event) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Escape:
|
case Qt.Key_Escape:
|
||||||
@@ -65,6 +78,12 @@ QtObject {
|
|||||||
return;
|
return;
|
||||||
case Qt.Key_Down:
|
case Qt.Key_Down:
|
||||||
case Qt.Key_Tab:
|
case Qt.Key_Tab:
|
||||||
|
if (event.key === Qt.Key_Tab && (event.modifiers & Qt.ControlModifier)) {
|
||||||
|
modal.activeTab = modal.activeTab === "saved" ? "recents" : "saved";
|
||||||
|
ClipboardService.selectedIndex = 0;
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!ClipboardService.keyboardNavigationActive) {
|
if (!ClipboardService.keyboardNavigationActive) {
|
||||||
ClipboardService.keyboardNavigationActive = true;
|
ClipboardService.keyboardNavigationActive = true;
|
||||||
ClipboardService.selectedIndex = 0;
|
ClipboardService.selectedIndex = 0;
|
||||||
@@ -75,6 +94,12 @@ QtObject {
|
|||||||
return;
|
return;
|
||||||
case Qt.Key_Up:
|
case Qt.Key_Up:
|
||||||
case Qt.Key_Backtab:
|
case Qt.Key_Backtab:
|
||||||
|
if (event.key === Qt.Key_Backtab && (event.modifiers & Qt.ControlModifier)) {
|
||||||
|
modal.activeTab = modal.activeTab === "saved" ? "recents" : "saved";
|
||||||
|
ClipboardService.selectedIndex = 0;
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!ClipboardService.keyboardNavigationActive) {
|
if (!ClipboardService.keyboardNavigationActive) {
|
||||||
ClipboardService.keyboardNavigationActive = true;
|
ClipboardService.keyboardNavigationActive = true;
|
||||||
ClipboardService.selectedIndex = 0;
|
ClipboardService.selectedIndex = 0;
|
||||||
@@ -121,6 +146,12 @@ QtObject {
|
|||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
case Qt.Key_S:
|
||||||
|
if (ClipboardService.keyboardNavigationActive) {
|
||||||
|
togglePinSelected();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ Rectangle {
|
|||||||
property bool enterToPaste: false
|
property bool enterToPaste: false
|
||||||
readonly property string hintsText: {
|
readonly property string hintsText: {
|
||||||
if (!wtypeAvailable)
|
if (!wtypeAvailable)
|
||||||
return I18n.tr("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("Shift+Enter: Copy • Shift+Del: Clear All • Esc: Close", "Keyboard hints when enter-to-paste is enabled") : I18n.tr("Shift+Enter: Paste • 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
height: ClipboardConstants.keyboardHintsHeight
|
height: ClipboardConstants.keyboardHintsHeight
|
||||||
|
|||||||
Reference in New Issue
Block a user