Improve contextual actions for the FeedList and EntryLists

This adds "select all", "deselect all" to the page contextual actions
and adds "show podcast info" to the OverlayPage opened by clicking on
the overflow menu button on the cards.
This also adds correct use of plurals for the actions if more than one
item has been selected.
This commit is contained in:
Bart De Vries 2021-09-29 08:36:17 +02:00
parent e1c80bff3d
commit f0f4da8aa7
3 changed files with 39 additions and 11 deletions

View File

@ -246,17 +246,26 @@ Controls.ItemDelegate {
header: Kirigami.Heading { header: Kirigami.Heading {
text: feed.name text: feed.name
level: 2 level: 2
wrapMode: Text.Wrap elide: Text.ElideRight
} }
contentItem: ColumnLayout { contentItem: ColumnLayout {
RowLayout { Kirigami.BasicListItem {
Layout.preferredWidth: Kirigami.Units.gridUnit * 20 Layout.fillWidth: true
spacing: 0 leftPadding: Kirigami.Units.smallSpacing
rightPadding: 0
onClicked: {
while(pageStack.depth > 1)
pageStack.pop()
pageStack.push("qrc:/FeedDetailsPage.qml", {"feed": feed});
actionOverlay.close();
}
icon: "help-about-symbolic"
text: i18n("Podcast Details")
}
Kirigami.BasicListItem { Kirigami.BasicListItem {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
leftPadding: Kirigami.Units.smallSpacing leftPadding: Kirigami.Units.smallSpacing
rightPadding: 0 rightPadding: 0
onClicked: { onClicked: {
@ -269,7 +278,6 @@ Controls.ItemDelegate {
icon: "delete" icon: "delete"
text: i18n("Remove Podcast") text: i18n("Remove Podcast")
} }
}
} }
} }

View File

@ -226,9 +226,27 @@ Kirigami.ScrollablePage {
// For lack of a better place, we put generic entry list actions here so // For lack of a better place, we put generic entry list actions here so
// they can be re-used across the different ListViews. // they can be re-used across the different ListViews.
property var selectAllAction: Kirigami.Action {
iconName: "edit-select-all"
text: i18n("Select All")
visible: true
onTriggered: {
feedList.selectionModel.select(feedList.model.index(0, 0), ItemSelectionModel.ClearAndSelect | ItemSelectionModel.Columns);
}
}
property var selectNoneAction: Kirigami.Action {
iconName: "edit-select-none"
text: i18n("Deselect All")
visible: feedList.selectionModel.hasSelection
onTriggered: {
feedList.selectionModel.clearSelection();
}
}
property var deleteFeedAction: Kirigami.Action { property var deleteFeedAction: Kirigami.Action {
iconName: "delete" iconName: "delete"
text: i18n("Remove Podcast") text: i18np("Remove Podcast", "Remove Podcasts", feedList.selectionForContextMenu.length)
visible: feedList.selectionModel.hasSelection visible: feedList.selectionModel.hasSelection
onTriggered: { onTriggered: {
// First get an array of pointers to the feeds to be deleted // First get an array of pointers to the feeds to be deleted
@ -255,13 +273,15 @@ Kirigami.ScrollablePage {
visible: feedList.selectionModel.hasSelection && (feedList.selectionForContextMenu.length == 1) visible: feedList.selectionModel.hasSelection && (feedList.selectionForContextMenu.length == 1)
onTriggered: { onTriggered: {
while(pageStack.depth > 1) while(pageStack.depth > 1)
pageStack.pop() pageStack.pop();
pageStack.push("qrc:/FeedDetailsPage.qml", {"feed": feedList.selectionForContextMenu[0].model.data(feedList.selectionForContextMenu[0], FeedsModel.FeedRole)}) pageStack.push("qrc:/FeedDetailsPage.qml", {"feed": feedList.selectionForContextMenu[0].model.data(feedList.selectionForContextMenu[0], FeedsModel.FeedRole)});
} }
} }
property var contextualActionList: [feedDetailsAction, property var contextualActionList: [feedDetailsAction,
deleteFeedAction] deleteFeedAction,
selectAllAction,
selectNoneAction]
property Controls.Menu contextMenu: Controls.Menu { property Controls.Menu contextMenu: Controls.Menu {
id: contextMenu id: contextMenu

View File

@ -204,7 +204,7 @@ ListView {
} }
property var deleteEnclosureAction: Kirigami.Action { property var deleteEnclosureAction: Kirigami.Action {
text: i18n("Delete Download") text: i18np("Delete Download", "Delete Downloads", selectionForContextMenu.length)
icon.name: "delete" icon.name: "delete"
visible: listView.selectionModel.hasSelection && (singleSelectedEntry ? (singleSelectedEntry.hasEnclosure ? singleSelectedEntry.enclosure.status !== Enclosure.Downloadable : false) : true) visible: listView.selectionModel.hasSelection && (singleSelectedEntry ? (singleSelectedEntry.hasEnclosure ? singleSelectedEntry.enclosure.status !== Enclosure.Downloadable : false) : true)
onTriggered: { onTriggered: {