/* Work sponsored by the LiMux project of the city of Munich: SPDX-FileCopyrightText: 2018 Kai Uwe Broulik SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ pragma ComponentBehavior: Bound import QtQuick import QtQuick.Layouts import org.kde.config as KConfig import org.kde.kcmutils as KCMUtils import org.kde.kirigami as Kirigami import org.kde.plasma.core as PlasmaCore import org.kde.plasma.plasma5support as P5Support import org.kde.plasma.plasmoid import org.kde.private.kscreen as KScreen PlasmoidItem { id: root // Only show if the user enabled presentation mode Plasmoid.status: presentationModeEnabled ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus toolTipSubText: presentationModeEnabled ? i18n("Presentation mode is enabled") : "" readonly property string kcmName: "kcm_kscreen" readonly property bool kcmAllowed: KConfig.KAuthorized.authorizeControlModule("kcm_kscreen") readonly property bool presentationModeEnabled: presentationModeCookie > 0 property int presentationModeCookie: -1 P5Support.DataSource { id: pmSource engine: "powermanagement" connectedSources: ["PowerDevil", "Inhibitions"] onSourceAdded: source => { disconnectSource(source); connectSource(source); } onSourceRemoved: source => { disconnectSource(source); } readonly property var inhibitions: { var inhibitions = []; var data = pmSource.data.Inhibitions; if (data) { for (var key in data) { if (key === "plasmashell" || key === "plasmoidviewer") { // ignore our own inhibition continue; } inhibitions.push(data[key]); } } return inhibitions; } } PlasmaCore.Action { id: configureAction text: i18n("Configure Display Settingsā€¦") icon.name: "preferences-desktop-display" visible: root.kcmAllowed onTriggered: KCMUtils.KCMLauncher.openSystemSettings(root.kcmName) } Component.onCompleted: { Plasmoid.setInternalAction("configure", configureAction); } fullRepresentation: ColumnLayout { spacing: 0 Layout.preferredWidth: Kirigami.Units.gridUnit * 15 ScreenLayoutSelection { Layout.leftMargin: Kirigami.Units.smallSpacing Layout.fillWidth: true screenLayouts: Plasmoid.availableActions } PresentationModeItem { Layout.fillWidth: true Layout.topMargin: Kirigami.Units.smallSpacing * 2 Layout.leftMargin: Kirigami.Units.smallSpacing } // compact the layout Item { Layout.fillHeight: true } } }