Changeset View
Changeset View
Standalone View
Standalone View
kcms/desktoptheme/package/contents/ui/main.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright (c) 2014 Marco Martin <mart@kde.org> | 2 | Copyright (c) 2014 Marco Martin <mart@kde.org> | ||
3 | Copyright (c) 2016 David Rosca <nowrep@gmail.com> | 3 | Copyright (c) 2016 David Rosca <nowrep@gmail.com> | ||
4 | Copyright (c) 2018 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
4 | 5 | | |||
5 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public | ||
7 | License version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. | ||
8 | 9 | | |||
9 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | 13 | Library General Public License for more details. | ||
13 | 14 | | |||
14 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
18 | */ | 19 | */ | ||
19 | 20 | | |||
20 | import QtQuick 2.1 | 21 | import QtQuick 2.1 | ||
21 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
22 | import QtQuick.Dialogs 1.0 | 23 | import QtQuick.Dialogs 1.0 | ||
23 | import QtQuick.Controls.Private 1.0 | 24 | import QtQuick.Controls 2.3 as QtControls | ||
24 | import QtQuick.Controls 1.0 as QtControls | 25 | import org.kde.kirigami 2.4 as Kirigami | ||
26 | import org.kde.kcm 1.1 as KCM | ||||
25 | 27 | | |||
26 | import org.kde.kcm 1.0 | 28 | KCM.GridViewKCM { | ||
27 | import org.kde.kirigami 2.0 // for units | 29 | KCM.ConfigModule.quickHelp: i18n("This module lets you configure the desktop theme.") | ||
28 | import org.kde.plasma.components 2.0 as PlasmaComponents //the round toolbutton | | |||
29 | 30 | | |||
30 | Item { | 31 | view.model: kcm.desktopThemeModel | ||
31 | implicitWidth: Units.gridUnit * 20 | 32 | view.currentIndex: kcm.indexOf(kcm.selectedPlugin) | ||
32 | implicitHeight: Units.gridUnit * 20 | | |||
33 | 33 | | |||
34 | ConfigModule.quickHelp: i18n("This module lets you configure the desktop theme.") | 34 | view.remove: Transition { | ||
35 | 35 | ParallelAnimation { | |||
36 | SystemPalette { | 36 | NumberAnimation { property: "scale"; to: 0.5; duration: Kirigami.Units.longDuration } | ||
37 | id: syspal | 37 | NumberAnimation { property: "opacity"; to: 0.0; duration: Kirigami.Units.longDuration } | ||
38 | } | | |||
39 | | ||||
40 | ColumnLayout { | | |||
41 | anchors.fill: parent | | |||
42 | QtControls.ScrollView { | | |||
43 | Layout.fillWidth: true | | |||
44 | Layout.fillHeight: true | | |||
45 | verticalScrollBarPolicy: Qt.ScrollBarAlwaysOn | | |||
46 | GridView { | | |||
47 | id: grid | | |||
48 | model: kcm.desktopThemeModel | | |||
49 | cellWidth: Math.floor(grid.width / Math.max(Math.floor(grid.width / (Units.gridUnit * 12)), 3)) | | |||
50 | cellHeight: cellWidth / 1.6 | | |||
51 | | ||||
52 | onCountChanged: { | | |||
53 | grid.currentIndex = kcm.indexOf(kcm.selectedPlugin); | | |||
54 | grid.positionViewAtIndex(grid.currentIndex, GridView.Visible) | | |||
55 | } | | |||
56 | | ||||
57 | delegate: Item { | | |||
58 | property bool isLocal : model.isLocal | | |||
59 | property string pluginName : model.pluginName | | |||
60 | width: grid.cellWidth | | |||
61 | height: grid.cellHeight | | |||
62 | Rectangle { | | |||
63 | anchors { | | |||
64 | fill: parent | | |||
65 | margins: Units.smallSpacing | | |||
66 | } | | |||
67 | Connections { | | |||
68 | target: kcm | | |||
69 | onSelectedPluginChanged: { | | |||
70 | if (kcm.selectedPlugin == model.pluginName) { | | |||
71 | makeCurrentTimer.pendingIndex = index | | |||
72 | } | | |||
73 | } | | |||
74 | } | | |||
75 | Component.onCompleted: { | | |||
76 | if (kcm.selectedPlugin == model.pluginName) { | | |||
77 | makeCurrentTimer.pendingIndex = index | | |||
78 | } | 38 | } | ||
79 | } | 39 | } | ||
80 | 40 | | |||
81 | MouseArea { | 41 | view.removeDisplaced: Transition { | ||
82 | anchors { | 42 | SequentialAnimation { | ||
83 | fill: parent | 43 | // wait for the "remove" animation to finish | ||
84 | margins: Units.smallSpacing * 2 | 44 | PauseAnimation { duration: Kirigami.Units.longDuration } | ||
45 | NumberAnimation { properties: "x,y"; duration: Kirigami.Units.longDuration } | ||||
85 | } | 46 | } | ||
86 | hoverEnabled: true | | |||
87 | onClicked: { | | |||
88 | grid.currentIndex = index | | |||
89 | kcm.selectedPlugin = model.pluginName | | |||
90 | } | 47 | } | ||
91 | 48 | | |||
92 | Timer { | 49 | view.delegate: KCM.GridDelegate { | ||
93 | interval: 1000 | 50 | id: delegate | ||
94 | running: parent.containsMouse && !parent.pressedButtons | 51 | | ||
95 | onTriggered: { | 52 | text: model.themeName | ||
96 | Tooltip.showText(parent, Qt.point(parent.mouseX, parent.mouseY), model.themeName); | 53 | toolTip: model.description || model.themeName | ||
97 | } | | |||
98 | } | | |||
99 | 54 | | |||
100 | ThemePreview { | 55 | thumbnailAvailable: true | ||
56 | thumbnail: ThemePreview { | ||||
101 | id: preview | 57 | id: preview | ||
102 | anchors { | 58 | anchors.fill: parent | ||
103 | top: parent.top | | |||
104 | left: parent.left | | |||
105 | right: parent.right | | |||
106 | bottom: label.top | | |||
107 | } | | |||
108 | themeName: model.pluginName | 59 | themeName: model.pluginName | ||
109 | } | 60 | } | ||
110 | 61 | | |||
111 | PlasmaComponents.ToolButton { | 62 | actions: [ | ||
112 | anchors { | 63 | Kirigami.Action { | ||
113 | bottom: preview.bottom | 64 | iconName: "document-edit" | ||
114 | right: preview.right | 65 | tooltip: i18n("Edit Theme") | ||
115 | margins: units.smallSpacing | | |||
116 | } | | |||
117 | iconSource: "document-edit" | | |||
118 | tooltip: i18n("Edit theme") | | |||
119 | flat: false | | |||
120 | onClicked: kcm.editTheme(model.pluginName) | | |||
121 | visible: kcm.canEditThemes | 66 | visible: kcm.canEditThemes | ||
122 | opacity: parent.containsMouse ? 1 : 0 | 67 | onTriggered: kcm.editTheme(model.pluginName) | ||
123 | Behavior on opacity { | 68 | }, | ||
124 | PropertyAnimation { | 69 | Kirigami.Action { | ||
125 | duration: units.longDuration | 70 | iconName: "edit-delete" | ||
126 | easing.type: Easing.OutQuad | 71 | tooltip: i18n("Remove Theme") | ||
127 | } | 72 | enabled: model.isLocal | ||
128 | } | 73 | onTriggered: kcm.removeTheme(model.pluginName) | ||
129 | } | 74 | } | ||
75 | ] | ||||
130 | 76 | | |||
131 | QtControls.Label { | 77 | onClicked: { | ||
132 | id: label | 78 | kcm.selectedPlugin = model.pluginName; | ||
133 | anchors { | 79 | view.forceActiveFocus(); | ||
134 | bottom: parent.bottom | | |||
135 | horizontalCenter: parent.horizontalCenter | | |||
136 | leftMargin: Units.smallSpacing * 2 | | |||
137 | rightMargin: Units.smallSpacing * 2 | | |||
138 | } | | |||
139 | height: paintedHeight | | |||
140 | width: parent.width | | |||
141 | color: "black" | | |||
142 | text: model.themeName | | |||
143 | elide: Text.ElideRight | | |||
144 | horizontalAlignment: Text.AlignHCenter | | |||
145 | } | 80 | } | ||
146 | } | 81 | } | ||
147 | 82 | | |||
148 | Rectangle { | 83 | footer: ColumnLayout { | ||
149 | opacity: grid.currentIndex == index ? 1.0 : 0 | 84 | Kirigami.InlineMessage { | ||
150 | anchors.fill: parent | 85 | id: infoLabel | ||
151 | border.width: Units.smallSpacing * 2 | 86 | Layout.fillWidth: true | ||
152 | border.color: syspal.highlight | 87 | | ||
153 | color: "transparent" | 88 | showCloseButton: true | ||
154 | Behavior on opacity { | 89 | | ||
155 | PropertyAnimation { | 90 | Connections { | ||
156 | duration: Units.longDuration | 91 | target: kcm | ||
157 | easing.type: Easing.OutQuad | 92 | onShowSuccessMessage: { | ||
158 | } | 93 | infoLabel.type = Kirigami.MessageType.Positive; | ||
159 | } | 94 | infoLabel.text = message; | ||
160 | } | 95 | infoLabel.visible = true; | ||
161 | } | 96 | } | ||
162 | } | 97 | onShowErrorMessage: { | ||
163 | Timer { | 98 | infoLabel.type = Kirigami.MessageType.Error; | ||
164 | id: makeCurrentTimer | 99 | infoLabel.text = message; | ||
165 | interval: 100 | 100 | infoLabel.visible = true; | ||
166 | repeat: false | | |||
167 | property int pendingIndex | | |||
168 | onPendingIndexChanged: makeCurrentTimer.restart() | | |||
169 | onTriggered: { | | |||
170 | grid.currentIndex = pendingIndex | | |||
171 | } | | |||
172 | } | 101 | } | ||
173 | } | 102 | } | ||
174 | } | 103 | } | ||
104 | | ||||
175 | RowLayout { | 105 | RowLayout { | ||
176 | QtControls.Button { | 106 | Layout.alignment: Qt.AlignRight | ||
177 | text: i18n("Get New Themes...") | | |||
178 | iconName: "get-hot-new-stuff" | | |||
179 | onClicked: kcm.getNewThemes() | | |||
180 | } | | |||
181 | 107 | | |||
182 | QtControls.Button { | 108 | QtControls.Button { | ||
183 | text: i18n("Install from File...") | 109 | text: i18n("Install from File...") | ||
184 | iconName: "document-import" | 110 | icon.name: "document-import" | ||
185 | onClicked: fileDialogLoader.active = true; | 111 | onClicked: fileDialogLoader.active = true; | ||
186 | } | 112 | } | ||
187 | 113 | | |||
188 | QtControls.Button { | 114 | QtControls.Button { | ||
189 | text: i18n("Remove Theme") | 115 | text: i18n("Get New Themes...") | ||
190 | iconName: "edit-delete" | 116 | icon.name: "get-hot-new-stuff" | ||
191 | enabled: grid.currentItem && grid.currentItem.isLocal | 117 | onClicked: kcm.getNewThemes() | ||
192 | onClicked: { | | |||
193 | kcm.removeTheme(grid.currentItem.pluginName); | | |||
194 | kcm.selectedPlugin = grid.currentItem.pluginName | | |||
195 | } | | |||
196 | } | | |||
197 | | ||||
198 | Item { | | |||
199 | Layout.fillWidth: true | | |||
200 | } | | |||
201 | | ||||
202 | QtControls.Label { | | |||
203 | id: infoLabel | | |||
204 | } | | |||
205 | } | | |||
206 | } | | |||
207 | | ||||
208 | Connections { | | |||
209 | target: kcm | | |||
210 | onShowInfoMessage: { | | |||
211 | infoLabel.text = infoMessage; | | |||
212 | hideInfoMessageTimer.restart(); | | |||
213 | } | | |||
214 | } | 118 | } | ||
215 | | ||||
216 | Timer { | | |||
217 | id: hideInfoMessageTimer | | |||
218 | interval: 20 * 1000 | | |||
219 | onTriggered: { | | |||
220 | infoLabel.text = "" | | |||
221 | } | 119 | } | ||
222 | } | 120 | } | ||
223 | 121 | | |||
224 | Loader { | 122 | Loader { | ||
225 | id: fileDialogLoader | 123 | id: fileDialogLoader | ||
226 | active: false | 124 | active: false | ||
227 | sourceComponent: FileDialog { | 125 | sourceComponent: FileDialog { | ||
228 | visible: true | 126 | visible: true | ||
Show All 13 Lines |