From 29d625e81038a890aa4720c33d99d762624ae286 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Sun, 18 Apr 2021 09:40:19 +0200 Subject: [PATCH] First attempt at Swipeable episode list (all, new, unread) --- src/episodemodel.h | 1 + src/qml/EpisodeListPage.qml | 26 +++++++--------- src/qml/EpisodeSwipePage.qml | 57 ++++++++++++++++++++++++++++++++++++ src/qml/main.qml | 6 ++-- src/resources.qrc | 1 + 5 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 src/qml/EpisodeSwipePage.qml diff --git a/src/episodemodel.h b/src/episodemodel.h index f2149cab..5f988cf3 100644 --- a/src/episodemodel.h +++ b/src/episodemodel.h @@ -19,6 +19,7 @@ public: enum Type { All, New, + Unread, Downloading, Downloaded, }; diff --git a/src/qml/EpisodeListPage.qml b/src/qml/EpisodeListPage.qml index 736d87ab..a56c1c46 100644 --- a/src/qml/EpisodeListPage.qml +++ b/src/qml/EpisodeListPage.qml @@ -10,14 +10,16 @@ import QtQuick.Controls 2.14 as Controls import QtQuick.Layouts 1.14 import QtGraphicalEffects 1.15 import QtMultimedia 5.15 -import org.kde.kirigami 2.12 as Kirigami +import org.kde.kirigami 2.15 as Kirigami import org.kde.alligator 1.0 -Kirigami.ScrollablePage { - id: page - title: i18n("Episode List") +Kirigami.ScrollablePage { + //anchors.fill: parent + + title: i18n("New Episodes") + property var episodeType: EpisodeModel.All supportsRefreshing: true onRefreshingChanged: { @@ -27,13 +29,6 @@ Kirigami.ScrollablePage { } } - actions.main: Kirigami.Action { - text: i18n("Refresh all feeds") - iconName: "view-refresh" - onTriggered: refreshing = true - visible: !Kirigami.Settings.isMobile - } - Kirigami.PlaceholderMessage { visible: episodeList.count === 0 @@ -42,22 +37,21 @@ Kirigami.ScrollablePage { text: i18n("No Entries available") } - Component { - id: entryListDelegate + id: episodeListDelegate GenericEntryDelegate { listView: episodeList } } - ListView { + anchors.fill: parent id: episodeList visible: count !== 0 - model: EpisodeModel { type: EpisodeModel.All } + model: EpisodeModel { type: episodeType } delegate: Kirigami.DelegateRecycler { width: episodeList.width - sourceComponent: entryListDelegate + sourceComponent: episodeListDelegate } } } diff --git a/src/qml/EpisodeSwipePage.qml b/src/qml/EpisodeSwipePage.qml new file mode 100644 index 00000000..0d9e705b --- /dev/null +++ b/src/qml/EpisodeSwipePage.qml @@ -0,0 +1,57 @@ +/** + * SPDX-FileCopyrightText: 2020 Tobias Fella + * SPDX-FileCopyrightText: 2021 Bart De Vries + * + * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL + */ + +import QtQuick 2.14 +import QtQuick.Controls 2.14 as Controls +import QtQuick.Layouts 1.14 +import QtGraphicalEffects 1.15 +import QtMultimedia 5.15 +import org.kde.kirigami 2.15 as Kirigami + +import org.kde.alligator 1.0 + +Kirigami.Page { + id: page + + title: i18n("Episode List") + padding: 0 + + header: Controls.TabBar { + id: tabBar + currentIndex: swipeView.currentIndex + + Controls.TabButton { + text: "New Episodes" + } + Controls.TabButton { + text: "All Episodes" + } + } + + Controls.SwipeView { + id: swipeView + anchors.fill: parent + currentIndex: tabBar.currentIndex + + EpisodeListPage { + title: i18n("New Episodes") + episodeType: EpisodeModel.New + } + + EpisodeListPage { + title: i18n("All Episodes") + episodeType: EpisodeModel.All + } + } + + /*actions.main: Kirigami.Action { + text: i18n("Refresh all feeds") + iconName: "view-refresh" + onTriggered: refreshing = true + visible: !Kirigami.Settings.isMobile + }*/ +} diff --git a/src/qml/main.qml b/src/qml/main.qml index bef7ac32..845ec767 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -27,7 +27,7 @@ Kirigami.ApplicationWindow { pageStack.initialPage: mainPagePool.loadPage(SettingsManager.lastOpenedPage === "FeedListPage" ? "qrc:/FeedListPage.qml" : SettingsManager.lastOpenedPage === "QueuePage" ? "qrc:/QueuePage.qml" - : SettingsManager.lastOpenedPage === "EpisodeListPage" ? "qrc:/EpisodeListPage.qml" + : SettingsManager.lastOpenedPage === "EpisodeSwipePage" ? "qrc:/EpisodeSwipePage.qml" : "qrc:/FeedListPage.qml") globalDrawer: Kirigami.GlobalDrawer { @@ -49,9 +49,9 @@ Kirigami.ApplicationWindow { text: i18n("Episodes") iconName: "rss" pagePool: mainPagePool - page: "qrc:/EpisodeListPage.qml" + page: "qrc:/EpisodeSwipePage.qml" onTriggered: { - SettingsManager.lastOpenedPage = "EpisodeListPage" // for persistency + SettingsManager.lastOpenedPage = "EpisodeSwipePage" // for persistency } }, Kirigami.PagePoolAction { diff --git a/src/resources.qrc b/src/resources.qrc index 82b9f407..53e343a5 100755 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -14,6 +14,7 @@ qml/FooterBar.qml qml/QueuePage.qml qml/EpisodeListPage.qml + qml/EpisodeSwipePage.qml qml/GenericListHeader.qml qml/GenericEntryDelegate.qml ../logo.png