mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-12 00:32:17 -04:00
clipboard: add popout variant
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import qs.Services
|
||||
|
||||
QtObject {
|
||||
id: keyboardController
|
||||
@@ -6,48 +7,48 @@ QtObject {
|
||||
required property var modal
|
||||
|
||||
function reset() {
|
||||
modal.selectedIndex = 0;
|
||||
modal.keyboardNavigationActive = false;
|
||||
ClipboardService.selectedIndex = 0;
|
||||
ClipboardService.keyboardNavigationActive = false;
|
||||
modal.showKeyboardHints = false;
|
||||
}
|
||||
|
||||
function selectNext() {
|
||||
if (!modal.clipboardEntries || modal.clipboardEntries.length === 0) {
|
||||
if (!ClipboardService.clipboardEntries || ClipboardService.clipboardEntries.length === 0) {
|
||||
return;
|
||||
}
|
||||
modal.keyboardNavigationActive = true;
|
||||
modal.selectedIndex = Math.min(modal.selectedIndex + 1, modal.clipboardEntries.length - 1);
|
||||
ClipboardService.keyboardNavigationActive = true;
|
||||
ClipboardService.selectedIndex = Math.min(ClipboardService.selectedIndex + 1, ClipboardService.clipboardEntries.length - 1);
|
||||
}
|
||||
|
||||
function selectPrevious() {
|
||||
if (!modal.clipboardEntries || modal.clipboardEntries.length === 0) {
|
||||
if (!ClipboardService.clipboardEntries || ClipboardService.clipboardEntries.length === 0) {
|
||||
return;
|
||||
}
|
||||
modal.keyboardNavigationActive = true;
|
||||
modal.selectedIndex = Math.max(modal.selectedIndex - 1, 0);
|
||||
ClipboardService.keyboardNavigationActive = true;
|
||||
ClipboardService.selectedIndex = Math.max(ClipboardService.selectedIndex - 1, 0);
|
||||
}
|
||||
|
||||
function copySelected() {
|
||||
if (!modal.clipboardEntries || modal.clipboardEntries.length === 0 || modal.selectedIndex < 0 || modal.selectedIndex >= modal.clipboardEntries.length) {
|
||||
if (!ClipboardService.clipboardEntries || ClipboardService.clipboardEntries.length === 0 || ClipboardService.selectedIndex < 0 || ClipboardService.selectedIndex >= ClipboardService.clipboardEntries.length) {
|
||||
return;
|
||||
}
|
||||
const selectedEntry = modal.clipboardEntries[modal.selectedIndex];
|
||||
const selectedEntry = ClipboardService.clipboardEntries[ClipboardService.selectedIndex];
|
||||
modal.copyEntry(selectedEntry);
|
||||
}
|
||||
|
||||
function deleteSelected() {
|
||||
if (!modal.clipboardEntries || modal.clipboardEntries.length === 0 || modal.selectedIndex < 0 || modal.selectedIndex >= modal.clipboardEntries.length) {
|
||||
if (!ClipboardService.clipboardEntries || ClipboardService.clipboardEntries.length === 0 || ClipboardService.selectedIndex < 0 || ClipboardService.selectedIndex >= ClipboardService.clipboardEntries.length) {
|
||||
return;
|
||||
}
|
||||
const selectedEntry = modal.clipboardEntries[modal.selectedIndex];
|
||||
const selectedEntry = ClipboardService.clipboardEntries[ClipboardService.selectedIndex];
|
||||
modal.deleteEntry(selectedEntry);
|
||||
}
|
||||
|
||||
function handleKey(event) {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Escape:
|
||||
if (modal.keyboardNavigationActive) {
|
||||
modal.keyboardNavigationActive = false;
|
||||
if (ClipboardService.keyboardNavigationActive) {
|
||||
ClipboardService.keyboardNavigationActive = false;
|
||||
} else {
|
||||
modal.hide();
|
||||
}
|
||||
@@ -55,9 +56,9 @@ QtObject {
|
||||
return;
|
||||
case Qt.Key_Down:
|
||||
case Qt.Key_Tab:
|
||||
if (!modal.keyboardNavigationActive) {
|
||||
modal.keyboardNavigationActive = true;
|
||||
modal.selectedIndex = 0;
|
||||
if (!ClipboardService.keyboardNavigationActive) {
|
||||
ClipboardService.keyboardNavigationActive = true;
|
||||
ClipboardService.selectedIndex = 0;
|
||||
} else {
|
||||
selectNext();
|
||||
}
|
||||
@@ -65,11 +66,11 @@ QtObject {
|
||||
return;
|
||||
case Qt.Key_Up:
|
||||
case Qt.Key_Backtab:
|
||||
if (!modal.keyboardNavigationActive) {
|
||||
modal.keyboardNavigationActive = true;
|
||||
modal.selectedIndex = 0;
|
||||
} else if (modal.selectedIndex === 0) {
|
||||
modal.keyboardNavigationActive = false;
|
||||
if (!ClipboardService.keyboardNavigationActive) {
|
||||
ClipboardService.keyboardNavigationActive = true;
|
||||
ClipboardService.selectedIndex = 0;
|
||||
} else if (ClipboardService.selectedIndex === 0) {
|
||||
ClipboardService.keyboardNavigationActive = false;
|
||||
} else {
|
||||
selectPrevious();
|
||||
}
|
||||
@@ -85,9 +86,9 @@ QtObject {
|
||||
switch (event.key) {
|
||||
case Qt.Key_N:
|
||||
case Qt.Key_J:
|
||||
if (!modal.keyboardNavigationActive) {
|
||||
modal.keyboardNavigationActive = true;
|
||||
modal.selectedIndex = 0;
|
||||
if (!ClipboardService.keyboardNavigationActive) {
|
||||
ClipboardService.keyboardNavigationActive = true;
|
||||
ClipboardService.selectedIndex = 0;
|
||||
} else {
|
||||
selectNext();
|
||||
}
|
||||
@@ -95,18 +96,18 @@ QtObject {
|
||||
return;
|
||||
case Qt.Key_P:
|
||||
case Qt.Key_K:
|
||||
if (!modal.keyboardNavigationActive) {
|
||||
modal.keyboardNavigationActive = true;
|
||||
modal.selectedIndex = 0;
|
||||
} else if (modal.selectedIndex === 0) {
|
||||
modal.keyboardNavigationActive = false;
|
||||
if (!ClipboardService.keyboardNavigationActive) {
|
||||
ClipboardService.keyboardNavigationActive = true;
|
||||
ClipboardService.selectedIndex = 0;
|
||||
} else if (ClipboardService.selectedIndex === 0) {
|
||||
ClipboardService.keyboardNavigationActive = false;
|
||||
} else {
|
||||
selectPrevious();
|
||||
}
|
||||
event.accepted = true;
|
||||
return;
|
||||
case Qt.Key_C:
|
||||
if (modal.keyboardNavigationActive) {
|
||||
if (ClipboardService.keyboardNavigationActive) {
|
||||
copySelected();
|
||||
event.accepted = true;
|
||||
}
|
||||
@@ -123,7 +124,7 @@ QtObject {
|
||||
return;
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Enter:
|
||||
if (modal.keyboardNavigationActive) {
|
||||
if (ClipboardService.keyboardNavigationActive) {
|
||||
modal.pasteSelected();
|
||||
event.accepted = true;
|
||||
}
|
||||
@@ -131,7 +132,7 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
if (modal.keyboardNavigationActive) {
|
||||
if (ClipboardService.keyboardNavigationActive) {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Enter:
|
||||
|
||||
Reference in New Issue
Block a user