Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/ScreenLayoutSelection.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2018 Kai Uwe Broulik <kde@broulik.de> | ||||
3 | * Work sponsored by the LiMux project of | ||||
4 | * the city of Munich. | ||||
5 | * | ||||
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. | ||||
13 | * | ||||
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. | ||||
18 | * | ||||
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/>. | ||||
21 | * | ||||
22 | */ | ||||
23 | | ||||
24 | import QtQuick 2.8 | ||||
25 | import QtQuick.Layouts 1.1 | ||||
26 | | ||||
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 | | ||||
32 | ColumnLayout { | ||||
33 | spacing: 0 | ||||
34 | | ||||
35 | states: [ | ||||
36 | State { | ||||
37 | // only makes sense to offer screen layout setup if there's more than one screen connected | ||||
38 | when: plasmoid.nativeInterface.connectedOutputCount < 2 | ||||
39 | | ||||
40 | PropertyChanges { | ||||
41 | target: screenLayoutRow | ||||
42 | enabled: false | ||||
43 | } | ||||
44 | PropertyChanges { | ||||
45 | target: noScreenLabel | ||||
46 | visible: true | ||||
47 | } | ||||
48 | } | ||||
49 | ] | ||||
50 | | ||||
51 | PlasmaExtras.Heading { | ||||
52 | Layout.fillWidth: true | ||||
53 | level: 2 | ||||
54 | text: i18n("Screen Layout") | ||||
55 | } | ||||
56 | | ||||
57 | // Screen layout selector section | ||||
58 | Row { | ||||
59 | id: screenLayoutRow | ||||
60 | readonly property int buttonSize: Math.floor((width - spacing * (screenLayoutRepeater.count - 1)) / screenLayoutRepeater.count) | ||||
61 | Layout.fillWidth: true | ||||
62 | spacing: units.smallSpacing | ||||
63 | | ||||
64 | Repeater { | ||||
65 | id: screenLayoutRepeater | ||||
66 | model: root.screenLayouts | ||||
67 | | ||||
68 | PlasmaComponents.Button { | ||||
69 | width: screenLayoutRow.buttonSize | ||||
70 | height: width | ||||
71 | tooltip: modelData.label | ||||
72 | Accessible.name: tooltip | ||||
73 | onClicked: plasmoid.nativeInterface.applyLayoutPreset(modelData.action) | ||||
74 | | ||||
75 | // HACK otherwise the icon won't expand to full button size | ||||
76 | PlasmaCore.IconItem { | ||||
77 | anchors.centerIn: parent | ||||
78 | width: height | ||||
79 | // FIXME use proper FrameSvg margins and stuff | ||||
80 | height: parent.height - units.smallSpacing | ||||
81 | source: modelData.iconName | ||||
82 | active: parent.hovered | ||||
83 | } | ||||
84 | } | ||||
85 | } | ||||
86 | } | ||||
87 | | ||||
88 | PlasmaExtras.DescriptiveLabel { | ||||
89 | id: noScreenLabel | ||||
90 | Layout.fillWidth: true | ||||
91 | Layout.maximumWidth: Math.min(units.gridUnit * 20, implicitWidth) | ||||
92 | wrapMode: Text.Wrap | ||||
93 | text: i18n("You can only apply a different screen layout when there is more than one display device plugged in.") | ||||
94 | font.pointSize: theme.smallestFont.pointSize | ||||
95 | visible: false | ||||
96 | } | ||||
97 | } |