mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
NotificationHistoryPanel: add keybind controls
This commit is contained in:
@@ -1047,6 +1047,9 @@
|
||||
"keybinds-enter": "Confirm / Action",
|
||||
"keybinds-escape": "Close / Back",
|
||||
"keybinds-left": "Move left",
|
||||
"keybinds-modifier-description": "Shortcuts must include a modifier key (Ctrl or Alt).",
|
||||
"keybinds-modifier-title": "Modifier required",
|
||||
"keybinds-remove": "Remove/Delete",
|
||||
"keybinds-right": "Move right",
|
||||
"keybinds-title": "Navigation keybinds",
|
||||
"keybinds-up": "Move up",
|
||||
@@ -1951,4 +1954,4 @@
|
||||
"poor": "Poor"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,6 +119,9 @@
|
||||
],
|
||||
"keyEscape": [
|
||||
"Esc"
|
||||
],
|
||||
"keyRemove": [
|
||||
"Del"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -297,6 +297,7 @@ Singleton {
|
||||
property list<string> keyRight: ["Right"]
|
||||
property list<string> keyEnter: ["Return"]
|
||||
property list<string> keyEscape: ["Esc"]
|
||||
property list<string> keyRemove: ["Del"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ function getKeybindString(event) {
|
||||
keyName = String.fromCharCode(event.key);
|
||||
} else if (event.key >= Qt.Key_F1 && event.key <= Qt.Key_F12) {
|
||||
keyName = "F" + (event.key - Qt.Key_F1 + 1);
|
||||
} else if (rawText && rawText.length > 0 && rawText.charCodeAt(0) > 31) {
|
||||
} else if (rawText && rawText.length > 0 && rawText.charCodeAt(0) > 31 && rawText.charCodeAt(0) !== 127) {
|
||||
keyName = rawText.toUpperCase();
|
||||
|
||||
if (event.modifiers & Qt.ShiftModifier) {
|
||||
|
||||
@@ -69,4 +69,13 @@ ColumnLayout {
|
||||
settingsPath: "general.keybinds.keyEscape"
|
||||
onKeybindsChanged: newKeybinds => Settings.data.general.keybinds.keyEscape = newKeybinds
|
||||
}
|
||||
|
||||
NKeybindRecorder {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.general.keybinds-remove")
|
||||
currentKeybinds: Settings.data.general.keybinds.keyRemove
|
||||
defaultKeybind: "Del"
|
||||
settingsPath: "general.keybinds.keyRemove"
|
||||
onKeybindsChanged: newKeybinds => Settings.data.general.keybinds.keyRemove = newKeybinds
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ Item {
|
||||
keyName = String.fromCharCode(event.key);
|
||||
} else if (event.key >= Qt.Key_F1 && event.key <= Qt.Key_F12) {
|
||||
keyName = "F" + (event.key - Qt.Key_F1 + 1);
|
||||
} else if (rawText && rawText.length > 0 && rawText.charCodeAt(0) > 31) {
|
||||
} else if (rawText && rawText.length > 0 && rawText.charCodeAt(0) > 31 && rawText.charCodeAt(0) !== 127) {
|
||||
keyName = rawText.toUpperCase();
|
||||
|
||||
// Handle shifted digits
|
||||
@@ -308,6 +308,23 @@ Item {
|
||||
}
|
||||
|
||||
if (keyName) {
|
||||
// Enforce modifier requirement (Ctrl or Alt) for "normal" keys
|
||||
// Allow Arrows, Nav, Function, and System keys without modifiers
|
||||
const isSpecialKey = (event.key >= Qt.Key_F1 && event.key <= Qt.Key_F35) || (event.key >= Qt.Key_Left && event.key <= Qt.Key_Down) || (event.key === Qt.Key_Home || event.key === Qt.Key_End || event.key === Qt.Key_PageUp || event.key === Qt.Key_PageDown) || (event.key === Qt.Key_Insert || event.key === Qt.Key_Delete || event.key
|
||||
=== Qt.Key_Backspace) || (event.key === Qt.Key_Tab || event.key
|
||||
=== Qt.Key_Return || event.key === Qt.Key_Enter
|
||||
|| event.key === Qt.Key_Escape || event.key
|
||||
=== Qt.Key_Space);
|
||||
|
||||
const hasModifier = (event.modifiers & Qt.ControlModifier) || (event.modifiers & Qt.AltModifier);
|
||||
|
||||
if (!hasModifier && !isSpecialKey) {
|
||||
hasConflict = true;
|
||||
ToastService.showWarning(I18n.tr("panels.general.keybinds-modifier-title"), I18n.tr("panels.general.keybinds-modifier-description"));
|
||||
conflictTimer.restart();
|
||||
return;
|
||||
}
|
||||
|
||||
root._applyKeybind(keyStr + keyName);
|
||||
}
|
||||
event.accepted = true;
|
||||
|
||||
Reference in New Issue
Block a user