From b2dd9961ed05f0d66c36aebd9fe379e718b75c56 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Fri, 16 Apr 2021 21:43:08 +0200 Subject: [PATCH] Rework actions on queue, entrylist and entrypage --- src/qml/EntryListDelegate.qml | 35 +++++++++++++++++++------------ src/qml/EntryPage.qml | 39 ++++++++++++++++++++++++++++------- src/qml/QueueDelegate.qml | 12 ++++++++--- 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/src/qml/EntryListDelegate.qml b/src/qml/EntryListDelegate.qml index f2970834..282d96bb 100644 --- a/src/qml/EntryListDelegate.qml +++ b/src/qml/EntryListDelegate.qml @@ -8,9 +8,8 @@ import QtQuick 2.14 import QtQuick.Controls 2.14 as Controls import QtQuick.Layouts 1.14 - import org.kde.kirigami 2.13 as Kirigami - +import QtMultimedia 5.15 import org.kde.alligator 1.0 Kirigami.SwipeListItem { @@ -118,7 +117,10 @@ Kirigami.SwipeListItem { onClicked: { // only mark pure rss feeds as read; podcasts should only be marked read once they have been listened to - if (!entry.enclosure) { entry.read = true; entry.new = false;} + if (!entry.enclosure) { + entry.read = true; + entry.new = false; + } pageStack.push("qrc:/EntryPage.qml", {"entry": entry}) } @@ -138,21 +140,28 @@ Kirigami.SwipeListItem { onTriggered: entry.enclosure.cancelDownload() visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading }, - Kirigami.Action { - text: "Play" - icon.name: "media-playback-start" - onTriggered: { - audio.entry = entry; - audio.play(); - } - visible: entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded - }, Kirigami.Action { text: i18n("Add to queue") icon.name: "media-playlist-append" visible: !entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded onTriggered: entry.queueStatus = true - } /*, + }, + Kirigami.Action { + text: i18n("Play") + icon.name: "media-playback-start" + visible: entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && (audio.entry !== entry || audio.playbackState !== Audio.PlayingState) + onTriggered: { + audio.entry = entry + audio.play() + } + }, + Kirigami.Action { + text: i18n("Pause") + icon.name: "media-playback-pause" + visible: entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && audio.entry === entry && audio.playbackState === Audio.PlayingState + onTriggered: audio.pause() + } + /*, Kirigami.Action { text: i18n("Delete download") icon.name: "delete" diff --git a/src/qml/EntryPage.qml b/src/qml/EntryPage.qml index c0520622..f270edb3 100644 --- a/src/qml/EntryPage.qml +++ b/src/qml/EntryPage.qml @@ -50,23 +50,48 @@ Kirigami.ScrollablePage { text: !entry.enclosure ? i18n("Open in Browser") : entry.enclosure.status === Enclosure.Downloadable ? i18n("Download") : entry.enclosure.status === Enclosure.Downloading ? i18n("Cancel download") : - i18n("Delete downloaded file") + !entry.queueStatus ? i18("Add to Queue") : + (audio.entry === entry) && audio.playbackState === Audio.PlayingState ? i18n("Play") : + i18n("Pause") icon.name: !entry.enclosure ? "globe" : entry.enclosure.status === Enclosure.Downloadable ? "download" : entry.enclosure.status === Enclosure.Downloading ? "edit-delete-remove" : - "delete" + !entry.queueStatus ? "media-playlist-append" : + (audio.entry === entry && audio.playbackState === Audio.PlayingState) ? "media-playback-pause" : + "media-playback-start" onTriggered: { if(!entry.enclosure) Qt.openUrlExternally(entry.link) else if(entry.enclosure.status === Enclosure.Downloadable) entry.enclosure.download() else if(entry.enclosure.status === Enclosure.Downloading) entry.enclosure.cancelDownload() - else entry.enclosure.deleteFile() + else if(entry.queueStatus) { + if(audio.entry === entry && audio.playbackState === Audio.PlayingState) { + audio.pause() + } else { + audio.entry = entry + audio.play() + } + } else { + entry.queueStatus = true + } } } actions.left: Kirigami.Action { - text: "Add to queue" - icon.name: "media-playlist-append" - visible: entry.enclosure && !entry.queueStatus - onTriggered: entry.queueStatus = true + text: !entry.queueStatus ? i18n("Add to queue") : i18n("Remove from Queue") + icon.name: !entry.queueStatus ? "media-playlist-append" : "list-remove" + visible: entry.enclosure + onTriggered: { + if(!entry.queueStatus) { + entry.queueStatus = true + } else { + entry.queueStatus = false + } + } + } + actions.right: Kirigami.Action { + text: i18n("Delete download") + icon.name: "delete" + onTriggered: entry.enclosure.deleteFile() + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloaded } } diff --git a/src/qml/QueueDelegate.qml b/src/qml/QueueDelegate.qml index bd802666..74cae511 100644 --- a/src/qml/QueueDelegate.qml +++ b/src/qml/QueueDelegate.qml @@ -7,7 +7,7 @@ // Includes relevant modules used by the QML import QtQuick 2.14 import QtQuick.Controls 2.14 as Controls -import QtQuick.Layouts 1.2 +import QtQuick.Layouts 1.14 import org.kde.kirigami 2.13 as Kirigami import QtMultimedia 5.15 import org.kde.alligator 1.0 @@ -150,13 +150,19 @@ Kirigami.SwipeListItem { visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloaded },*/ Kirigami.Action { - text: "Play" + text: i18n("Play") icon.name: "media-playback-start" + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && (audio.entry !== entry || audio.playbackState !== Audio.PlayingState) onTriggered: { audio.entry = entry audio.play() } - visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloaded + }, + Kirigami.Action { + text: i18n("Pause") + icon.name: "media-playback-pause" + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && audio.entry === entry && audio.playbackState === Audio.PlayingState + onTriggered: audio.pause() } ] }