[ubuntu] Fix pull-to-refresh behaviour

This commit is contained in:
Alberto Mardegan 2016-07-29 22:21:10 +03:00
parent 9605f6c2be
commit 276246fffc
3 changed files with 35 additions and 11 deletions

View file

@ -43,7 +43,7 @@ Page {
}
}
UbuntuListView {
ListView {
id: listView
anchors.fill: parent
@ -62,10 +62,9 @@ Page {
}
*/
pullToRefresh {
enabled: true
onRefresh: categories.update()
refreshing: network.loading
MyPullToRefresh {
id: pullToRefresh
updating: network.loading
}
delegate: CategoryDelegate {
@ -82,7 +81,7 @@ Page {
rootWindow.showAll ? qsTr("No categories to display") : qsTr("No categories have unread items")
}
ActivityIndicator {
running: listView.count != 0 && network.loading
running: network.loading && !pullToRefresh.refreshing
anchors.centerIn: parent
}
Scrollbar {

View file

@ -22,8 +22,6 @@ Page {
var ttrss = rootWindow.getTTRSS()
ttrss.setShowAll(settings.showAll)
feedModel.update()
// FIXME workaround for https://bugs.launchpad.net/bugs/1404884
pullToRefresh.enabled = true
}
header: PageHeader {
@ -57,11 +55,10 @@ Page {
anchors.fill: parent
model: feedModel
PullToRefresh {
MyPullToRefresh {
id: pullToRefresh
enabled: false
onRefresh: feedModel.update()
refreshing: network.loading
updating: network.loading
}
/* TODO
@ -145,6 +142,10 @@ Page {
qsTr("Loading") :
rootWindow.showAll ? qsTr("No feeds in category") : qsTr("Category has no unread items")
}
ActivityIndicator {
running: network.loading && !pullToRefresh.refreshing
anchors.centerIn: parent
}
Scrollbar {
flickableItem: listView
}

View file

@ -0,0 +1,24 @@
//Copyright Hauke Schade, 2012-2014
//
//This file is part of TTRss.
//
//TTRss is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
//Free Software Foundation, either version 2 of the License, or (at your option) any later version.
//TTRss is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//You should have received a copy of the GNU General Public License along with TTRss (on a Maemo/Meego system there is a copy
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
import QtQuick 2.0
import Ubuntu.Components 1.3
PullToRefresh {
id: root
property bool updating: false
property bool _wasPulled: false
onRefresh: _wasPulled = true
refreshing: _wasPulled && updating
onUpdatingChanged: if (!updating) _wasPulled = false
}