From 88eab5b96fe5469c3c2c611b5e1270572aff76a1 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Mon, 20 Jul 2020 17:19:53 +0200 Subject: [PATCH] Refactor the feed images --- src/qml/EntryListHeader.qml | 19 ++------------ src/qml/FeedImage.qml | 48 ++++++++++++++++++++++++++++++++++++ src/qml/FeedListDelegate.qml | 23 ++++------------- src/resources.qrc | 1 + 4 files changed, 56 insertions(+), 35 deletions(-) create mode 100644 src/qml/FeedImage.qml diff --git a/src/qml/EntryListHeader.qml b/src/qml/EntryListHeader.qml index fce2b99b..b8305ef3 100644 --- a/src/qml/EntryListHeader.qml +++ b/src/qml/EntryListHeader.qml @@ -41,23 +41,8 @@ ColumnLayout { width: parent.width height: root.height * 0.2 - Item { - id: icon - width: 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 - } + FeedImage { + feed: page.feed } ColumnLayout { diff --git a/src/qml/FeedImage.qml b/src/qml/FeedImage.qml new file mode 100644 index 00000000..239ed1a6 --- /dev/null +++ b/src/qml/FeedImage.qml @@ -0,0 +1,48 @@ +/** + * Copyright 2020 Tobias Fella + * + * This program 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) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program 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 this program. If not, see . + */ + +import QtQuick 2.14 +import QtQuick.Controls 2.14 as Controls +import QtQuick.Layouts 1.14 + +import org.kde.kirigami 2.12 as Kirigami + +import org.kde.alligator 1.0 + +Item { + id: icon + width: height + height: parent.height + + property QtObject feed + + Kirigami.Icon { + source: Fetcher.image(feed.image) + width: height + height: parent.height + visible: !busy.visible + } + Controls.BusyIndicator { + id: busy + width: height + height: parent.height + visible: feed.refreshing + } +} diff --git a/src/qml/FeedListDelegate.qml b/src/qml/FeedListDelegate.qml index 1047d928..f217c36f 100644 --- a/src/qml/FeedListDelegate.qml +++ b/src/qml/FeedListDelegate.qml @@ -30,27 +30,14 @@ Kirigami.SwipeListItem { height: Kirigami.Units.gridUnit*2 Item { - Item { - id: icon - width: height - height: parent.height - Kirigami.Icon { - source: Fetcher.image(model.feed.image) - width: height - height: parent.height - visible: !busy.visible - } - Controls.BusyIndicator { - id: busy - width: height - height: parent.height - visible: model.feed.refreshing - } + FeedImage { + id: image + feed: model.feed } Controls.Label { text: model.feed.name height: parent.height - anchors.left: icon.right + anchors.left: image.right leftPadding: 0.5*Kirigami.Units.gridUnit } } @@ -71,4 +58,4 @@ Kirigami.SwipeListItem { lastFeed = model.feed.url pageStack.push("qrc:/EntryListPage.qml", {"feed": model.feed}) } -} \ No newline at end of file +} diff --git a/src/resources.qrc b/src/resources.qrc index c1e71612..3de6a63d 100755 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -10,6 +10,7 @@ qml/EntryListDelegate.qml qml/AddFeedSheet.qml qml/FeedListDelegate.qml + qml/FeedImage.qml qtquickcontrols2.conf