mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-07 19:59:14 -04:00
fix(keybinds): show percentage amount in titles & performance improvements
This commit is contained in:
@@ -770,6 +770,26 @@ const DMS_ACTION_ARGS = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const DMS_AMOUNT_LABELS = {
|
||||||
|
"audio increment": "Volume Up",
|
||||||
|
"audio decrement": "Volume Down",
|
||||||
|
"mpris increment": "Player Volume Up",
|
||||||
|
"mpris decrement": "Player Volume Down",
|
||||||
|
"brightness increment": "Brightness Up",
|
||||||
|
"brightness decrement": "Brightness Down"
|
||||||
|
};
|
||||||
|
|
||||||
|
function getDmsAmountLabel(action) {
|
||||||
|
var parsed = parseDmsActionArgs(action);
|
||||||
|
var label = DMS_AMOUNT_LABELS[parsed.base];
|
||||||
|
if (!label)
|
||||||
|
return null;
|
||||||
|
var amount = parsed.args?.amount;
|
||||||
|
if (amount === undefined || amount === null || amount === "")
|
||||||
|
return label;
|
||||||
|
return label + " (" + amount + "%)";
|
||||||
|
}
|
||||||
|
|
||||||
function getActionTypes() {
|
function getActionTypes() {
|
||||||
return ACTION_TYPES;
|
return ACTION_TYPES;
|
||||||
}
|
}
|
||||||
@@ -844,6 +864,10 @@ function getActionLabel(action, compositor) {
|
|||||||
if (!action)
|
if (!action)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
var amountLabel = getDmsAmountLabel(action);
|
||||||
|
if (amountLabel)
|
||||||
|
return amountLabel;
|
||||||
|
|
||||||
var dmsAct = findDmsAction(action);
|
var dmsAct = findDmsAction(action);
|
||||||
if (dmsAct)
|
if (dmsAct)
|
||||||
return dmsAct.label;
|
return dmsAct.label;
|
||||||
|
|||||||
@@ -71,15 +71,32 @@ Item {
|
|||||||
signal resetBind(string key)
|
signal resetBind(string key)
|
||||||
signal cancelEdit
|
signal cancelEdit
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
property bool _userToggledExpand: false
|
||||||
|
|
||||||
implicitHeight: contentColumn.implicitHeight
|
implicitHeight: contentColumn.implicitHeight
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
|
|
||||||
|
Behavior on implicitHeight {
|
||||||
|
enabled: root._userToggledExpand
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
onRunningChanged: {
|
||||||
|
if (!running)
|
||||||
|
root._userToggledExpand = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (isNew && isExpanded)
|
if (isNew && isExpanded)
|
||||||
resetEdits();
|
resetEdits();
|
||||||
}
|
}
|
||||||
|
|
||||||
onIsExpandedChanged: {
|
onIsExpandedChanged: {
|
||||||
|
_userToggledExpand = true;
|
||||||
if (!isExpanded)
|
if (!isExpanded)
|
||||||
return;
|
return;
|
||||||
if (restoreKey) {
|
if (restoreKey) {
|
||||||
@@ -431,7 +448,7 @@ Item {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
active: root.isExpanded
|
active: root.isExpanded
|
||||||
visible: status === Loader.Ready
|
visible: status === Loader.Ready
|
||||||
asynchronous: true
|
asynchronous: false
|
||||||
sourceComponent: expandedComponent
|
sourceComponent: expandedComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -957,7 +974,7 @@ Item {
|
|||||||
if (act.label === value) {
|
if (act.label === value) {
|
||||||
root.updateEdit({
|
root.updateEdit({
|
||||||
"action": act.id,
|
"action": act.id,
|
||||||
"desc": act.label
|
"desc": KeybindsService.getActionLabel(act.id)
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1012,11 +1029,16 @@ Item {
|
|||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
if (!dmsArgsRow.parsedArgs)
|
if (!dmsArgsRow.parsedArgs)
|
||||||
return;
|
return;
|
||||||
|
const oldAction = root.editAction;
|
||||||
const newArgs = Object.assign({}, dmsArgsRow.parsedArgs.args);
|
const newArgs = Object.assign({}, dmsArgsRow.parsedArgs.args);
|
||||||
newArgs.amount = text || "5";
|
newArgs.amount = text || "5";
|
||||||
root.updateEdit({
|
const newAction = Actions.buildDmsAction(dmsArgsRow.parsedArgs.base, newArgs);
|
||||||
"action": Actions.buildDmsAction(dmsArgsRow.parsedArgs.base, newArgs)
|
const changes = {
|
||||||
});
|
"action": newAction
|
||||||
|
};
|
||||||
|
if (root.editDesc === "" || root.editDesc === KeybindsService.getActionLabel(oldAction))
|
||||||
|
changes.desc = KeybindsService.getActionLabel(newAction);
|
||||||
|
root.updateEdit(changes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user