2
* Copyright (c) 2018 Kai Uwe Broulik <kde@broulik.de>
3
* Work sponsored by the LiMux project of
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation; either version 2 of
9
* the License or (at your option) version 3 or any later version
10
* accepted by the membership of KDE e.V. (or its successor approved
11
* by the membership of KDE e.V.), which shall act as a proxy
12
* defined in Section 14 of version 3 of the license.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
import QtQuick.Layouts 1.1
27
import org.kde.plasma.plasmoid 2.0
28
import org.kde.plasma.core 2.0 as PlasmaCore
29
import org.kde.plasma.components 2.0 as PlasmaComponents
30
import org.kde.plasma.extras 2.0 as PlasmaExtras
31
import org.kde.kquickcontrolsaddons 2.0
33
import org.kde.private.kscreen 1.0
38
// Only show if there's screen layouts available or the user enabled presentation mode
39
Plasmoid.status: presentationModeEnabled || plasmoid.nativeInterface.connectedOutputCount > 1 ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus
40
Plasmoid.toolTipSubText: presentationModeEnabled ? i18n("Presentation mode is enabled") : ""
42
readonly property string kcmName: "kcm_kscreen"
43
// does this need an ellipsis?
44
readonly property string kcmLabel: i18nc("Open the full display settings module", "Advanced Display Settings")
45
readonly property string kcmIconName: "preferences-desktop-display-randr"
46
readonly property bool kcmAllowed: KCMShell.authorize(kcmName + ".desktop").length > 0
48
readonly property bool presentationModeEnabled: presentationModeCookie > 0
49
property int presentationModeCookie: -1
51
readonly property var screenLayouts: {
52
var layouts = OsdAction.actionOrder().filter(function (layout) {
53
// We don't want the "No action" item in the plasmoid
54
return layout !== OsdAction.NoAction;
57
layouts.map(function (layout) {
59
iconName: OsdAction.actionIconName(layout),
60
label: OsdAction.actionLabel(layout),
66
PlasmaCore.DataSource {
68
engine: "powermanagement"
69
connectedSources: ["PowerDevil", "Inhibitions"]
72
disconnectSource(source);
73
connectSource(source);
76
disconnectSource(source);
79
readonly property var inhibitions: {
82
var data = pmSource.data.Inhibitions;
84
for (var key in data) {
85
if (key === "plasmashell" || key === "plasmoidviewer") { // ignore our own inhibition
89
inhibitions.push(data[key]);
97
function action_openKcm() {
98
KCMShell.open(kcmName);
101
Component.onCompleted: {
103
plasmoid.setAction("openKcm", root.kcmLabel, root.kcmIconName)
107
Plasmoid.fullRepresentation: ColumnLayout {
109
Layout.preferredWidth: units.gridUnit * 15
111
ScreenLayoutSelection {
112
Layout.fillWidth: true
115
PresentationModeItem {
116
Layout.fillWidth: true
117
Layout.topMargin: units.largeSpacing
120
// compact the layout, push settings button to the bottom
122
Layout.fillHeight: true
125
PlasmaComponents.Button {
126
Layout.alignment: Qt.AlignRight
127
Layout.topMargin: units.smallSpacing
129
iconName: root.kcmIconName
130
onClicked: action_openKcm()