Consolidate all EntryDelegate actions

QueueDelegates and EntryListDelegates are now using the same actions
defined in GenericEntryDelegate.
This commit is contained in:
Bart De Vries 2021-04-17 20:15:14 +02:00
parent 1ceb5532b2
commit 07afc98978
3 changed files with 39 additions and 106 deletions

View File

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

View File

@ -19,45 +19,6 @@ Kirigami.SwipeListItem {
property bool isQueue: false
property var listView: ""
property list<Controls.Action> entryActions
property list<Controls.Action> 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()
}
]
}

View File

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