Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/UpdatesPage.qml
1 | import QtQuick.Controls 2.3 | 1 | import QtQuick.Controls 2.3 | ||
---|---|---|---|---|---|
2 | import QtQuick.Layouts 1.1 | 2 | import QtQuick.Layouts 1.1 | ||
3 | import QtQuick 2.4 | 3 | import QtQuick 2.4 | ||
4 | import org.kde.discover 2.0 | 4 | import org.kde.discover 2.0 | ||
5 | import org.kde.discover.app 1.0 | 5 | import org.kde.discover.app 1.0 | ||
6 | import "navigation.js" as Navigation | 6 | import "navigation.js" as Navigation | ||
7 | import org.kde.kirigami 2.3 as Kirigami | 7 | import org.kde.kirigami 2.3 as Kirigami | ||
8 | 8 | | |||
9 | DiscoverPage | 9 | DiscoverPage | ||
10 | { | 10 | { | ||
11 | id: page | 11 | id: page | ||
12 | title: i18n("Updates") | 12 | title: i18n("Updates") | ||
13 | 13 | | |||
14 | property string footerLabel: "" | 14 | property string footerLabel: "" | ||
15 | property bool isBusy: false | ||||
15 | 16 | | |||
16 | ResourcesUpdatesModel { | 17 | ResourcesUpdatesModel { | ||
17 | id: resourcesUpdatesModel | 18 | id: resourcesUpdatesModel | ||
18 | onPassiveMessage: window.showPassiveNotification(message) | 19 | onPassiveMessage: window.showPassiveNotification(message) | ||
19 | onIsProgressingChanged: { | 20 | onIsProgressingChanged: { | ||
20 | if (!isProgressing) { | 21 | if (!isProgressing) { | ||
21 | resourcesUpdatesModel.prepare() | 22 | resourcesUpdatesModel.prepare() | ||
22 | } | 23 | } | ||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 135 | footer: ColumnLayout { | |||
136 | anchors.left: parent.left | 137 | anchors.left: parent.left | ||
137 | Kirigami.Heading { | 138 | Kirigami.Heading { | ||
138 | Layout.fillWidth: true | 139 | Layout.fillWidth: true | ||
139 | Layout.alignment: Qt.AlignHCenter | 140 | Layout.alignment: Qt.AlignHCenter | ||
140 | horizontalAlignment: Text.AlignHCenter | 141 | horizontalAlignment: Text.AlignHCenter | ||
141 | visible: page.footerLabel !== "" | 142 | visible: page.footerLabel !== "" | ||
142 | text: page.footerLabel | 143 | text: page.footerLabel | ||
143 | } | 144 | } | ||
145 | BusyIndicator { | ||||
146 | id: indicator | ||||
147 | Layout.alignment: Qt.AlignHCenter | ||||
148 | Layout.minimumWidth: Kirigami.Units.gridUnit * 12 | ||||
149 | Layout.maximumWidth: Layout.minimumWidth | ||||
150 | Layout.minimumHeight: Layout.minimumWidth | ||||
151 | Layout.maximumHeight: Layout.minimumHeight | ||||
152 | visible: page.isBusy | ||||
apol: use `page.isBusy` so it doesn't have to start looking for the symbol all over the place | |||||
153 | } | ||||
144 | Kirigami.Icon { | 154 | Kirigami.Icon { | ||
145 | Layout.alignment: Qt.AlignHCenter | 155 | Layout.alignment: Qt.AlignHCenter | ||
146 | visible: page.footerLabel !== "" | 156 | visible: !indicator.visible && page.footerLabel !== "" | ||
147 | source: "update-none" | 157 | source: "update-none" | ||
148 | opacity: 0.3 | 158 | opacity: 0.3 | ||
149 | width: Kirigami.Units.gridUnit * 12 | 159 | width: Kirigami.Units.gridUnit * 12 | ||
150 | height: width | 160 | height: width | ||
151 | } | 161 | } | ||
152 | Item { | 162 | Item { | ||
153 | visible: page.footerLabel === "" | 163 | visible: page.footerLabel === "" | ||
154 | height: Kirigami.Units.gridUnit | 164 | height: Kirigami.Units.gridUnit | ||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Line(s) | 306 | state: ( updateModel.hasUpdates ? "has-updates" | |||
302 | : secSinceUpdate < 1000 * 60 * 60 * 24 ? "uptodate" | 312 | : secSinceUpdate < 1000 * 60 * 60 * 24 ? "uptodate" | ||
303 | : secSinceUpdate < 1000 * 60 * 60 * 24 * 7 ? "medium" | 313 | : secSinceUpdate < 1000 * 60 * 60 * 24 * 7 ? "medium" | ||
304 | : "low" | 314 | : "low" | ||
305 | ) | 315 | ) | ||
306 | 316 | | |||
307 | states: [ | 317 | states: [ | ||
308 | State { | 318 | State { | ||
309 | name: "fetching" | 319 | name: "fetching" | ||
310 | PropertyChanges { target: page; title: i18nc("@info", "Fetching...") } | 320 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Fetching updates...") } | ||
311 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Checking for updates...") } | 321 | PropertyChanges { target: page; isBusy: true } | ||
apol: Gathering reads super weird to me. | |||||
312 | }, | 322 | }, | ||
313 | State { | 323 | State { | ||
314 | name: "progressing" | 324 | name: "progressing" | ||
315 | PropertyChanges { target: page; title: i18nc("@info", "Updating...") } | | |||
316 | PropertyChanges { target: page; supportsRefreshing: false } | 325 | PropertyChanges { target: page; supportsRefreshing: false } | ||
317 | PropertyChanges { target: page; footerLabel: resourcesUpdatesModel.progress<=0 ? i18nc("@info", "Fetching updates") : "" } | 326 | PropertyChanges { target: page; footerLabel: resourcesUpdatesModel.progress<=0 ? i18nc("@info", "Fetching updates...") : "" } | ||
327 | PropertyChanges { target: page; isBusy: true } | ||||
318 | }, | 328 | }, | ||
319 | State { | 329 | State { | ||
320 | name: "has-updates" | 330 | name: "has-updates" | ||
321 | PropertyChanges { target: page; title: i18nc("@info", "Updates") } | 331 | PropertyChanges { target: page; title: i18nc("@info", "Updates") } | ||
322 | }, | 332 | }, | ||
323 | State { | 333 | State { | ||
324 | name: "reboot" | 334 | name: "reboot" | ||
325 | PropertyChanges { target: page; title: i18nc("@info", "The system requires a restart") } | 335 | PropertyChanges { target: page; footerLabel: i18nc("@info", "The system requires a restart") } | ||
326 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Restart") } | | |||
327 | }, | 336 | }, | ||
328 | State { | 337 | State { | ||
329 | name: "now-uptodate" | 338 | name: "now-uptodate" | ||
330 | PropertyChanges { target: page; title: i18nc("@info", "The system is up to date") } | 339 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Up to date") } | ||
331 | PropertyChanges { target: page; footerLabel: i18nc("@info", "No updates") } | | |||
332 | }, | 340 | }, | ||
333 | State { | 341 | State { | ||
334 | name: "uptodate" | 342 | name: "uptodate" | ||
335 | PropertyChanges { target: page; title: i18nc("@info", "The system is up to date") } | 343 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Up to date") } | ||
336 | PropertyChanges { target: page; footerLabel: i18nc("@info", "No updates") } | | |||
337 | }, | 344 | }, | ||
338 | State { | 345 | State { | ||
339 | name: "medium" | 346 | name: "medium" | ||
340 | PropertyChanges { target: page; title: i18nc("@info", "No updates are available") } | 347 | PropertyChanges { target: page; title: i18nc("@info", "Up to date") } | ||
341 | }, | 348 | }, | ||
342 | State { | 349 | State { | ||
343 | name: "low" | 350 | name: "low" | ||
344 | PropertyChanges { target: page; title: i18nc("@info", "Should check for updates") } | 351 | PropertyChanges { target: page; title: i18nc("@info", "Should check for updates") } | ||
345 | }, | 352 | }, | ||
346 | State { | 353 | State { | ||
347 | name: "unknown" | 354 | name: "unknown" | ||
348 | PropertyChanges { target: page; title: i18nc("@info", "It is unknown when the last check for updates was") } | 355 | PropertyChanges { target: page; title: i18nc("@info", "It is unknown when the last check for updates was") } | ||
349 | } | 356 | } | ||
350 | ] | 357 | ] | ||
351 | } | 358 | } |
use page.isBusy so it doesn't have to start looking for the symbol all over the place