diff --git a/quickshell/Modals/Clipboard/ClipboardHistoryModal.qml b/quickshell/Modals/Clipboard/ClipboardHistoryModal.qml index f8535d4f..ae509ac6 100644 --- a/quickshell/Modals/Clipboard/ClipboardHistoryModal.qml +++ b/quickshell/Modals/Clipboard/ClipboardHistoryModal.qml @@ -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; + } } } diff --git a/quickshell/Modals/Clipboard/ClipboardKeyboardController.qml b/quickshell/Modals/Clipboard/ClipboardKeyboardController.qml index 699f0dec..c7fd0004 100644 --- a/quickshell/Modals/Clipboard/ClipboardKeyboardController.qml +++ b/quickshell/Modals/Clipboard/ClipboardKeyboardController.qml @@ -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(); diff --git a/quickshell/Modals/Clipboard/ClipboardKeyboardHints.qml b/quickshell/Modals/Clipboard/ClipboardKeyboardHints.qml index c9891eb7..a637d1e6 100644 --- a/quickshell/Modals/Clipboard/ClipboardKeyboardHints.qml +++ b/quickshell/Modals/Clipboard/ClipboardKeyboardHints.qml @@ -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 } }