Make refreshing consistent on FeedListPage and EntryListPage

This commit is contained in:
Tobias Fella 2020-05-31 22:47:42 +02:00
parent 6fd81f52e9
commit 4d5684b0d0
3 changed files with 25 additions and 14 deletions

View File

@ -57,7 +57,7 @@ public:
void setAuthors(QVector<Author *> authors); void setAuthors(QVector<Author *> authors);
void setRefreshing(bool refreshing); void setRefreshing(bool refreshing);
void refresh(); Q_INVOKABLE void refresh();
void remove(); void remove();
Q_SIGNALS: Q_SIGNALS:

View File

@ -32,8 +32,13 @@ Kirigami.ScrollablePage {
property var feed property var feed
title: feed.name title: feed.name
supportsRefreshing: true
//property bool all: feed onRefreshingChanged:
if(refreshing) {
feed.refresh()
refreshing = false
}
contextualActions: [ contextualActions: [
Kirigami.Action { Kirigami.Action {
@ -46,7 +51,8 @@ Kirigami.ScrollablePage {
actions.main: Kirigami.Action { actions.main: Kirigami.Action {
iconName: "view-refresh" iconName: "view-refresh"
text: i18n("Refresh Feed") text: i18n("Refresh Feed")
onTriggered: Fetcher.fetch(page.feed.url) onTriggered: page.refreshing = true
visible: !Kirigami.Settings.isMobile
} }
Kirigami.PlaceholderMessage { Kirigami.PlaceholderMessage {
@ -70,10 +76,22 @@ Kirigami.ScrollablePage {
width: parent.width width: parent.width
height: root.height * 0.2 height: root.height * 0.2
visible: !all visible: !all
Kirigami.Icon { Item {
source: Fetcher.image(page.feed.image) id: icon
width: height width: height
height: parent.height height: parent.height
Kirigami.Icon {
source: Fetcher.image(page.feed.image)
width: height
height: parent.height
visible: !busy.visible
}
Controls.BusyIndicator {
id: busy
width: height
height: parent.height
visible: page.feed.refreshing
}
} }
Kirigami.Heading { Kirigami.Heading {
text: page.feed.name text: page.feed.name

View File

@ -34,21 +34,15 @@ Kirigami.ScrollablePage {
supportsRefreshing: true supportsRefreshing: true
onRefreshingChanged: onRefreshingChanged:
if(refreshing) { if(refreshing) {
timer.running = true
Fetcher.fetchAll() Fetcher.fetchAll()
refreshing = false
} }
Timer {
id: timer
interval: 1000
onTriggered: refreshing = false
}
contextualActions: [ contextualActions: [
Kirigami.Action { Kirigami.Action {
text: i18n("Refresh all feeds") text: i18n("Refresh all feeds")
iconName: "view-refresh" iconName: "view-refresh"
onTriggered: Fetcher.fetchAll() onTriggered: refreshing = true
visible: !Kirigami.Settings.isMobile visible: !Kirigami.Settings.isMobile
} }
] ]
@ -139,7 +133,6 @@ Kirigami.ScrollablePage {
visible: model.feed.refreshing visible: model.feed.refreshing
} }
} }
Controls.Label { Controls.Label {
text: model.feed.name text: model.feed.name
height: parent.height height: parent.height