From 276246fffc6e72886f2167ac5a170f48253ade55 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Fri, 29 Jul 2016 22:21:10 +0300 Subject: [PATCH] [ubuntu] Fix pull-to-refresh behaviour --- qml/ttrss/ubuntu-touch/Categories.qml | 11 +++++----- qml/ttrss/ubuntu-touch/Feeds.qml | 11 +++++----- qml/ttrss/ubuntu-touch/MyPullToRefresh.qml | 24 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 qml/ttrss/ubuntu-touch/MyPullToRefresh.qml diff --git a/qml/ttrss/ubuntu-touch/Categories.qml b/qml/ttrss/ubuntu-touch/Categories.qml index fbe9ee7..a05ed02 100644 --- a/qml/ttrss/ubuntu-touch/Categories.qml +++ b/qml/ttrss/ubuntu-touch/Categories.qml @@ -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 { diff --git a/qml/ttrss/ubuntu-touch/Feeds.qml b/qml/ttrss/ubuntu-touch/Feeds.qml index 1ad5c10..77ea608 100644 --- a/qml/ttrss/ubuntu-touch/Feeds.qml +++ b/qml/ttrss/ubuntu-touch/Feeds.qml @@ -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 } diff --git a/qml/ttrss/ubuntu-touch/MyPullToRefresh.qml b/qml/ttrss/ubuntu-touch/MyPullToRefresh.qml new file mode 100644 index 0000000..727b9bf --- /dev/null +++ b/qml/ttrss/ubuntu-touch/MyPullToRefresh.qml @@ -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 +}