Changeset View
Changeset View
Standalone View
Standalone View
kcms/lookandfeel/package/contents/ui/main.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright (c) 2014 Marco Martin <mart@kde.org> | 2 | Copyright (c) 2018 Marco Martin <mart@kde.org> | ||
3 | 3 | | |||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public | ||
6 | License version 2 as published by the Free Software Foundation. | 6 | License version 2 as published by the Free Software Foundation. | ||
7 | 7 | | |||
8 | This library is distributed in the hope that it will be useful, | 8 | This library is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | Library General Public License for more details. | 11 | Library General Public License for more details. | ||
12 | 12 | | |||
13 | You should have received a copy of the GNU Library General Public License | 13 | You should have received a copy of the GNU Library General Public License | ||
14 | along with this library; see the file COPYING.LIB. If not, write to | 14 | along with this library; see the file COPYING.LIB. If not, write to | ||
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
16 | Boston, MA 02110-1301, USA. | 16 | Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | import QtQuick 2.1 | 19 | import QtQuick 2.6 | ||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 | ||
21 | import QtQuick.Window 2.2 | 21 | import QtQuick.Window 2.2 | ||
22 | import QtQuick.Controls 1.0 as QtControls | 22 | import QtQuick.Controls 2.3 as QtControls | ||
23 | import org.kde.kquickcontrolsaddons 2.0 | 23 | import org.kde.kirigami 2.4 as Kirigami | ||
24 | import QtQuick.Controls.Private 1.0 | 24 | import org.kde.kcm 1.1 as KCM | ||
25 | import org.kde.kirigami 2.0 | 25 | | ||
26 | import org.kde.plasma.components 2.0 as PlasmaComponents | 26 | KCM.GridViewKCM { | ||
27 | import org.kde.kcm 1.0 | 27 | KCM.ConfigModule.quickHelp: i18n("This module lets you configure the look and feel theme.") | ||
28 | | ||||
29 | view.model: kcm.lookAndFeelModel | ||||
30 | view.currentIndex: kcm.selectedPluginIndex | ||||
31 | view.delegate: KCM.GridDelegate { | ||||
32 | id: delegate | ||||
28 | 33 | | |||
29 | Item { | | |||
30 | id: root | | |||
31 | implicitWidth: Units.gridUnit * 20 | | |||
32 | implicitHeight: Units.gridUnit * 20 | | |||
33 | | ||||
34 | ConfigModule.quickHelp: i18n("This module lets you configure the look of the whole workspace with some ready to go presets.") | | |||
35 | | ||||
36 | // HACK QtQuick Controls 1 Button does not update its styleOption palette when it changes, since QQC1 is basically | | |||
37 | // unmaintained and we're eventually moving to QQC2 and this is the first impression the user gets when playing with | | |||
38 | // look and feel feature, we destroy and re-create the GHNS button when its color would change to avoid this. | | |||
39 | SystemPalette { | | |||
40 | id: syspal | | |||
41 | onButtonChanged: { | | |||
42 | ghnsButtonLoader.active = false; | | |||
43 | ghnsButtonLoader.active = true; | | |||
44 | } | | |||
45 | } | | |||
46 | | ||||
47 | ColumnLayout { | | |||
48 | anchors.fill: parent | | |||
49 | QtControls.Label { | | |||
50 | text: i18nd("kcm_lookandfeel", "Select an overall theme for your workspace (including plasma theme, color scheme, mouse cursor, window and desktop switcher, splash screen, lock screen etc.)") | | |||
51 | wrapMode: Text.WordWrap | | |||
52 | Layout.fillWidth: true | | |||
53 | } | | |||
54 | QtControls.ScrollView { | | |||
55 | Layout.fillWidth: true | | |||
56 | Layout.fillHeight: true | | |||
57 | GridView { | | |||
58 | id: grid | | |||
59 | model: kcm.lookAndFeelModel | | |||
60 | cellWidth: Math.floor(root.width / Math.max(Math.floor(root.width / (Units.gridUnit*12)), 3)) - Units.gridUnit | | |||
61 | cellHeight: cellWidth / 1.6 | | |||
62 | | ||||
63 | onCountChanged: { | | |||
64 | grid.currentIndex = kcm.selectedPluginIndex; | | |||
65 | grid.positionViewAtIndex(grid.currentIndex, GridView.Visible) | | |||
66 | } | | |||
67 | delegate: Item { | | |||
68 | width: grid.cellWidth | | |||
69 | height: grid.cellHeight | | |||
70 | | ||||
71 | Rectangle { | | |||
72 | anchors { | | |||
73 | fill: parent | | |||
74 | margins: Units.smallSpacing | | |||
75 | } | | |||
76 | Connections { | | |||
77 | target: kcm | | |||
78 | onSelectedPluginChanged: { | | |||
79 | if (kcm.selectedPlugin == model.pluginName) { | | |||
80 | grid.currentIndex = index | | |||
81 | } | | |||
82 | } | | |||
83 | } | | |||
84 | QIconItem { | | |||
85 | id: icon | | |||
86 | anchors.centerIn: parent | | |||
87 | width: Units.iconSizes.large | | |||
88 | height: width | | |||
89 | icon: "view-preview" | | |||
90 | } | | |||
91 | Image { | | |||
92 | anchors { | | |||
93 | fill: parent | | |||
94 | margins: Units.smallSpacing * 2 | | |||
95 | } | | |||
96 | source: model.screenshot | | |||
97 | | ||||
98 | Rectangle { | | |||
99 | anchors { | | |||
100 | left: parent.left | | |||
101 | right: parent.right | | |||
102 | bottom: parent.bottom | | |||
103 | } | | |||
104 | height: childrenRect.height | | |||
105 | gradient: Gradient { | | |||
106 | GradientStop { | | |||
107 | position: 0.0 | | |||
108 | color: "transparent" | | |||
109 | } | | |||
110 | GradientStop { | | |||
111 | position: 1.0 | | |||
112 | color: Qt.rgba(0, 0, 0, 0.5) | | |||
113 | } | | |||
114 | } | | |||
115 | QtControls.Label { | | |||
116 | anchors { | | |||
117 | horizontalCenter: parent.horizontalCenter | | |||
118 | } | | |||
119 | color: "white" | | |||
120 | text: model.display | 34 | text: model.display | ||
121 | } | 35 | toolTip: model.description | ||
122 | } | | |||
123 | } | | |||
124 | Rectangle { | | |||
125 | opacity: grid.currentIndex == index ? 1.0 : 0 | | |||
126 | anchors.fill: parent | | |||
127 | border.width: Units.smallSpacing * 2 | | |||
128 | border.color: syspal.highlight | | |||
129 | color: "transparent" | | |||
130 | Behavior on opacity { | | |||
131 | PropertyAnimation { | | |||
132 | duration: Units.longDuration | | |||
133 | easing.type: Easing.OutQuad | | |||
134 | } | | |||
135 | } | | |||
136 | } | | |||
137 | MouseArea { | | |||
138 | anchors.fill: parent | | |||
139 | hoverEnabled: true | | |||
140 | onClicked: { | | |||
141 | grid.currentIndex = index | | |||
142 | kcm.selectedPlugin = model.pluginName | | |||
143 | resetCheckbox.checked = false; | | |||
144 | } | | |||
145 | Timer { | | |||
146 | interval: 1000 // FIXME TODO: Use platform value for tooltip activation delay. | | |||
147 | | ||||
148 | running: parent.containsMouse && !parent.pressedButtons | | |||
149 | 36 | | |||
150 | onTriggered: { | 37 | thumbnailAvailable: model.screenshot | ||
151 | Tooltip.showText(parent, Qt.point(parent.mouseX, parent.mouseY), model.display); | 38 | thumbnail: Image { | ||
152 | } | 39 | anchors.fill: parent | ||
153 | } | 40 | source: model.screenshot || "" | ||
154 | PlasmaComponents.ToolButton { | | |||
155 | anchors { | | |||
156 | top: parent.top | | |||
157 | right: parent.right | | |||
158 | margins: Units.smallSpacing | | |||
159 | } | 41 | } | ||
42 | actions: [ | ||||
43 | Kirigami.Action { | ||||
160 | visible: model.fullScreenPreview != "" | 44 | visible: model.fullScreenPreview != "" | ||
161 | iconSource: "media-playback-start" | 45 | iconName: "media-playback-start" | ||
162 | tooltip: i18n("Show Preview") | 46 | tooltip: i18n("Test Splashscreen") | ||
163 | flat: false | 47 | onTriggered: { | ||
164 | onClicked: { | | |||
165 | previewWindow.url = model.fullScreenPreview; | 48 | previewWindow.url = model.fullScreenPreview; | ||
166 | previewWindow.showFullScreen(); | 49 | previewWindow.showFullScreen(); | ||
167 | } | 50 | } | ||
168 | opacity: parent.containsMouse ? 1 : 0 | | |||
169 | Behavior on opacity { | | |||
170 | PropertyAnimation { | | |||
171 | duration: Units.longDuration | | |||
172 | easing.type: Easing.OutQuad | | |||
173 | } | | |||
174 | } | | |||
175 | } | | |||
176 | } | | |||
177 | } | 51 | } | ||
178 | } | 52 | ] | ||
179 | } | 53 | onClicked: { | ||
180 | } | 54 | kcm.selectedPlugin = model.pluginName; | ||
181 | QtControls.Label { | 55 | view.forceActiveFocus(); | ||
182 | text: i18nd("kcm_lookandfeel", "Warning: your Plasma Desktop layout will be lost and reset to the default layout provided by the selected theme.") | | |||
183 | visible: resetCheckbox.checked | | |||
184 | wrapMode: Text.WordWrap | | |||
185 | Layout.fillWidth: true | | |||
186 | } | | |||
187 | Connections { | | |||
188 | target: kcm | | |||
189 | onNeedsSaveChanged: { | | |||
190 | if (!needsSave) { | | |||
191 | resetCheckbox.checked = false; | 56 | resetCheckbox.checked = false; | ||
192 | } | 57 | } | ||
193 | } | 58 | } | ||
194 | } | 59 | | ||
195 | RowLayout { | 60 | footer: RowLayout { | ||
196 | QtControls.CheckBox { | 61 | QtControls.CheckBox { | ||
197 | id: resetCheckbox | 62 | id: resetCheckbox | ||
198 | checked: kcm.resetDefaultLayout | 63 | checked: kcm.resetDefaultLayout | ||
199 | text: i18n("Use Desktop Layout from theme") | 64 | text: i18n("Use Desktop Layout from theme") | ||
200 | onCheckedChanged: kcm.resetDefaultLayout = checked; | 65 | onCheckedChanged: kcm.resetDefaultLayout = checked; | ||
201 | } | 66 | } | ||
202 | Item { | 67 | Item { | ||
203 | Layout.fillWidth: true | 68 | Layout.fillWidth: true | ||
204 | } | 69 | } | ||
205 | Loader { | 70 | QtControls.Button { | ||
206 | id: ghnsButtonLoader | | |||
207 | anchors.right: parent.right | | |||
208 | | ||||
209 | sourceComponent: QtControls.Button { | | |||
210 | text: i18n("Get New Looks...") | 71 | text: i18n("Get New Looks...") | ||
211 | iconName: "get-hot-new-stuff" | 72 | icon.name: "get-hot-new-stuff" | ||
212 | onClicked: kcm.getNewStuff(); | 73 | onClicked: kcm.getNewStuff(); | ||
213 | } | 74 | } | ||
214 | } | 75 | } | ||
215 | } | | |||
216 | } | | |||
217 | | ||||
218 | Window { | 76 | Window { | ||
219 | id: previewWindow | 77 | id: previewWindow | ||
220 | property alias url: previewImage.source | 78 | property alias url: previewImage.source | ||
221 | color: Qt.rgba(0, 0, 0, 0.7) | 79 | color: Qt.rgba(0, 0, 0, 0.7) | ||
222 | MouseArea { | 80 | MouseArea { | ||
223 | anchors.fill: parent | 81 | anchors.fill: parent | ||
224 | Image { | 82 | Image { | ||
225 | id: previewImage | 83 | id: previewImage | ||
226 | anchors.centerIn: parent | 84 | anchors.centerIn: parent | ||
227 | fillMode: Image.PreserveAspectFit | 85 | fillMode: Image.PreserveAspectFit | ||
228 | width: Math.min(parent.width, sourceSize.width) | 86 | width: Math.min(parent.width, sourceSize.width) | ||
229 | height: Math.min(parent.height, sourceSize.height) | 87 | height: Math.min(parent.height, sourceSize.height) | ||
230 | } | 88 | } | ||
231 | onClicked: previewWindow.visible = false; | 89 | onClicked: previewWindow.visible = false; | ||
232 | QtControls.ToolButton { | 90 | QtControls.ToolButton { | ||
233 | anchors { | 91 | anchors { | ||
234 | top: parent.top | 92 | top: parent.top | ||
235 | right: parent.right | 93 | right: parent.right | ||
236 | } | 94 | } | ||
237 | iconName: "window-close" | 95 | icon.name: "window-close" | ||
238 | onClicked: previewWindow.visible = false; | 96 | onClicked: previewWindow.visible = false; | ||
239 | } | 97 | } | ||
240 | QtControls.Action { | 98 | Shortcut { | ||
241 | onTriggered: previewWindow.visible = false; | 99 | onActivated: previewWindow.visible = false; | ||
242 | shortcut: "Esc" | 100 | sequence: "Esc" | ||
243 | } | 101 | } | ||
244 | } | 102 | } | ||
245 | } | 103 | } | ||
246 | } | 104 | } |