Warning, /plasma/kscreen/plasmoid/package/contents/ui/PresentationModeItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 Work sponsored by the LiMux project of the city of Munich: 0003 SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@broulik.de> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 import QtQuick 2.15 0009 import QtQuick.Layouts 1.15 0010 0011 import org.kde.kirigami 2.20 as Kirigami 0012 import org.kde.plasma.components 3.0 as PlasmaComponents3 0013 import org.kde.plasma.extras 2.0 as PlasmaExtras 0014 0015 ColumnLayout { 0016 spacing: Kirigami.Units.smallSpacing 0017 0018 PlasmaComponents3.Switch { 0019 id: presentationModeSwitch 0020 Layout.fillWidth: true 0021 // Remove spacing between checkbox and the explanatory label below 0022 Layout.bottomMargin: -parent.spacing 0023 text: i18n("Enable Presentation Mode") 0024 0025 onCheckedChanged: { 0026 if (checked === root.presentationModeEnabled) { 0027 return; 0028 } 0029 0030 // disable Switch while job is running 0031 presentationModeSwitch.enabled = false; 0032 0033 const service = pmSource.serviceForSource("PowerDevil"); 0034 0035 if (checked) { 0036 const op = service.operationDescription("beginSuppressingScreenPowerManagement"); 0037 op.reason = i18n("User enabled presentation mode"); 0038 0039 const job = service.startOperationCall(op); 0040 job.finished.connect(job => { 0041 presentationModeSwitch.enabled = true; 0042 }); 0043 } else { 0044 const op = service.operationDescription("stopSuppressingScreenPowerManagement"); 0045 0046 const job = service.startOperationCall(op); 0047 job.finished.connect(job => { 0048 presentationModeSwitch.enabled = true; 0049 }); 0050 } 0051 } 0052 } 0053 0054 PlasmaExtras.DescriptiveLabel { 0055 Layout.fillWidth: true 0056 Layout.leftMargin: presentationModeSwitch.indicator.width + presentationModeSwitch.spacing 0057 font: Kirigami.Theme.smallFont 0058 text: i18n("This will prevent your screen and computer from turning off automatically.") 0059 wrapMode: Text.WordWrap 0060 } 0061 0062 InhibitionHint { 0063 Layout.fillWidth: true 0064 Layout.leftMargin: presentationModeSwitch.indicator.width + presentationModeSwitch.spacing 0065 0066 iconSource: pmSource.inhibitions.length > 0 ? pmSource.inhibitions[0].Icon || "" : "" 0067 text: { 0068 const inhibitions = pmSource.inhibitions; 0069 const inhibition = inhibitions[0]; 0070 if (inhibitions.length > 1) { 0071 return i18ncp("Some Application and n others enforce presentation mode", 0072 "%2 and %1 other application are enforcing presentation mode.", 0073 "%2 and %1 other applications are enforcing presentation mode.", 0074 inhibitions.length - 1, inhibition.Name) // plural only works on %1 0075 } else if (inhibitions.length === 1) { 0076 if (!inhibition.Reason) { 0077 return i18nc("Some Application enforce presentation mode", 0078 "%1 is enforcing presentation mode.", inhibition.Name) 0079 } else { 0080 return i18nc("Some Application enforce presentation mode: Reason provided by the app", 0081 "%1 is enforcing presentation mode: %2", inhibition.Name, inhibition.Reason) 0082 } 0083 } else { 0084 return ""; 0085 } 0086 } 0087 } 0088 }