Warning, /plasma/powerdevil/kcmodule/profiles/ui/ProfileConfig.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2022, 2023 Jakob Petsovits <jpetso@petsovits.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Controls as QQC2 0009 import QtQuick.Layouts 0010 import org.kde.kcmutils as KCM 0011 import org.kde.kirigami as Kirigami 0012 import org.kde.powerdevil as PD 0013 0014 Kirigami.FormLayout { 0015 id: root 0016 0017 required property string profileId 0018 readonly property var profileSettings: kcm.settings["profile" + profileId] 0019 0020 function formatPercentageText(value) { 0021 return i18nc( 0022 "Percentage value example, used for formatting brightness levels in the power management settings", 0023 "10%" 0024 ).replace("10", value); 0025 } 0026 0027 function maxTimeDelaySpinBoxImplicitWidth() { 0028 return Math.max(dimDisplayTimeDelay.implicitWidth, turnOffDisplayTimeDelay.implicitWidth, turnOffDisplayWhenLockedTimeDelay.implicitWidth, idleTimeoutCommandTimeDelay.implicitWidth); 0029 } 0030 0031 // 0032 // Suspend Session 0033 0034 Item { 0035 Kirigami.FormData.isSection: true 0036 Kirigami.FormData.label: i18nc("@title:group", "Suspend Session") 0037 visible: ( 0038 autoSuspendActionRow.visible 0039 || powerButtonActionCombo.visible 0040 || lidActionCombo.visible 0041 || triggersLidActionWhenExternalMonitorPresentCheck.visible 0042 || sleepModeCombo.visible 0043 ) 0044 } 0045 0046 RowLayout { 0047 id: autoSuspendActionRow 0048 Kirigami.FormData.label: i18nc( 0049 "@label:combobox Suspend action such as sleep/hibernate to perform when the system is idle", 0050 "A&fter a period of inactivity:" 0051 ) 0052 visible: kcm.supportedActions["SuspendSession"] === true 0053 Layout.fillWidth: true 0054 spacing: Kirigami.Units.smallSpacing 0055 0056 ComboBoxWithIcon { 0057 id: autoSuspendActionCombo 0058 Accessible.name: i18nc("@accessible:name:combobox", "Action to perform when the system is idle") 0059 0060 Layout.fillWidth: true 0061 implicitContentWidthPolicy: QQC2.ComboBox.WidestTextWhenCompleted 0062 0063 model: kcm.autoSuspendActionModel 0064 textRole: "name" 0065 valueRole: "value" 0066 0067 KCM.SettingStateBinding { 0068 configObject: profileSettings 0069 settingName: "AutoSuspendAction" 0070 } 0071 onActivated: { 0072 profileSettings.autoSuspendAction = currentValue; 0073 } 0074 function resetToProfileSettings() { 0075 currentIndex = indexOfValue(profileSettings.autoSuspendAction); 0076 } 0077 Component.onCompleted: { autoSuspendActionCombo.resetToProfileSettings(); } 0078 Connections { 0079 target: root 0080 function onProfileSettingsChanged() { autoSuspendActionCombo.resetToProfileSettings(); } 0081 } 0082 Connections { 0083 target: profileSettings 0084 function onAutoSuspendActionChanged() { autoSuspendActionCombo.resetToProfileSettings(); } 0085 } 0086 } 0087 0088 TimeDelaySpinBox { 0089 id: autoSuspendTimeDelay 0090 stepSize: 60 0091 from: 60 0092 to: 360 * 60 0093 0094 KCM.SettingStateBinding { 0095 configObject: profileSettings 0096 settingName: "AutoSuspendIdleTimeoutSec" 0097 extraEnabledConditions: autoSuspendActionCombo.currentValue !== PD.PowerDevil.PowerButtonAction.NoAction 0098 } 0099 value: profileSettings.autoSuspendIdleTimeoutSec 0100 onValueModified: { 0101 profileSettings.autoSuspendIdleTimeoutSec = value; 0102 } 0103 function resetToProfileSettings() { 0104 value = profileSettings.autoSuspendIdleTimeoutSec; 0105 } 0106 Connections { 0107 target: root 0108 function onProfileSettingsChanged() { autoSuspendTimeDelay.resetToProfileSettings(); } 0109 } 0110 Connections { 0111 target: profileSettings 0112 function onAutoSuspendIdleTimeoutSecChanged() { autoSuspendTimeDelay.resetToProfileSettings(); } 0113 } 0114 } 0115 } 0116 0117 ComboBoxWithIcon { 0118 id: powerButtonActionCombo 0119 Kirigami.FormData.label: i18nc( 0120 "@label:combobox Suspend action such as sleep/hibernate to perform when the power button is pressed", 0121 "When &power button pressed:" 0122 ) 0123 Accessible.name: i18nc("@accessible:name:combobox", "Action to perform when the power button is pressed") 0124 0125 visible: kcm.supportedActions["HandleButtonEvents"] === true && kcm.isPowerButtonPresent 0126 Layout.fillWidth: true 0127 implicitContentWidthPolicy: QQC2.ComboBox.WidestTextWhenCompleted 0128 0129 model: kcm.powerButtonActionModel 0130 textRole: "name" 0131 valueRole: "value" 0132 0133 KCM.SettingStateBinding { 0134 configObject: profileSettings 0135 settingName: "PowerButtonAction" 0136 } 0137 onActivated: { 0138 profileSettings.powerButtonAction = currentValue; 0139 } 0140 function resetToProfileSettings() { 0141 currentIndex = indexOfValue(profileSettings.powerButtonAction); 0142 } 0143 Component.onCompleted: { powerButtonActionCombo.resetToProfileSettings(); } 0144 Connections { 0145 target: root 0146 function onProfileSettingsChanged() { powerButtonActionCombo.resetToProfileSettings(); } 0147 } 0148 Connections { 0149 target: profileSettings 0150 function onPowerButtonActionChanged() { powerButtonActionCombo.resetToProfileSettings(); } 0151 } 0152 } 0153 0154 ComboBoxWithIcon { 0155 id: lidActionCombo 0156 Kirigami.FormData.label: i18nc( 0157 "@label:combobox Suspend action such as sleep/hibernate to perform when the power button is pressed", 0158 "When laptop &lid closed:" 0159 ) 0160 Accessible.name: i18nc("@accessible:name:combobox", "Action to perform when the laptop lid is closed") 0161 0162 visible: kcm.supportedActions["HandleButtonEvents"] === true && kcm.isLidPresent 0163 Layout.fillWidth: true 0164 implicitContentWidthPolicy: QQC2.ComboBox.WidestTextWhenCompleted 0165 0166 model: kcm.lidActionModel 0167 textRole: "name" 0168 valueRole: "value" 0169 0170 KCM.SettingStateBinding { 0171 configObject: profileSettings 0172 settingName: "LidAction" 0173 } 0174 onActivated: { 0175 profileSettings.lidAction = currentValue; 0176 } 0177 function resetToProfileSettings() { 0178 currentIndex = indexOfValue(profileSettings.lidAction); 0179 } 0180 Component.onCompleted: { lidActionCombo.resetToProfileSettings(); } 0181 Connections { 0182 target: root 0183 function onProfileSettingsChanged() { lidActionCombo.resetToProfileSettings(); } 0184 } 0185 Connections { 0186 target: profileSettings 0187 function onLidActionChanged() { lidActionCombo.resetToProfileSettings(); } 0188 } 0189 } 0190 0191 QQC2.CheckBox { 0192 id: triggersLidActionWhenExternalMonitorPresentCheck 0193 text: i18nc( 0194 "@text:checkbox Trigger laptop lid action even when an external monitor is connected", 0195 "Even when an external monitor is connected" 0196 ) 0197 Accessible.name: i18n("Perform laptop lid action even when an external monitor is connected") 0198 0199 visible: lidActionCombo.visible 0200 0201 KCM.SettingStateBinding { 0202 configObject: profileSettings 0203 settingName: "InhibitLidActionWhenExternalMonitorPresent" 0204 extraEnabledConditions: lidActionCombo.currentValue !== PD.PowerDevil.PowerButtonAction.NoAction 0205 } 0206 checked: !profileSettings.inhibitLidActionWhenExternalMonitorPresent 0207 onToggled: { profileSettings.inhibitLidActionWhenExternalMonitorPresent = !checked; } 0208 } 0209 0210 QQC2.ComboBox { 0211 id: sleepModeCombo 0212 Kirigami.FormData.label: i18nc( 0213 "@label:combobox Sleep mode selection - suspend to memory, disk or both", 0214 "When sleeping, enter:" 0215 ) 0216 Accessible.name: i18nc("@accessible:name:combobox", "When sleeping, enter this power-save mode") 0217 0218 visible: count > 1 && (kcm.supportedActions["SuspendSession"] === true || kcm.supportedActions["HandleButtonEvents"] === true) 0219 Layout.fillWidth: true 0220 implicitContentWidthPolicy: QQC2.ComboBox.WidestTextWhenCompleted 0221 0222 model: kcm.sleepModeModel 0223 textRole: "name" 0224 valueRole: "value" 0225 0226 delegate: Kirigami.SubtitleDelegate { 0227 required property string index 0228 0229 // model roles from roleNames(), expose these in your QAbstractItemModel if you haven't already 0230 required property string name 0231 required property string subtext 0232 0233 text: name 0234 subtitle: subtext 0235 icon.width: 0 0236 width: sleepModeCombo.popup.width 0237 highlighted: index === sleepModeCombo.currentIndex 0238 } 0239 0240 KCM.SettingStateBinding { 0241 configObject: profileSettings 0242 settingName: "SleepMode" 0243 extraEnabledConditions: ( 0244 autoSuspendActionCombo.currentValue === PD.PowerDevil.PowerButtonAction.Sleep 0245 || powerButtonActionCombo.currentValue === PD.PowerDevil.PowerButtonAction.Sleep 0246 || lidActionCombo.currentValue === PD.PowerDevil.PowerButtonAction.Sleep 0247 ) 0248 } 0249 onActivated: { 0250 profileSettings.sleepMode = currentValue; 0251 } 0252 function resetToProfileSettings() { 0253 currentIndex = indexOfValue(profileSettings.sleepMode); 0254 } 0255 Component.onCompleted: { sleepModeCombo.resetToProfileSettings(); } 0256 Connections { 0257 target: root 0258 function onProfileSettingsChanged() { sleepModeCombo.resetToProfileSettings(); } 0259 } 0260 Connections { 0261 target: profileSettings 0262 function onSleepModeChanged() { sleepModeCombo.resetToProfileSettings(); } 0263 } 0264 } 0265 0266 // 0267 // Display and Brightness 0268 0269 Item { 0270 Kirigami.FormData.isSection: true 0271 Kirigami.FormData.label: i18nc("@title:group", "Display and Brightness") 0272 visible: ( 0273 kcm.supportedActions["BrightnessControl"] === true 0274 || kcm.supportedActions["DimDisplay"] === true 0275 || kcm.supportedActions["DPMSControl"] === true 0276 || kcm.supportedActions["KeyboardBrightnessControl"] === true 0277 ) 0278 } 0279 0280 RowLayout { 0281 Kirigami.FormData.label: i18nc("@label:slider Brightness level", "Change scr&een brightness:") 0282 0283 visible: kcm.supportedActions["BrightnessControl"] === true 0284 Layout.fillWidth: true 0285 spacing: Kirigami.Units.smallSpacing 0286 0287 QQC2.CheckBox { 0288 id: displayBrightnessCheck 0289 0290 KCM.SettingStateBinding { 0291 configObject: profileSettings 0292 settingName: "UseProfileSpecificDisplayBrightness" 0293 } 0294 checked: profileSettings.useProfileSpecificDisplayBrightness 0295 onToggled: { profileSettings.useProfileSpecificDisplayBrightness = checked; } 0296 } 0297 QQC2.Slider { 0298 id: displayBrightnessSlider 0299 Layout.fillWidth: true 0300 from: 1 0301 to: 100 0302 stepSize: 1 0303 0304 KCM.SettingStateBinding { 0305 configObject: profileSettings 0306 settingName: "DisplayBrightness" 0307 extraEnabledConditions: displayBrightnessCheck.checked 0308 } 0309 value: profileSettings.displayBrightness 0310 onMoved: { profileSettings.displayBrightness = value; } 0311 } 0312 QQC2.Label { 0313 enabled: displayBrightnessCheck.checked 0314 text: formatPercentageText(displayBrightnessSlider.value) 0315 Layout.preferredWidth: displayBrightnessPercentageMetrics.width 0316 } 0317 TextMetrics { 0318 id: displayBrightnessPercentageMetrics 0319 text: formatPercentageText(100) 0320 } 0321 } 0322 0323 RowLayout { 0324 Kirigami.FormData.label: i18nc("@label:spinbox Dim screen after X minutes", "Di&m automatically:") 0325 0326 visible: kcm.supportedActions["DimDisplay"] === true 0327 Layout.fillWidth: true 0328 spacing: Kirigami.Units.smallSpacing 0329 0330 QQC2.CheckBox { 0331 id: dimDisplayCheck 0332 0333 KCM.SettingStateBinding { 0334 configObject: profileSettings 0335 settingName: "DimDisplayWhenIdle" 0336 } 0337 checked: profileSettings.dimDisplayWhenIdle 0338 onToggled: { profileSettings.dimDisplayWhenIdle = checked; } 0339 } 0340 TimeDelaySpinBox { 0341 id: dimDisplayTimeDelay 0342 Layout.preferredWidth: maxTimeDelaySpinBoxImplicitWidth() 0343 0344 stepSize: 60 0345 from: 60 0346 to: 360 * 60 0347 0348 KCM.SettingStateBinding { 0349 configObject: profileSettings 0350 settingName: "DimDisplayIdleTimeoutSec" 0351 extraEnabledConditions: dimDisplayCheck.checked 0352 } 0353 value: profileSettings.dimDisplayIdleTimeoutSec 0354 onValueModified: { 0355 profileSettings.dimDisplayIdleTimeoutSec = value; 0356 } 0357 function resetToProfileSettings() { 0358 value = profileSettings.dimDisplayIdleTimeoutSec; 0359 } 0360 Connections { 0361 target: root 0362 function onProfileSettingsChanged() { dimDisplayTimeDelay.resetToProfileSettings(); } 0363 } 0364 Connections { 0365 target: profileSettings 0366 function onDimDisplayIdleTimeoutSecChanged() { dimDisplayTimeDelay.resetToProfileSettings(); } 0367 } 0368 } 0369 } 0370 0371 RowLayout { 0372 id: turnOffDisplayRow 0373 Kirigami.FormData.label: i18nc("@label:spinbox After X minutes", "&Turn off screen:") 0374 0375 visible: kcm.supportedActions["DPMSControl"] === true 0376 Layout.fillWidth: true 0377 spacing: Kirigami.Units.smallSpacing 0378 0379 QQC2.CheckBox { 0380 id: turnOffDisplayCheck 0381 0382 KCM.SettingStateBinding { 0383 configObject: profileSettings 0384 settingName: "TurnOffDisplayWhenIdle" 0385 } 0386 checked: profileSettings.turnOffDisplayWhenIdle 0387 onToggled: { profileSettings.turnOffDisplayWhenIdle = checked; } 0388 } 0389 TimeDelaySpinBox { 0390 id: turnOffDisplayTimeDelay 0391 Layout.preferredWidth: maxTimeDelaySpinBoxImplicitWidth() 0392 0393 stepSize: 60 0394 from: 60 0395 to: 360 * 60 0396 0397 KCM.SettingStateBinding { 0398 configObject: profileSettings 0399 settingName: "TurnOffDisplayIdleTimeoutSec" 0400 extraEnabledConditions: turnOffDisplayCheck.checked 0401 } 0402 value: profileSettings.turnOffDisplayIdleTimeoutSec 0403 onValueModified: { 0404 profileSettings.turnOffDisplayIdleTimeoutSec = value; 0405 } 0406 function resetToProfileSettings() { 0407 value = profileSettings.turnOffDisplayIdleTimeoutSec; 0408 } 0409 Connections { 0410 target: root 0411 function onProfileSettingsChanged() { turnOffDisplayTimeDelay.resetToProfileSettings(); } 0412 } 0413 Connections { 0414 target: profileSettings 0415 function onTurnOffDisplayIdleTimeoutSecChanged() { turnOffDisplayTimeDelay.resetToProfileSettings(); } 0416 } 0417 } 0418 } 0419 0420 RowLayout { 0421 Kirigami.FormData.label: i18nc("@label:spinbox After X seconds", "When loc&ked, turn off screen:") 0422 0423 visible: kcm.supportedActions["DPMSControl"] === true 0424 Layout.fillWidth: true 0425 spacing: Kirigami.Units.smallSpacing 0426 0427 QQC2.CheckBox { // dummy item to line up the two spinboxes 0428 enabled: false 0429 opacity: 0 0430 } 0431 TimeDelaySpinBox { 0432 id: turnOffDisplayWhenLockedTimeDelay 0433 Layout.preferredWidth: maxTimeDelaySpinBoxImplicitWidth() 0434 0435 stepSize: 10 0436 from: 0 0437 to: turnOffDisplayTimeDelay.value 0438 0439 KCM.SettingStateBinding { 0440 configObject: profileSettings 0441 settingName: "TurnOffDisplayIdleTimeoutWhenLockedSec" 0442 extraEnabledConditions: turnOffDisplayCheck.checked 0443 } 0444 value: profileSettings.turnOffDisplayIdleTimeoutWhenLockedSec 0445 onValueModified: { 0446 profileSettings.turnOffDisplayIdleTimeoutWhenLockedSec = value; 0447 } 0448 function resetToProfileSettings() { 0449 value = profileSettings.turnOffDisplayIdleTimeoutWhenLockedSec; 0450 } 0451 Connections { 0452 target: root 0453 function onProfileSettingsChanged() { turnOffDisplayWhenLockedTimeDelay.resetToProfileSettings(); } 0454 } 0455 Connections { 0456 target: profileSettings 0457 function onTurnOffDisplayIdleTimeoutWhenLockedSecChanged() { turnOffDisplayWhenLockedTimeDelay.resetToProfileSettings(); } 0458 } 0459 } 0460 } 0461 0462 RowLayout { 0463 Kirigami.FormData.label: i18nc("@label:slider Brightness level", "Change key&board brightness:") 0464 0465 visible: kcm.supportedActions["KeyboardBrightnessControl"] === true 0466 Layout.fillWidth: true 0467 spacing: Kirigami.Units.smallSpacing 0468 0469 QQC2.CheckBox { 0470 id: keyboardBrightnessCheck 0471 0472 KCM.SettingStateBinding { 0473 configObject: profileSettings 0474 settingName: "UseProfileSpecificKeyboardBrightness" 0475 } 0476 checked: profileSettings.useProfileSpecificKeyboardBrightness 0477 onToggled: { profileSettings.useProfileSpecificKeyboardBrightness = checked; } 0478 } 0479 QQC2.Slider { 0480 id: keyboardBrightnessSlider 0481 Layout.fillWidth: true 0482 from: 0 0483 to: 100 0484 stepSize: 1 0485 0486 KCM.SettingStateBinding { 0487 configObject: profileSettings 0488 settingName: "KeyboardBrightness" 0489 extraEnabledConditions: keyboardBrightnessCheck.checked 0490 } 0491 value: profileSettings.keyboardBrightness 0492 onMoved: { profileSettings.keyboardBrightness = value; } 0493 } 0494 QQC2.Label { 0495 enabled: keyboardBrightnessCheck.checked 0496 text: formatPercentageText(keyboardBrightnessSlider.value) 0497 Layout.preferredWidth: keyboardBrightnessPercentageMetrics.width 0498 } 0499 TextMetrics { 0500 id: keyboardBrightnessPercentageMetrics 0501 text: formatPercentageText(100) 0502 } 0503 } 0504 0505 // 0506 // Advanced customization options 0507 0508 Item { 0509 Kirigami.FormData.isSection: true 0510 Kirigami.FormData.label: i18nc("@title:group", "Other Settings") 0511 visible: kcm.supportedActions["RunScript"] === true || powerProfileCombo.visible 0512 } 0513 0514 QQC2.ComboBox { 0515 id: powerProfileCombo 0516 Kirigami.FormData.label: i18nc( 0517 "@label:combobox Power Save, Balanced or Performance profile - same options as in the Battery applet", 0518 "Switch to po&wer profile:" 0519 ) 0520 Accessible.name: i18nc( 0521 "@accessible:name:combobox Power Save, Balanced or Performance profile - same options as in the Battery applet", 0522 "Switch to power profile" 0523 ) 0524 0525 visible: kcm.supportedActions["PowerProfile"] === true && count > 1 0526 Layout.fillWidth: true 0527 implicitContentWidthPolicy: QQC2.ComboBox.WidestTextWhenCompleted 0528 0529 model: kcm.powerProfileModel 0530 textRole: "name" 0531 valueRole: "value" 0532 0533 /*private*/ property bool assignedInitialIndex: false 0534 0535 KCM.SettingStateBinding { 0536 configObject: profileSettings 0537 settingName: "PowerProfile" 0538 } 0539 onActivated: { 0540 profileSettings.powerProfile = currentValue; 0541 } 0542 function resetToProfileSettings() { 0543 currentIndex = indexOfValue(profileSettings.powerProfile); 0544 } 0545 onCountChanged: { // PowerProfileModel has delayed initialization due to a D-Bus call 0546 if (count > 0 && !assignedInitialIndex) { 0547 resetToProfileSettings(); 0548 assignedInitialIndex = true; 0549 } 0550 } 0551 Connections { 0552 target: root 0553 function onProfileSettingsChanged() { powerProfileCombo.resetToProfileSettings(); } 0554 } 0555 Connections { 0556 target: profileSettings 0557 function onPowerProfileChanged() { powerProfileCombo.resetToProfileSettings(); } 0558 } 0559 } 0560 0561 QQC2.Button { 0562 id: addScriptCommandButton 0563 Kirigami.FormData.label: i18nc("@label:button", "Run custom script:") 0564 visible: kcm.supportedActions["RunScript"] === true 0565 0566 icon.name: "settings-configure" 0567 text: i18nc( 0568 "@text:button Determine what will trigger a script command to run in this power state", 0569 "Choose run conditions…" 0570 ) 0571 Accessible.name: i18nc("@accessible:name:button", "Choose run conditions for script command") 0572 0573 onClicked: { 0574 if (addScriptCommandMenu.opened) { 0575 addScriptCommandMenu.close(); // closePolicy: Popup.CloseOnPressOutside does not seem to work? 0576 } else { 0577 addScriptCommandMenu.open(); 0578 } 0579 } 0580 0581 QQC2.Menu { 0582 id: addScriptCommandMenu 0583 title: addScriptCommandButton.text 0584 y: addScriptCommandButton.height 0585 0586 Kirigami.Action { 0587 id: profileLoadCommandEditAction 0588 text: i18nc( 0589 "@text:action:menu Script command to execute", 0590 "When e&ntering this power state" 0591 ) 0592 checkable: true 0593 Component.onCompleted: { 0594 profileLoadCommandEditAction.checked = profileSettings.profileLoadCommand !== ""; 0595 } 0596 onToggled: { 0597 if (!checked) { 0598 profileSettings.profileLoadCommand = ""; 0599 } 0600 } 0601 } 0602 Kirigami.Action { 0603 id: profileUnloadCommandEditAction 0604 text: i18nc( 0605 "@text:action:menu Script command to execute", 0606 "When e&xiting this power state" 0607 ) 0608 checkable: true 0609 Component.onCompleted: { 0610 profileUnloadCommandEditAction.checked = profileSettings.profileUnloadCommand !== ""; 0611 } 0612 onToggled: { 0613 if (!checked) { 0614 profileSettings.profileUnloadCommand = ""; 0615 } 0616 } 0617 } 0618 Kirigami.Action { 0619 id: idleTimeoutCommandEditAction 0620 text: i18nc( 0621 "@text:action:menu Script command to execute", 0622 "After a period of inacti&vity" 0623 ) 0624 checkable: true 0625 Component.onCompleted: { 0626 idleTimeoutCommandEditAction.checked = profileSettings.idleTimeoutCommand !== ""; 0627 } 0628 onToggled: { 0629 if (!checked) { 0630 profileSettings.idleTimeoutCommand = ""; 0631 } 0632 } 0633 } 0634 } 0635 } 0636 0637 RunScriptEdit { 0638 id: profileLoadCommandEdit 0639 Kirigami.FormData.label: i18nc( 0640 "@label:textfield Script command to execute", 0641 "When e&ntering this power state:" 0642 ) 0643 Accessible.name: i18nc("@label:textfield", "Script command when entering this power state") 0644 0645 visible: profileLoadCommandEditAction.checked 0646 Layout.fillWidth: true 0647 0648 KCM.SettingStateBinding { 0649 configObject: profileSettings 0650 settingName: "ProfileLoadCommand" 0651 } 0652 command: profileSettings.profileLoadCommand 0653 onCommandChanged: { 0654 profileSettings.profileLoadCommand = command; 0655 } 0656 function resetToProfileSettings() { 0657 command = profileSettings.profileLoadCommand; 0658 profileLoadCommandEditAction.checked |= profileSettings.profileLoadCommand !== ""; 0659 } 0660 Connections { 0661 target: root 0662 function onProfileSettingsChanged() { profileLoadCommandEdit.resetToProfileSettings(); } 0663 } 0664 Connections { 0665 target: profileSettings 0666 function onProfileLoadCommandChanged() { profileLoadCommandEdit.resetToProfileSettings(); } 0667 } 0668 } 0669 0670 RunScriptEdit { 0671 id: profileUnloadCommandEdit 0672 Kirigami.FormData.label: i18nc( 0673 "@label:textfield Script command to execute", 0674 "When e&xiting this power state:" 0675 ) 0676 Accessible.name: i18nc("@label:textfield", "Script command when exiting this power state") 0677 0678 visible: profileUnloadCommandEditAction.checked 0679 Layout.fillWidth: true 0680 0681 KCM.SettingStateBinding { 0682 configObject: profileSettings 0683 settingName: "ProfileUnloadCommand" 0684 } 0685 command: profileSettings.profileUnloadCommand 0686 onCommandChanged: { 0687 profileSettings.profileUnloadCommand = command; 0688 } 0689 function resetToProfileSettings() { 0690 command = profileSettings.profileUnloadCommand; 0691 profileUnloadCommandEditAction.checked |= profileSettings.profileUnloadCommand !== ""; 0692 } 0693 Connections { 0694 target: root 0695 function onProfileSettingsChanged() { profileUnloadCommandEdit.resetToProfileSettings(); } 0696 } 0697 Connections { 0698 target: profileSettings 0699 function onProfileUnloadCommandChanged() { profileUnloadCommandEdit.resetToProfileSettings(); } 0700 } 0701 } 0702 0703 RunScriptEdit { 0704 id: idleTimeoutCommandEdit 0705 Kirigami.FormData.label: i18nc( 0706 "@label:textfield Script command to execute", 0707 "After a period of inacti&vity:" 0708 ) 0709 Accessible.name: i18nc("@@accessible:name:textfield", "Script command after a period of inactivity") 0710 0711 visible: idleTimeoutCommandEditAction.checked 0712 Layout.fillWidth: true 0713 0714 KCM.SettingStateBinding { 0715 configObject: profileSettings 0716 settingName: "IdleTimeoutCommand" 0717 } 0718 command: profileSettings.idleTimeoutCommand 0719 onCommandChanged: { 0720 profileSettings.idleTimeoutCommand = command; 0721 } 0722 function resetToProfileSettings() { 0723 command = profileSettings.idleTimeoutCommand; 0724 idleTimeoutCommandEditAction.checked |= profileSettings.idleTimeoutCommand !== ""; 0725 } 0726 Connections { 0727 target: root 0728 function onProfileSettingsChanged() { idleTimeoutCommandEdit.resetToProfileSettings(); } 0729 } 0730 Connections { 0731 target: profileSettings 0732 function onIdleTimeoutCommandChanged() { idleTimeoutCommandEdit.resetToProfileSettings(); } 0733 } 0734 } 0735 0736 TimeDelaySpinBox { 0737 id: idleTimeoutCommandTimeDelay 0738 Accessible.name: i18nc("@accessible:name:spinbox", "Period of inactivity until the script command executes") 0739 visible: idleTimeoutCommandEdit.visible 0740 Layout.preferredWidth: maxTimeDelaySpinBoxImplicitWidth() 0741 0742 stepSize: 60 0743 from: 60 0744 to: 360 * 60 0745 0746 KCM.SettingStateBinding { 0747 configObject: profileSettings 0748 settingName: "RunScriptIdleTimeoutSec" 0749 } 0750 value: profileSettings.runScriptIdleTimeoutSec 0751 onValueModified: { 0752 profileSettings.runScriptIdleTimeoutSec = value; 0753 } 0754 function resetToProfileSettings() { 0755 value = profileSettings.runScriptIdleTimeoutSec; 0756 } 0757 Connections { 0758 target: root 0759 function onProfileSettingsChanged() { idleTimeoutCommandTimeDelay.resetToProfileSettings(); } 0760 } 0761 Connections { 0762 target: profileSettings 0763 function onRunScriptIdleTimeoutSecChanged() { idleTimeoutCommandTimeDelay.resetToProfileSettings(); } 0764 } 0765 } 0766 }