Warning, /plasma/plasma-bigscreen/containments/homescreen/package/contents/ui/PowerManagementItem.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2020 Aditya Mehra <aix.m@outlook.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 
0006 */
0007 
0008 import QtQuick.Layouts 1.14
0009 import QtQuick 2.14
0010 import QtQuick.Window 2.14
0011 import QtQuick.Controls 2.14
0012 import org.kde.plasma.plasma5support 2.0 as P5Support
0013 import org.kde.plasma.components 3.0 as PlasmaComponents3
0014 import org.kde.kirigami 2.12 as Kirigami
0015 import org.kde.kcmutils as KCM
0016 import org.kde.mycroft.bigscreen 1.0 as BigScreen
0017 
0018 Item {
0019     id: powerManagementItem
0020     property int cookie1: -1
0021     property int cookie2: -1
0022     property bool inhibit
0023 
0024     property QtObject pmSource: P5Support.DataSource {
0025         id: pmSource
0026         engine: "powermanagement"
0027         connectedSources: sources
0028         
0029         onSourceAdded: function(source) {
0030             disconnectSource(source);
0031             connectSource(source);
0032         }
0033         onSourceRemoved: function(source) {
0034             disconnectSource(source);
0035         }
0036     }
0037 
0038     onInhibitChanged: {
0039         const service = pmSource.serviceForSource("PowerDevil");
0040         if (inhibit) {
0041             const reason = i18n("Bigscreen has enabled system-wide inhibition");
0042             const op1 = service.operationDescription("beginSuppressingSleep");
0043             op1.reason = reason;
0044             const op2 = service.operationDescription("beginSuppressingScreenPowerManagement");
0045             op2.reason = reason;
0046 
0047             const job1 = service.startOperationCall(op1);
0048             job1.finished.connect(job => {
0049                 cookie1 = job.result;
0050             });
0051 
0052             const job2 = service.startOperationCall(op2);
0053             job2.finished.connect(job => {
0054                 cookie2 = job.result;
0055             });
0056             console.log("Power Inhibition Activated By Bigscreen");
0057         } else {
0058             const op1 = service.operationDescription("stopSuppressingSleep");
0059             op1.cookie = cookie1;
0060             const op2 = service.operationDescription("stopSuppressingScreenPowerManagement");
0061             op2.cookie = cookie2;
0062 
0063             const job1 = service.startOperationCall(op1);
0064             job1.finished.connect(job => {
0065                 cookie1 = -1;
0066             });
0067 
0068             const job2 = service.startOperationCall(op2);
0069             job2.finished.connect(job => {
0070                 cookie2 = -1;
0071             });
0072             console.log("Power Inhibition Deactivated By Bigscreen");
0073         }
0074     }
0075 }