Expand FeedListPage PlaceholderMessage with helpful actions

This commit is contained in:
Bart De Vries 2023-04-26 16:28:05 +02:00
parent cbf2888754
commit caff8da25f
1 changed files with 64 additions and 11 deletions

View File

@ -50,13 +50,15 @@ Kirigami.ScrollablePage {
onTriggered: refreshing = true onTriggered: refreshing = true
}, },
Kirigami.Action { Kirigami.Action {
text: i18nc("@action:intoolbar", "Add Podcast") id: addAction
text: i18nc("@action:intoolbar", "Add Podcast...")
icon.name: "list-add" icon.name: "list-add"
onTriggered: { onTriggered: {
addSheet.open() addSheet.open()
} }
}, },
Kirigami.Action { Kirigami.Action {
id: importAction
text: i18nc("@action:intoolbar", "Import Podcasts...") text: i18nc("@action:intoolbar", "Import Podcasts...")
icon.name: "document-import" icon.name: "document-import"
displayHint: Kirigami.DisplayHint.AlwaysHide displayHint: Kirigami.DisplayHint.AlwaysHide
@ -85,18 +87,11 @@ Kirigami.ScrollablePage {
id: addSheet id: addSheet
} }
Kirigami.PlaceholderMessage {
visible: feedList.count === 0
width: Kirigami.Units.gridUnit * 20
anchors.centerIn: parent
text: i18nc("@info Placeholder message for empty podcast list", "No Podcasts Added Yet")
}
FileDialog { FileDialog {
id: importDialog id: importDialog
title: i18nc("@title:window", "Import Podcasts") title: i18nc("@title:window", "Import Podcasts")
folder: StandardPaths.writableLocation(StandardPaths.HomeLocation) folder: StandardPaths.writableLocation(StandardPaths.HomeLocation)
nameFilters: [i18nc("@label:listbox File filter option in file dialog", "All Files (*)"), i18nc("@label:listbox File filter option in file dialog", "XML Files (*.xml)"), i18nc("@label:listbox File filter option in file dialog", "OPML Files (*.opml)")] nameFilters: [i18nc("@label:listbox File filter option in file dialog", "OPML Files (*.opml)"), i18nc("@label:listbox File filter option in file dialog", "XML Files (*.xml)"), i18nc("@label:listbox File filter option in file dialog", "All Files (*)")]
onAccepted: DataManager.importFeeds(file) onAccepted: DataManager.importFeeds(file)
} }
@ -104,7 +99,7 @@ Kirigami.ScrollablePage {
id: exportDialog id: exportDialog
title: i18nc("@title:window", "Export Podcasts") title: i18nc("@title:window", "Export Podcasts")
folder: StandardPaths.writableLocation(StandardPaths.HomeLocation) folder: StandardPaths.writableLocation(StandardPaths.HomeLocation)
nameFilters: [i18nc("@label:listbox File filter option in file dialog", "All Files")] nameFilters: [i18nc("@label:listbox File filter option in file dialog", "OPML Files (*.opml)"), i18nc("@label:listbox File filter option in file dialog", "All Files (*)")]
onAccepted: DataManager.exportFeeds(file) onAccepted: DataManager.exportFeeds(file)
fileMode: FileDialog.SaveFile fileMode: FileDialog.SaveFile
} }
@ -112,9 +107,67 @@ Kirigami.ScrollablePage {
GridView { GridView {
id: feedList id: feedList
currentIndex: -1 currentIndex: -1
visible: count !== 0
clip: true clip: true
Kirigami.PlaceholderMessage {
id: placeholderMessage
visible: feedList.count === 0
width: Kirigami.Units.gridUnit * 20
anchors.centerIn: parent
type: Kirigami.PlaceholderMessage.Actionable
text: i18nc("@info Placeholder message for empty podcast list", "No podcasts added yet")
explanation: i18nc("@info:tipoftheday", "Get started by adding podcasts:")
readonly property int buttonSize: Math.max(discoverButton.implicitWidth, addButton.implicitWidth, importButton.implicitWidth, syncButton.implicitWidth)
// These actions are also in the toolbar, but duplicating some here
// to give them more descriptive names
Controls.Button {
id: discoverButton
Layout.preferredWidth: placeholderMessage.buttonSize
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: Kirigami.Units.gridUnit
action: Kirigami.Action {
icon.name: "search"
text: i18nc("@action:button", "Search Online")
onTriggered: pushPage("DiscoverPage")
}
}
Controls.Button {
id: addButton
Layout.preferredWidth: placeholderMessage.buttonSize
Layout.alignment: Qt.AlignHCenter
action: addAction
}
Controls.Button {
id: importButton
Layout.preferredWidth: placeholderMessage.buttonSize
Layout.alignment: Qt.AlignHCenter
action: importAction
}
Controls.Button {
id: syncButton
Layout.preferredWidth: placeholderMessage.buttonSize
Layout.alignment: Qt.AlignHCenter
action: Kirigami.Action {
text: i18nc("@action:button", "Synchronize")
icon.name: "state-sync"
onTriggered: {
// not using pushPage here in order to open the sync page
// directly
pageStack.layers.clear()
pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {
defaultPage: "Synchronization" }, {
title: i18n("Settings"),
})
}
}
}
}
property int minimumCardSize: 150 property int minimumCardSize: 150
property int cardMargin: Kirigami.Units.largeSpacing property int cardMargin: Kirigami.Units.largeSpacing
// In order to account for the scrollbar popping up and creating a // In order to account for the scrollbar popping up and creating a