From 07afc98978466e0869e1bdd58980e6e9cc7788ad Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Sat, 17 Apr 2021 20:15:14 +0200 Subject: [PATCH] Consolidate all EntryDelegate actions QueueDelegates and EntryListDelegates are now using the same actions defined in GenericEntryDelegate. --- src/qml/EntryListPage.qml | 38 ---------------- src/qml/GenericEntryDelegate.qml | 78 ++++++++++++++++---------------- src/qml/QueuePage.qml | 29 ------------ 3 files changed, 39 insertions(+), 106 deletions(-) diff --git a/src/qml/EntryListPage.qml b/src/qml/EntryListPage.qml index fbb9750d..562583ba 100644 --- a/src/qml/EntryListPage.qml +++ b/src/qml/EntryListPage.qml @@ -68,44 +68,6 @@ Kirigami.ScrollablePage { id: entryListDelegate GenericEntryDelegate { listView: entryList - entryActions: [ // TODO: put the actions back into GenericEntryDelegate - Kirigami.Action { - text: i18n("Download") - icon.name: "download" - onTriggered: { - entry.queueStatus = true; - entry.enclosure.download(); - } - visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloadable - }, - Kirigami.Action { - text: i18n("Cancel download") - icon.name: "edit-delete-remove" - onTriggered: entry.enclosure.cancelDownload() - visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading - }, - 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() - } - ] } } diff --git a/src/qml/GenericEntryDelegate.qml b/src/qml/GenericEntryDelegate.qml index 15d3b337..8887dd5a 100644 --- a/src/qml/GenericEntryDelegate.qml +++ b/src/qml/GenericEntryDelegate.qml @@ -19,45 +19,6 @@ Kirigami.SwipeListItem { property bool isQueue: false property var listView: "" - property list entryActions - property list defaultActions: [ - Kirigami.Action { - text: i18n("Download") - icon.name: "download" - onTriggered: { - entry.queueStatus = true; - entry.enclosure.download(); - } - visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloadable - }, - Kirigami.Action { - text: i18n("Cancel download") - icon.name: "edit-delete-remove" - onTriggered: entry.enclosure.cancelDownload() - visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading - }, - 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() - } - ] contentItem: RowLayout { Loader { @@ -192,5 +153,44 @@ Kirigami.SwipeListItem { actions = defaultActions; } } + + actions: [ + Kirigami.Action { + text: i18n("Download") + icon.name: "download" + onTriggered: { + entry.queueStatus = true; + entry.enclosure.download(); + } + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloadable + }, + Kirigami.Action { + text: i18n("Cancel download") + icon.name: "edit-delete-remove" + onTriggered: entry.enclosure.cancelDownload() + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading + }, + 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() + } + ] } diff --git a/src/qml/QueuePage.qml b/src/qml/QueuePage.qml index d40ead77..341af314 100644 --- a/src/qml/QueuePage.qml +++ b/src/qml/QueuePage.qml @@ -46,35 +46,6 @@ Kirigami.ScrollablePage { GenericEntryDelegate { isQueue: true listView: queueList - entryActions: [ - Kirigami.Action { - text: i18n("Download") - icon.name: "download" - onTriggered: entry.enclosure.download() - visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloadable - }, - Kirigami.Action { - text: i18n("Cancel download") - icon.name: "edit-delete-remove" - onTriggered: entry.enclosure.cancelDownload() - visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading - }, - Kirigami.Action { - 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() - } - }, - 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() - } - ] } }