diff --git a/src/datamanager.h b/src/datamanager.h index 9fd2ffac..e0988854 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -28,7 +28,7 @@ public: } Feed *getFeed(const int index) const; - Feed *getFeed(const QString &feedurl) const; + Q_INVOKABLE Feed *getFeed(const QString &feedurl) const; Entry *getEntry(const int feed_index, const int entry_index) const; Entry *getEntry(const Feed *feed, const int entry_index) const; Q_INVOKABLE Entry *getEntry(const QString &id) const; diff --git a/src/qml/DiscoverPage.qml b/src/qml/DiscoverPage.qml index 993ab4c3..b276f379 100644 --- a/src/qml/DiscoverPage.qml +++ b/src/qml/DiscoverPage.qml @@ -63,20 +63,23 @@ Kirigami.ScrollablePage { } actions: [ Kirigami.Action { + id: subscribeAction text: enabled ? i18n("Subscribe") : i18n("Subscribed") icon.name: "kt-add-feeds" enabled: !DataManager.feedExists(model.url) onTriggered: { - DataManager.addFeed(model.url) + DataManager.addFeed(model.url); + enabled = false; } } ] onClicked: { - pageStack.push("qrc:/FeedDetailsPage.qml", {"feed": model, isSubscribed: false}) + pageStack.push("qrc:/FeedDetailsPage.qml", {"feed": subscribeAction.enabled ? model : DataManager.getFeed(model.url), "isSubscribed": !subscribeAction.enabled, "subscribeAction": subscribeAction}) } } } ListView { + id: listView anchors.fill: parent reuseItems: true diff --git a/src/qml/FeedDetailsPage.qml b/src/qml/FeedDetailsPage.qml index dea4d64a..f4047241 100644 --- a/src/qml/FeedDetailsPage.qml +++ b/src/qml/FeedDetailsPage.qml @@ -22,6 +22,7 @@ Kirigami.ScrollablePage { property QtObject feed; property bool isSubscribed: true + property var subscribeAction: undefined // this is only used if instantiated from the discoverpage property string author: isSubscribed ? (page.feed.authors.length === 0 ? "" : page.feed.authors[0].name) : feed.author property bool showMoreInfo: false @@ -142,7 +143,14 @@ Kirigami.ScrollablePage { text: enabled ? i18n("Subscribe") : i18n("Subscribed") enabled: !DataManager.feedExists(feed.url) visible: !isSubscribed - onTriggered: DataManager.addFeed(feed.url) + onTriggered: { + DataManager.addFeed(feed.url); + enabled = false; + // Also disable button on discoverpage + if (subscribeAction !== undefined) { + subscribeAction.enabled = false; + } + } }, Kirigami.Action { iconName: "documentinfo"