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 145 Lines • ▼ Show 20 Line(s) | 304 | state: ( updateModel.hasUpdates ? "has-updates" | |||
300 | : secSinceUpdate < 1000 * 60 * 60 * 24 ? "uptodate" | 310 | : secSinceUpdate < 1000 * 60 * 60 * 24 ? "uptodate" | ||
301 | : secSinceUpdate < 1000 * 60 * 60 * 24 * 7 ? "medium" | 311 | : secSinceUpdate < 1000 * 60 * 60 * 24 * 7 ? "medium" | ||
302 | : "low" | 312 | : "low" | ||
303 | ) | 313 | ) | ||
304 | 314 | | |||
305 | states: [ | 315 | states: [ | ||
306 | State { | 316 | State { | ||
307 | name: "fetching" | 317 | name: "fetching" | ||
308 | PropertyChanges { target: page; title: i18nc("@info", "Fetching...") } | 318 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Fetching updates...") } | ||
309 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Checking for updates...") } | 319 | PropertyChanges { target: page; isBusy: true } | ||
apol: Gathering reads super weird to me. | |||||
310 | }, | 320 | }, | ||
311 | State { | 321 | State { | ||
312 | name: "progressing" | 322 | name: "progressing" | ||
313 | PropertyChanges { target: page; title: i18nc("@info", "Updating...") } | | |||
314 | PropertyChanges { target: page; supportsRefreshing: false } | 323 | PropertyChanges { target: page; supportsRefreshing: false } | ||
315 | PropertyChanges { target: page; footerLabel: resourcesUpdatesModel.progress<=0 ? i18nc("@info", "Fetching updates") : "" } | 324 | PropertyChanges { target: page; footerLabel: resourcesUpdatesModel.progress<=0 ? i18nc("@info", "Fetching updates...") : "" } | ||
325 | PropertyChanges { target: page; isBusy: true } | ||||
316 | }, | 326 | }, | ||
317 | State { | 327 | State { | ||
318 | name: "has-updates" | 328 | name: "has-updates" | ||
319 | PropertyChanges { target: page; title: i18nc("@info", "Updates") } | 329 | PropertyChanges { target: page; title: i18nc("@info", "Updates") } | ||
320 | }, | 330 | }, | ||
321 | State { | 331 | State { | ||
322 | name: "reboot" | 332 | name: "reboot" | ||
323 | PropertyChanges { target: page; title: i18nc("@info", "The system requires a restart") } | 333 | PropertyChanges { target: page; footerLabel: i18nc("@info", "The system requires a restart") } | ||
324 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Restart") } | | |||
325 | }, | 334 | }, | ||
326 | State { | 335 | State { | ||
327 | name: "now-uptodate" | 336 | name: "now-uptodate" | ||
328 | PropertyChanges { target: page; title: i18nc("@info", "The system is up to date") } | 337 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Up to date") } | ||
329 | PropertyChanges { target: page; footerLabel: i18nc("@info", "No updates") } | | |||
330 | }, | 338 | }, | ||
331 | State { | 339 | State { | ||
332 | name: "uptodate" | 340 | name: "uptodate" | ||
333 | PropertyChanges { target: page; title: i18nc("@info", "The system is up to date") } | 341 | PropertyChanges { target: page; footerLabel: i18nc("@info", "Up to date") } | ||
334 | PropertyChanges { target: page; footerLabel: i18nc("@info", "No updates") } | | |||
335 | }, | 342 | }, | ||
336 | State { | 343 | State { | ||
337 | name: "medium" | 344 | name: "medium" | ||
338 | PropertyChanges { target: page; title: i18nc("@info", "No updates are available") } | 345 | PropertyChanges { target: page; title: i18nc("@info", "Up to date") } | ||
339 | }, | 346 | }, | ||
340 | State { | 347 | State { | ||
341 | name: "low" | 348 | name: "low" | ||
342 | PropertyChanges { target: page; title: i18nc("@info", "Should check for updates") } | 349 | PropertyChanges { target: page; title: i18nc("@info", "Should check for updates") } | ||
343 | }, | 350 | }, | ||
344 | State { | 351 | State { | ||
345 | name: "unknown" | 352 | name: "unknown" | ||
346 | PropertyChanges { target: page; title: i18nc("@info", "It is unknown when the last check for updates was") } | 353 | PropertyChanges { target: page; title: i18nc("@info", "It is unknown when the last check for updates was") } | ||
347 | } | 354 | } | ||
348 | ] | 355 | ] | ||
349 | } | 356 | } |
use page.isBusy so it doesn't have to start looking for the symbol all over the place