mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-26 14:32:52 -05:00
keybinds: fix empty string args, more writable provider options
This commit is contained in:
@@ -46,7 +46,9 @@ const KEY_MAP = {
|
||||
16777349: "XF86AudioMedia",
|
||||
16777350: "XF86AudioRecord",
|
||||
16842798: "XF86MonBrightnessUp",
|
||||
16777394: "XF86MonBrightnessUp",
|
||||
16842797: "XF86MonBrightnessDown",
|
||||
16777395: "XF86MonBrightnessDown",
|
||||
16842800: "XF86KbdBrightnessUp",
|
||||
16842799: "XF86KbdBrightnessDown",
|
||||
16842796: "XF86PowerOff",
|
||||
|
||||
@@ -75,6 +75,7 @@ Singleton {
|
||||
property var _flatCache: []
|
||||
property var displayList: []
|
||||
property int _dataVersion: 0
|
||||
property string _pendingSavedKey: ""
|
||||
|
||||
readonly property var categoryOrder: Actions.getCategoryOrder()
|
||||
readonly property string configDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation))
|
||||
@@ -278,7 +279,7 @@ Singleton {
|
||||
script = `mkdir -p "${compositorConfigDir}/dms" && touch "${compositorConfigDir}/dms/binds.kdl" && cp "${mainConfigPath}" "${backupPath}" && echo 'include "dms/binds.kdl"' >> "${mainConfigPath}"`;
|
||||
break;
|
||||
case "hyprland":
|
||||
script = `mkdir -p "${compositorConfigDir}/dms" && touch "${compositorConfigDir}/dms/binds.conf" && cp "${mainConfigPath}" "${backupPath}" && echo 'source = dms/binds.conf' >> "${mainConfigPath}"`;
|
||||
script = `mkdir -p "${compositorConfigDir}/dms" && touch "${compositorConfigDir}/dms/binds.conf" && cp "${mainConfigPath}" "${backupPath}" && echo 'source = ./dms/binds.conf' >> "${mainConfigPath}"`;
|
||||
break;
|
||||
case "mangowc":
|
||||
script = `mkdir -p "${compositorConfigDir}/dms" && touch "${compositorConfigDir}/dms/binds.conf" && cp "${mainConfigPath}" "${backupPath}" && echo 'source = ./dms/binds.conf' >> "${mainConfigPath}"`;
|
||||
@@ -342,6 +343,10 @@ Singleton {
|
||||
displayList = [];
|
||||
_dataVersion++;
|
||||
bindsLoaded();
|
||||
if (_pendingSavedKey) {
|
||||
bindSaved(_pendingSavedKey);
|
||||
_pendingSavedKey = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -378,7 +383,8 @@ Singleton {
|
||||
"key": bind.key || "",
|
||||
"source": bind.source || "config",
|
||||
"isOverride": bind.source === "dms",
|
||||
"cooldownMs": bind.cooldownMs || 0
|
||||
"cooldownMs": bind.cooldownMs || 0,
|
||||
"flags": bind.flags || ""
|
||||
};
|
||||
if (actionMap[action]) {
|
||||
actionMap[action].keys.push(keyData);
|
||||
@@ -425,6 +431,10 @@ Singleton {
|
||||
displayList = list;
|
||||
_dataVersion++;
|
||||
bindsLoaded();
|
||||
if (_pendingSavedKey) {
|
||||
bindSaved(_pendingSavedKey);
|
||||
_pendingSavedKey = "";
|
||||
}
|
||||
}
|
||||
|
||||
function getCategories() {
|
||||
@@ -444,9 +454,11 @@ Singleton {
|
||||
cmd.push("--replace-key", originalKey);
|
||||
if (bindData.cooldownMs > 0)
|
||||
cmd.push("--cooldown-ms", String(bindData.cooldownMs));
|
||||
if (bindData.flags)
|
||||
cmd.push("--flags", bindData.flags);
|
||||
saveProcess.command = cmd;
|
||||
saveProcess.running = true;
|
||||
bindSaved(bindData.key);
|
||||
_pendingSavedKey = bindData.key;
|
||||
}
|
||||
|
||||
function removeBind(key) {
|
||||
|
||||
@@ -24,7 +24,9 @@ Item {
|
||||
property string editAction: ""
|
||||
property string editDesc: ""
|
||||
property int editCooldownMs: 0
|
||||
property string editFlags: ""
|
||||
property int _savedCooldownMs: -1
|
||||
property string _savedFlags: ""
|
||||
property bool hasChanges: false
|
||||
property string _actionType: ""
|
||||
property bool addingNewKey: false
|
||||
@@ -104,6 +106,12 @@ Item {
|
||||
} else {
|
||||
editCooldownMs = keys[i].cooldownMs || 0;
|
||||
}
|
||||
if (_savedFlags) {
|
||||
editFlags = _savedFlags;
|
||||
_savedFlags = "";
|
||||
} else {
|
||||
editFlags = keys[i].flags || "";
|
||||
}
|
||||
hasChanges = false;
|
||||
_actionType = Actions.getActionType(editAction);
|
||||
useCustomCompositor = _actionType === "compositor" && editAction && !Actions.isKnownCompositorAction(KeybindsService.currentProvider, editAction);
|
||||
@@ -124,6 +132,7 @@ Item {
|
||||
editAction = bindData.action || "";
|
||||
editDesc = bindData.desc || "";
|
||||
editCooldownMs = editingKeyIndex >= 0 ? (keys[editingKeyIndex].cooldownMs || 0) : 0;
|
||||
editFlags = editingKeyIndex >= 0 ? (keys[editingKeyIndex].flags || "") : "";
|
||||
hasChanges = false;
|
||||
_actionType = Actions.getActionType(editAction);
|
||||
useCustomCompositor = _actionType === "compositor" && editAction && !Actions.isKnownCompositorAction(KeybindsService.currentProvider, editAction);
|
||||
@@ -143,6 +152,7 @@ Item {
|
||||
editingKeyIndex = index;
|
||||
editKey = keys[index].key;
|
||||
editCooldownMs = keys[index].cooldownMs || 0;
|
||||
editFlags = keys[index].flags || "";
|
||||
hasChanges = false;
|
||||
}
|
||||
|
||||
@@ -155,9 +165,12 @@ Item {
|
||||
editDesc = changes.desc;
|
||||
if (changes.cooldownMs !== undefined)
|
||||
editCooldownMs = changes.cooldownMs;
|
||||
if (changes.flags !== undefined)
|
||||
editFlags = changes.flags;
|
||||
const origKey = editingKeyIndex >= 0 && editingKeyIndex < keys.length ? keys[editingKeyIndex].key : "";
|
||||
const origCooldown = editingKeyIndex >= 0 && editingKeyIndex < keys.length ? (keys[editingKeyIndex].cooldownMs || 0) : 0;
|
||||
hasChanges = editKey !== origKey || editAction !== (bindData.action || "") || editDesc !== (bindData.desc || "") || editCooldownMs !== origCooldown;
|
||||
const origFlags = editingKeyIndex >= 0 && editingKeyIndex < keys.length ? (keys[editingKeyIndex].flags || "") : "";
|
||||
hasChanges = editKey !== origKey || editAction !== (bindData.action || "") || editDesc !== (bindData.desc || "") || editCooldownMs !== origCooldown || editFlags !== origFlags;
|
||||
}
|
||||
|
||||
function canSave() {
|
||||
@@ -176,11 +189,13 @@ Item {
|
||||
if (expandedLoader.item?.currentTitle !== undefined)
|
||||
desc = expandedLoader.item.currentTitle;
|
||||
_savedCooldownMs = editCooldownMs;
|
||||
_savedFlags = editFlags;
|
||||
saveBind(origKey, {
|
||||
"key": editKey,
|
||||
"action": editAction,
|
||||
"desc": desc,
|
||||
"cooldownMs": editCooldownMs
|
||||
"cooldownMs": editCooldownMs,
|
||||
"flags": editFlags
|
||||
});
|
||||
hasChanges = false;
|
||||
addingNewKey = false;
|
||||
@@ -1451,6 +1466,113 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: Theme.spacingM
|
||||
visible: KeybindsService.currentProvider === "hyprland"
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Flags")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceVariantText
|
||||
Layout.preferredWidth: root._labelWidth
|
||||
}
|
||||
|
||||
Flow {
|
||||
Layout.fillWidth: true
|
||||
spacing: Theme.spacingM
|
||||
|
||||
RowLayout {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankToggle {
|
||||
checked: root.editFlags.indexOf("e") !== -1
|
||||
onToggled: newChecked => {
|
||||
let flags = root.editFlags.split("").filter(f => f !== "e");
|
||||
if (newChecked)
|
||||
flags.push("e");
|
||||
root.updateEdit({
|
||||
"flags": flags.join("")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Repeat")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankToggle {
|
||||
checked: root.editFlags.indexOf("l") !== -1
|
||||
onToggled: newChecked => {
|
||||
let flags = root.editFlags.split("").filter(f => f !== "l");
|
||||
if (newChecked)
|
||||
flags.push("l");
|
||||
root.updateEdit({
|
||||
"flags": flags.join("")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Locked")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankToggle {
|
||||
checked: root.editFlags.indexOf("r") !== -1
|
||||
onToggled: newChecked => {
|
||||
let flags = root.editFlags.split("").filter(f => f !== "r");
|
||||
if (newChecked)
|
||||
flags.push("r");
|
||||
root.updateEdit({
|
||||
"flags": flags.join("")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Release")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankToggle {
|
||||
checked: root.editFlags.indexOf("o") !== -1
|
||||
onToggled: newChecked => {
|
||||
let flags = root.editFlags.split("").filter(f => f !== "o");
|
||||
if (newChecked)
|
||||
flags.push("o");
|
||||
root.updateEdit({
|
||||
"flags": flags.join("")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Long press")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: Theme.spacingM
|
||||
|
||||
Reference in New Issue
Block a user