mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-16 10:42:06 -04:00
idle/lock: add option to turn off monitors after lock explicitly
fixes #452 fixes #2156
This commit is contained in:
@@ -7,8 +7,8 @@ import qs.Modules.Settings.Widgets
|
||||
Item {
|
||||
id: root
|
||||
|
||||
readonly property var timeoutOptions: [I18n.tr("Never"), I18n.tr("1 minute"), I18n.tr("2 minutes"), I18n.tr("3 minutes"), I18n.tr("5 minutes"), I18n.tr("10 minutes"), I18n.tr("15 minutes"), I18n.tr("20 minutes"), I18n.tr("30 minutes"), I18n.tr("1 hour"), I18n.tr("1 hour 30 minutes"), I18n.tr("2 hours"), I18n.tr("3 hours")]
|
||||
readonly property var timeoutValues: [0, 60, 120, 180, 300, 600, 900, 1200, 1800, 3600, 5400, 7200, 10800]
|
||||
readonly property var timeoutOptions: [I18n.tr("Never"), I18n.tr("15 seconds"), I18n.tr("30 seconds"), I18n.tr("1 minute"), I18n.tr("2 minutes"), I18n.tr("3 minutes"), I18n.tr("5 minutes"), I18n.tr("10 minutes"), I18n.tr("15 minutes"), I18n.tr("20 minutes"), I18n.tr("30 minutes"), I18n.tr("1 hour"), I18n.tr("1 hour 30 minutes"), I18n.tr("2 hours"), I18n.tr("3 hours")]
|
||||
readonly property var timeoutValues: [0, 15, 30, 60, 120, 180, 300, 600, 900, 1200, 1800, 3600, 5400, 7200, 10800]
|
||||
|
||||
function getTimeoutIndex(timeout) {
|
||||
var idx = timeoutValues.indexOf(timeout);
|
||||
@@ -260,6 +260,39 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
id: postLockMonitorDropdown
|
||||
settingKey: "postLockMonitorTimeout"
|
||||
tags: ["monitor", "display", "screen", "timeout", "off", "lock", "after", "post"]
|
||||
text: I18n.tr("Turn off monitors after lock")
|
||||
options: root.timeoutOptions
|
||||
|
||||
Connections {
|
||||
target: powerCategory
|
||||
function onCurrentIndexChanged() {
|
||||
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acPostLockMonitorTimeout : SettingsData.batteryPostLockMonitorTimeout;
|
||||
postLockMonitorDropdown.currentValue = root.timeoutOptions[root.getTimeoutIndex(currentTimeout)];
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acPostLockMonitorTimeout : SettingsData.batteryPostLockMonitorTimeout;
|
||||
currentValue = root.timeoutOptions[root.getTimeoutIndex(currentTimeout)];
|
||||
}
|
||||
|
||||
onValueChanged: value => {
|
||||
const index = root.timeoutOptions.indexOf(value);
|
||||
if (index < 0)
|
||||
return;
|
||||
const timeout = root.timeoutValues[index];
|
||||
if (powerCategory.currentIndex === 0) {
|
||||
SettingsData.set("acPostLockMonitorTimeout", timeout);
|
||||
} else {
|
||||
SettingsData.set("batteryPostLockMonitorTimeout", timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
id: suspendDropdown
|
||||
settingKey: "suspendTimeout"
|
||||
|
||||
@@ -17,7 +17,6 @@ StyledRect {
|
||||
property string description: ""
|
||||
property string iconName: ""
|
||||
property bool checked: false
|
||||
property bool enabled: true
|
||||
|
||||
default property alias content: expandedContent.children
|
||||
readonly property bool hasContent: expandedContent.children.length > 0
|
||||
|
||||
Reference in New Issue
Block a user