mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-04 04:28:30 -04:00
@@ -192,23 +192,42 @@ function formatToken(mods, key) {
|
||||
return (mods.length ? mods.join("+") + "+" : "") + key;
|
||||
}
|
||||
|
||||
function normalizeKeyCombo(keyCombo) {
|
||||
if (!keyCombo)
|
||||
return "";
|
||||
return keyCombo.toLowerCase().replace(/\bmod\b/g, "super").replace(/\bsuper\b/g, "super");
|
||||
function canonicalModifier(modifier) {
|
||||
var normalized = (modifier || "").toLowerCase();
|
||||
if (normalized === "control")
|
||||
return "ctrl";
|
||||
if (normalized === "win")
|
||||
return "super";
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function getConflictingBinds(keyCombo, currentAction, allBinds) {
|
||||
function withSymbolicMod(mods, modKey) {
|
||||
var configuredMod = canonicalModifier(modKey);
|
||||
if (!configuredMod)
|
||||
return mods;
|
||||
return mods.map(function (modifier) {
|
||||
return canonicalModifier(modifier) === configuredMod ? "Mod" : modifier;
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeKeyCombo(keyCombo, modKey) {
|
||||
if (!keyCombo)
|
||||
return "";
|
||||
var configuredMod = canonicalModifier(modKey) || "super";
|
||||
return keyCombo.toLowerCase().replace(/\bmod\b/g, configuredMod).replace(/\bcontrol\b/g, "ctrl").replace(/\bwin\b/g, "super");
|
||||
}
|
||||
|
||||
function getConflictingBinds(keyCombo, currentAction, allBinds, modKey) {
|
||||
if (!keyCombo)
|
||||
return [];
|
||||
var conflicts = [];
|
||||
var normalizedKey = normalizeKeyCombo(keyCombo);
|
||||
var normalizedKey = normalizeKeyCombo(keyCombo, modKey);
|
||||
for (var i = 0; i < allBinds.length; i++) {
|
||||
var bind = allBinds[i];
|
||||
if (bind.action === currentAction)
|
||||
continue;
|
||||
for (var k = 0; k < bind.keys.length; k++) {
|
||||
if (normalizeKeyCombo(bind.keys[k].key) === normalizedKey) {
|
||||
if (normalizeKeyCombo(bind.keys[k].key, modKey) === normalizedKey) {
|
||||
conflicts.push({
|
||||
action: bind.action,
|
||||
desc: bind.desc || bind.action
|
||||
|
||||
@@ -42,6 +42,7 @@ Singleton {
|
||||
property bool saving: false
|
||||
property bool fixing: false
|
||||
property string lastError: ""
|
||||
property string modKey: "Super"
|
||||
property bool dmsBindsIncluded: true
|
||||
|
||||
property var dmsStatus: ({
|
||||
@@ -348,6 +349,7 @@ Singleton {
|
||||
|
||||
function _processData() {
|
||||
keybinds = _rawData || {};
|
||||
modKey = currentProvider === "niri" ? (_rawData?.modKey || "Super") : "Super";
|
||||
dmsBindsIncluded = _rawData?.dmsBindsIncluded ?? true;
|
||||
const status = _rawData?.dmsStatus;
|
||||
if (status) {
|
||||
|
||||
@@ -56,7 +56,7 @@ Item {
|
||||
readonly property bool hasConfigConflict: configConflict !== null
|
||||
readonly property string _originalKey: editingKeyIndex >= 0 && editingKeyIndex < keys.length ? keys[editingKeyIndex].key : ""
|
||||
readonly property string _selectedDesc: editingKeyIndex >= 0 && editingKeyIndex < keys.length ? (keys[editingKeyIndex].desc || bindData.desc || "") : (bindData.desc || "")
|
||||
readonly property var _conflicts: editKey ? KeyUtils.getConflictingBinds(editKey, bindData.action, KeybindsService.getFlatBinds()) : []
|
||||
readonly property var _conflicts: editKey ? KeyUtils.getConflictingBinds(editKey, bindData.action, KeybindsService.getFlatBinds(), KeybindsService.currentProvider === "niri" ? KeybindsService.modKey : "Super") : []
|
||||
readonly property bool hasConflict: _conflicts.length > 0
|
||||
|
||||
readonly property real _inputHeight: Math.round(Theme.fontSizeMedium * 3)
|
||||
@@ -725,6 +725,8 @@ Item {
|
||||
if (!mods.includes("Shift"))
|
||||
mods.push("Shift");
|
||||
}
|
||||
if (KeybindsService.currentProvider === "niri")
|
||||
mods = KeyUtils.withSymbolicMod(mods, KeybindsService.modKey);
|
||||
|
||||
const key = KeyUtils.xkbKeyFromQtKey(qtKey, !!(event.modifiers & Qt.KeypadModifier));
|
||||
if (!key) {
|
||||
@@ -756,7 +758,7 @@ Item {
|
||||
}
|
||||
wheel.accepted = true;
|
||||
|
||||
const mods = [];
|
||||
let mods = [];
|
||||
if (wheel.modifiers & Qt.ControlModifier)
|
||||
mods.push("Ctrl");
|
||||
if (wheel.modifiers & Qt.ShiftModifier)
|
||||
@@ -765,6 +767,8 @@ Item {
|
||||
mods.push("Alt");
|
||||
if (wheel.modifiers & Qt.MetaModifier)
|
||||
mods.push("Super");
|
||||
if (KeybindsService.currentProvider === "niri")
|
||||
mods = KeyUtils.withSymbolicMod(mods, KeybindsService.modKey);
|
||||
|
||||
let wheelKey = "";
|
||||
if (wheel.angleDelta.y > 0)
|
||||
|
||||
Reference in New Issue
Block a user