Changeset View
Changeset View
Standalone View
Standalone View
src/package/contents/ui/main.qml
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | * | 17 | * | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.1 | 20 | import QtQuick 2.1 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 | ||
22 | import QtQuick.Window 2.2 | 22 | import QtQuick.Window 2.2 | ||
23 | import QtQuick.Controls 1.0 as QtControls | 23 | import QtQuick.Controls 2.3 as QtControls | ||
24 | import org.kde.kquickcontrolsaddons 2.0 | 24 | import org.kde.kirigami 2.4 as Kirigami | ||
25 | import QtQuick.Controls.Private 1.0 | 25 | import org.kde.kcm 1.1 as KCM | ||
26 | //We need units from it | | |||
27 | import org.kde.plasma.core 2.0 as PlasmaCore | | |||
28 | import org.kde.plasma.components 2.0 as PlasmaComponents | | |||
29 | import org.kde.kcm 1.0 | | |||
30 | | ||||
31 | Item { | | |||
32 | id: root | | |||
33 | implicitWidth: units.gridUnit * 20 | | |||
34 | implicitHeight: units.gridUnit * 20 | | |||
35 | 26 | | |||
36 | ConfigModule.quickHelp: i18nd("kcm_plymouth", "This module lets you configure the look of the whole workspace with some ready to go presets.") | 27 | KCM.GridViewKCM { | ||
28 | KCM.ConfigModule.quickHelp: i18n("This module lets you choose the Plymouth boot splash screen.") | ||||
37 | 29 | | |||
38 | SystemPalette {id: syspal} | 30 | view.model: kcm.themesModel | ||
31 | view.currentIndex: kcm.selectedPluginIndex | ||||
39 | 32 | | |||
40 | ColumnLayout { | 33 | view.delegate: KCM.GridDelegate { | ||
41 | anchors.fill: parent | 34 | id: delegate | ||
42 | QtControls.Label { | | |||
43 | text: i18nd("kcm_plymouth", "Select a global splash screen for the system") | | |||
44 | wrapMode: Text.WordWrap | | |||
45 | Layout.fillWidth: true | | |||
46 | } | | |||
47 | QtControls.ScrollView { | | |||
48 | Layout.fillWidth: true | | |||
49 | Layout.fillHeight: true | | |||
50 | GridView { | | |||
51 | id: grid | | |||
52 | model: kcm.themesModel | | |||
53 | cellWidth: Math.floor(root.width / Math.max(Math.floor(root.width / (units.gridUnit*12)), 3)) - units.gridUnit | | |||
54 | cellHeight: cellWidth / 1.6 | | |||
55 | | ||||
56 | onCountChanged: { | | |||
57 | grid.currentIndex = kcm.selectedPluginIndex(); | | |||
58 | grid.positionViewAtIndex(grid.currentIndex, GridView.Visible) | | |||
59 | } | | |||
60 | delegate: Item { | | |||
61 | width: grid.cellWidth | | |||
62 | height: grid.cellHeight | | |||
63 | | ||||
64 | Rectangle { | | |||
65 | anchors { | | |||
66 | fill: parent | | |||
67 | margins: units.smallSpacing | | |||
68 | } | | |||
69 | Connections { | | |||
70 | target: kcm | | |||
71 | onSelectedPluginChanged: { | | |||
72 | if (kcm.selectedPlugin == model.pluginName) { | | |||
73 | grid.currentIndex = index | | |||
74 | } | | |||
75 | } | | |||
76 | } | | |||
77 | QIconItem { | | |||
78 | id: icon | | |||
79 | anchors.centerIn: parent | | |||
80 | width: units.iconSizes.large | | |||
81 | height: width | | |||
82 | icon: "view-preview" | | |||
83 | visible: image.status != Image.Ready | | |||
84 | } | | |||
85 | Image { | | |||
86 | id: image | | |||
87 | anchors { | | |||
88 | fill: parent | | |||
89 | margins: units.smallSpacing * 2 | | |||
90 | } | | |||
91 | source: model.screenshot | | |||
92 | 35 | | |||
93 | Rectangle { | | |||
94 | anchors { | | |||
95 | left: parent.left | | |||
96 | right: parent.right | | |||
97 | bottom: parent.bottom | | |||
98 | } | | |||
99 | height: childrenRect.height | | |||
100 | gradient: Gradient { | | |||
101 | GradientStop { | | |||
102 | position: 0.0 | | |||
103 | color: "transparent" | | |||
104 | } | | |||
105 | GradientStop { | | |||
106 | position: 1.0 | | |||
107 | color: Qt.rgba(0, 0, 0, 0.5) | | |||
108 | } | | |||
109 | } | | |||
110 | QtControls.Label { | | |||
111 | anchors { | | |||
112 | horizontalCenter: parent.horizontalCenter | | |||
113 | } | | |||
114 | color: "white" | | |||
115 | text: model.display | 36 | text: model.display | ||
116 | } | 37 | toolTip: model.description | ||
117 | } | 38 | | ||
118 | } | 39 | thumbnailAvailable: !!model.screenshot | ||
119 | Rectangle { | 40 | thumbnail: Image { | ||
120 | opacity: grid.currentIndex == index ? 1.0 : 0 | | |||
121 | anchors.fill: parent | | |||
122 | border.width: units.smallSpacing * 2 | | |||
123 | border.color: syspal.highlight | | |||
124 | color: "transparent" | | |||
125 | Behavior on opacity { | | |||
126 | PropertyAnimation { | | |||
127 | duration: units.longDuration | | |||
128 | easing.type: Easing.OutQuad | | |||
129 | } | | |||
130 | } | | |||
131 | } | | |||
132 | MouseArea { | | |||
133 | anchors.fill: parent | 41 | anchors.fill: parent | ||
134 | hoverEnabled: true | 42 | source: model.screenshot | ||
135 | onClicked: { | | |||
136 | grid.currentIndex = index | | |||
137 | kcm.selectedPlugin = model.pluginName | | |||
138 | } | 43 | } | ||
139 | Timer { | | |||
140 | interval: 1000 // FIXME TODO: Use platform value for tooltip activation delay. | | |||
141 | 44 | | |||
142 | running: parent.containsMouse && !parent.pressedButtons | 45 | actions: [ | ||
143 | 46 | Kirigami.Action { | |||
144 | onTriggered: { | 47 | iconName: "edit-delete" | ||
145 | Tooltip.showText(parent, Qt.point(parent.mouseX, parent.mouseY), model.display); | 48 | tooltip: i18n("Uninstall") | ||
146 | } | 49 | enabled: model.uninstallable | ||
50 | onTriggered: kcm.uninstall(model.pluginName) | ||||
147 | } | 51 | } | ||
148 | PlasmaComponents.ToolButton { | 52 | ] | ||
149 | anchors { | | |||
150 | top: parent.top | | |||
151 | right: parent.right | | |||
152 | margins: units.smallSpacing | | |||
153 | } | | |||
154 | visible: model.uninstallable | | |||
155 | iconSource: "list-remove" | | |||
156 | tooltip: i18nd("kcm_plymouth", "Uninstall") | | |||
157 | flat: false | | |||
158 | onClicked: { | 53 | onClicked: { | ||
159 | kcm.uninstall(model.pluginName); | 54 | kcm.selectedPlugin = model.pluginName; | ||
160 | } | 55 | view.forceActiveFocus(); | ||
161 | opacity: parent.containsMouse ? 1 : 0 | | |||
162 | Behavior on opacity { | | |||
163 | PropertyAnimation { | | |||
164 | duration: units.longDuration | | |||
165 | easing.type: Easing.OutQuad | | |||
166 | } | | |||
167 | } | | |||
168 | } | | |||
169 | } | | |||
170 | } | 56 | } | ||
171 | } | 57 | } | ||
58 | | ||||
59 | footer: ColumnLayout { | ||||
60 | Kirigami.InlineMessage { | ||||
61 | id: infoLabel | ||||
62 | Layout.fillWidth: true | ||||
63 | showCloseButton: true | ||||
172 | } | 64 | } | ||
65 | | ||||
66 | QtControls.Button { | ||||
67 | id: getNewButton | ||||
68 | Layout.alignment: Qt.AlignRight | ||||
69 | text: i18n("Get New Boot Splash Screens...") | ||||
70 | icon.name: "get-hot-new-stuff" | ||||
71 | onClicked: kcm.getNewStuff(this) | ||||
173 | } | 72 | } | ||
broulik: In all the other KCMs the `InlineMessage` is above the controls to not push them around as it… | |||||
174 | RowLayout { | 73 | | ||
175 | Item { | 74 | QtControls.ProgressBar { | ||
75 | id: progressBar | ||||
176 | Layout.fillWidth: true | 76 | Layout.fillWidth: true | ||
77 | visible: false | ||||
78 | indeterminate: true | ||||
177 | } | 79 | } | ||
178 | QtControls.Button { | | |||
179 | anchors.right: parent.right | | |||
180 | text: i18nd("kcm_plymouth", "Get New Boot Splash Screens...") | | |||
181 | iconName: "get-hot-new-stuff" | | |||
182 | onClicked: kcm.getNewStuff(); | | |||
183 | } | 80 | } | ||
broulik: I don't think this "progress" bar adds much value | |||||
I think it really does. Otherwise the whole UI freezes for 20 seconds and you think it's died. At least with the progress bar, you know something's happening. ngraham: I think it really does. Otherwise the whole UI freezes for 20 seconds and you think it's died. | |||||
Ah, it calls update-alternatives internally, alright, that might take some time. broulik: Ah, it calls `update-alternatives` internally, alright, that might take some time.
Is there a… | |||||
81 | | ||||
82 | Connections { | ||||
83 | target: kcm | ||||
84 | onShowSuccessMessage: { | ||||
85 | infoLabel.type = Kirigami.MessageType.Positive; | ||||
86 | infoLabel.text = message; | ||||
87 | infoLabel.visible = true; | ||||
88 | } | ||||
89 | onShowErrorMessage: { | ||||
90 | infoLabel.type = Kirigami.MessageType.Error; | ||||
91 | infoLabel.text = message; | ||||
92 | infoLabel.visible = true; | ||||
93 | } | ||||
94 | onBusyChanged: { | ||||
95 | view.enabled = !kcm.busy; | ||||
96 | getNewButton.enabled = !kcm.busy; | ||||
97 | progressBar.visible = kcm.busy; | ||||
184 | } | 98 | } | ||
185 | } | 99 | } | ||
186 | } | 100 | } |
In all the other KCMs the InlineMessage is above the controls to not push them around as it comes and goes