From 4f11060a418daa5e484bd1afcd2440515fc85fcd Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Sat, 3 Apr 2021 16:52:07 +0200 Subject: [PATCH] Queue is functional again --- src/qml/QueueDelegate.qml | 98 +++++++++++++++++++++++++++++++++++++++ src/qml/QueuePage.qml | 63 +++++++++---------------- src/qml/main.qml | 4 -- src/resources.qrc | 1 + 4 files changed, 120 insertions(+), 46 deletions(-) create mode 100644 src/qml/QueueDelegate.qml diff --git a/src/qml/QueueDelegate.qml b/src/qml/QueueDelegate.qml new file mode 100644 index 00000000..8a8f160d --- /dev/null +++ b/src/qml/QueueDelegate.qml @@ -0,0 +1,98 @@ +/* + SPDX-FileCopyrightText: 2021 (c) Bart De Vries + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +// Includes relevant modules used by the QML +import QtQuick 2.6 +import QtQuick.Controls 2.0 as Controls +import QtQuick.Layouts 1.2 +import org.kde.kirigami 2.13 as Kirigami +import QtMultimedia 5.15 +import org.kde.alligator 1.0 + + +Kirigami.SwipeListItem { + id: listItem + + contentItem: RowLayout { + Kirigami.ListItemDragHandle { + listItem: listItem + listView: queueList + onMoveRequested: DataManager.moveQueueItem(oldIndex, newIndex) + } + ColumnLayout { + spacing: 0 + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter + Controls.Label { + text: model.entry.title + Layout.fillWidth: true + elide: Text.ElideRight + font.weight: model.entry.read ? Font.Normal : Font.Bold + opacity: 1 + } + Loader { + sourceComponent: entry.enclosure && entry.enclosure.status === Enclosure.Downloading ? downloadProgress : subtitle + Layout.fillWidth: true + Component { + id: subtitle + Controls.Label { + text: model.entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (model.entry.authors.length === 0 ? "" : " " + i18nc("by ", "by") + " " + model.entry.authors[0].name) + Layout.fillWidth: true + elide: Text.ElideRight + font: Kirigami.Theme.smallFont + opacity: model.entry.read ? 0.7 : 0.9 + visible: !downloadProgress.visible + } + } + Component { + id: downloadProgress + Controls.ProgressBar { + from: 0 + to: 100 + value: model.entry.enclosure.downloadProgress + visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloading + Layout.fillWidth: true + } + } + } + } + } + + onClicked: { + model.entry.read = true + pageStack.push("qrc:/EntryPage.qml", {"entry": model.entry}) + } + + actions: [ + Kirigami.Action { + iconName: "media-playback-start" + text: "Play" + onTriggered: { + audio.entry = model.entry + audio.play() + } + }, + Kirigami.Action { + text: i18n("Download") + icon.name: "download" + onTriggered: model.entry.enclosure.download() + visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloadable + }, + Kirigami.Action { + text: i18n("Cancel download") + icon.name: "edit-delete-remove" + onTriggered: model.entry.enclosure.cancelDownload() + visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloading + }, + Kirigami.Action { + text: i18n("Delete download") + icon.name: "delete" + onTriggered: model.entry.enclosure.deleteFile() + visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloaded + } + ] +} + diff --git a/src/qml/QueuePage.qml b/src/qml/QueuePage.qml index 989068b6..4d348779 100644 --- a/src/qml/QueuePage.qml +++ b/src/qml/QueuePage.qml @@ -15,50 +15,33 @@ import org.kde.alligator 1.0 Kirigami.ScrollablePage { id: queuepage title: i18n("Queue") + + Kirigami.PlaceholderMessage { + visible: queueList.count === 0 + + width: Kirigami.Units.gridUnit * 20 + anchors.centerIn: parent + + text: i18n("Nothing added to the queue yet") + } + Component { id: delegateComponent - Kirigami.SwipeListItem { - id: listItem - contentItem: RowLayout { - Kirigami.ListItemDragHandle { - listItem: listItem - listView: mainList - onMoveRequested: DataManager.moveQueueItem(oldIndex, newIndex) - } - - Controls.Label { - Layout.fillWidth: true - height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium) - text: model.entry.title - color: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) ? listItem.activeTextColor : listItem.textColor - } - } - actions: [ - Kirigami.Action { - iconName: "media-playback-start" - text: "Play" - onTriggered: { - audio.entry = model.entry - audio.play() - } - }, - Kirigami.Action { - iconName: "delete" - text: i18n("Delete download") - onTriggered: model.entry.enclosure.deleteFile() - visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloaded - } - ] - onClicked: { - pageStack.push("qrc:/EntryPage.qml", {"entry": model.entry}) - } - } + QueueDelegate { } } ListView { - id: mainList + id: queueList + visible: count !== 0 - model: root.queueModel + model: QueueModel { + id: queueModel + } + delegate: Kirigami.DelegateRecycler { + width: queueList.width + sourceComponent: delegateComponent + } + anchors.fill: parent moveDisplaced: Transition { YAnimator { @@ -66,10 +49,6 @@ Kirigami.ScrollablePage { easing.type: Easing.InOutQuad } } - delegate: Kirigami.DelegateRecycler { - width: mainList.width - sourceComponent: delegateComponent - } } } diff --git a/src/qml/main.qml b/src/qml/main.qml index 7ed6971d..768a8f67 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -70,10 +70,6 @@ Kirigami.ApplicationWindow { id: feedList } - QueueModel { - id: queueModel - } - QueuePage { id: queuelist } diff --git a/src/resources.qrc b/src/resources.qrc index 0eb98ffa..91d0112b 100755 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -14,6 +14,7 @@ qml/PlayerControls.qml qml/FooterBar.qml qml/QueuePage.qml + qml/QueueDelegate.qml qtquickcontrols2.conf