Rework actions on queue, entrylist and entrypage

This commit is contained in:
Bart De Vries 2021-04-16 21:43:08 +02:00
parent 23b6b68500
commit b2dd9961ed
3 changed files with 63 additions and 23 deletions

View File

@ -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"

View File

@ -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
}
}

View File

@ -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()
}
]
}