mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
power menu: shorter hold durations
This commit is contained in:
@@ -318,7 +318,7 @@ Singleton {
|
||||
property bool osdAudioOutputEnabled: true
|
||||
|
||||
property bool powerActionConfirm: true
|
||||
property int powerActionHoldDuration: 1
|
||||
property real powerActionHoldDuration: 0.5
|
||||
property var powerMenuActions: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"]
|
||||
property string powerMenuDefaultAction: "logout"
|
||||
property bool powerMenuGridLayout: false
|
||||
|
||||
@@ -217,7 +217,7 @@ var SPEC = {
|
||||
osdAudioOutputEnabled: { def: true },
|
||||
|
||||
powerActionConfirm: { def: true },
|
||||
powerActionHoldDuration: { def: 1 },
|
||||
powerActionHoldDuration: { def: 0.5 },
|
||||
powerMenuActions: { def: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] },
|
||||
powerMenuDefaultAction: { def: "logout" },
|
||||
powerMenuGridLayout: { def: false },
|
||||
|
||||
@@ -787,12 +787,18 @@ DankModal {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
readonly property int remainingSeconds: Math.ceil(SettingsData.powerActionHoldDuration * (1 - root.holdProgress))
|
||||
readonly property real totalMs: SettingsData.powerActionHoldDuration * 1000
|
||||
readonly property int remainingMs: Math.ceil(totalMs * (1 - root.holdProgress))
|
||||
text: {
|
||||
if (root.showHoldHint)
|
||||
return I18n.tr("Hold longer to confirm");
|
||||
if (root.holdProgress > 0)
|
||||
return I18n.tr("Hold to confirm (%1s)").arg(remainingSeconds);
|
||||
if (root.holdProgress > 0) {
|
||||
if (totalMs < 1000)
|
||||
return I18n.tr("Hold to confirm (%1 ms)").arg(remainingMs);
|
||||
return I18n.tr("Hold to confirm (%1s)").arg(Math.ceil(remainingMs / 1000));
|
||||
}
|
||||
if (totalMs < 1000)
|
||||
return I18n.tr("Hold to confirm (%1 ms)").arg(totalMs);
|
||||
return I18n.tr("Hold to confirm (%1s)").arg(SettingsData.powerActionHoldDuration);
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
|
||||
@@ -780,12 +780,18 @@ Rectangle {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
readonly property int remainingSeconds: Math.ceil(SettingsData.powerActionHoldDuration * (1 - root.holdProgress))
|
||||
readonly property real totalMs: SettingsData.powerActionHoldDuration * 1000
|
||||
readonly property int remainingMs: Math.ceil(totalMs * (1 - root.holdProgress))
|
||||
text: {
|
||||
if (root.showHoldHint)
|
||||
return I18n.tr("Hold longer to confirm");
|
||||
if (root.holdProgress > 0)
|
||||
return I18n.tr("Hold to confirm (%1s)").arg(remainingSeconds);
|
||||
if (root.holdProgress > 0) {
|
||||
if (totalMs < 1000)
|
||||
return I18n.tr("Hold to confirm (%1 ms)").arg(remainingMs);
|
||||
return I18n.tr("Hold to confirm (%1s)").arg(Math.ceil(remainingMs / 1000));
|
||||
}
|
||||
if (totalMs < 1000)
|
||||
return I18n.tr("Hold to confirm (%1 ms)").arg(totalMs);
|
||||
return I18n.tr("Hold to confirm (%1s)").arg(SettingsData.powerActionHoldDuration);
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
|
||||
@@ -408,15 +408,27 @@ Item {
|
||||
onToggled: checked => SettingsData.set("powerActionConfirm", checked)
|
||||
}
|
||||
|
||||
SettingsSliderRow {
|
||||
SettingsDropdownRow {
|
||||
id: holdDurationDropdown
|
||||
property var durationOptions: ["250 ms", "500 ms", "750 ms", "1 second", "2 seconds", "3 seconds", "5 seconds", "10 seconds"]
|
||||
property var durationValues: [0.25, 0.5, 0.75, 1, 2, 3, 5, 10]
|
||||
|
||||
text: I18n.tr("Hold Duration")
|
||||
description: I18n.tr("How long to hold the button to confirm the action")
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
unit: "s"
|
||||
options: durationOptions
|
||||
visible: SettingsData.powerActionConfirm
|
||||
value: SettingsData.powerActionHoldDuration
|
||||
onSliderValueChanged: newValue => SettingsData.set("powerActionHoldDuration", newValue)
|
||||
|
||||
Component.onCompleted: {
|
||||
const currentDuration = SettingsData.powerActionHoldDuration;
|
||||
const index = durationValues.indexOf(currentDuration);
|
||||
currentValue = index >= 0 ? durationOptions[index] : "500 ms";
|
||||
}
|
||||
|
||||
onValueChanged: value => {
|
||||
const index = durationOptions.indexOf(value);
|
||||
if (index < 0)
|
||||
return;
|
||||
SettingsData.set("powerActionHoldDuration", durationValues[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user