UserSearchPage: Move "Enter User ID" action into placeholder

This commit is contained in:
Tobias Fella
2025-08-21 14:51:45 +02:00
parent 8f6683fd1d
commit 1bd39f282e
2 changed files with 21 additions and 10 deletions

View File

@@ -39,16 +39,6 @@ SearchPage {
connection: root.connection
}
listHeaderDelegate: Delegates.RoundedItemDelegate {
onClicked: _private.openManualUserDialog()
activeFocusOnTab: false // We handle moving to this item via up/down arrows, otherwise the tab order is wacky
text: i18n("Enter a user ID")
icon.name: "list-add-user"
icon.width: Kirigami.Units.gridUnit * 2
icon.height: Kirigami.Units.gridUnit * 2
}
modelDelegate: Delegates.RoundedItemDelegate {
id: userDelegate
required property string userId
@@ -92,6 +82,15 @@ SearchPage {
noSearchPlaceholderMessage: i18n("Enter text to start searching for your friends")
noResultPlaceholderMessage: i18nc("@info:label", "No matches found")
noSearchHelpfulAction: noResultHelpfulAction
noResultHelpfulAction: Kirigami.Action {
icon.name: "list-add-user"
text: i18nc("@action:button", "Enter a user ID")
onTriggered: _private.openManualUserDialog()
tooltip: text
}
Component {
id: manualUserDialog
ManualUserDialog {}

View File

@@ -91,6 +91,16 @@ Kirigami.ScrollablePage {
*/
property string customPlaceholderIcon: ""
/**
* @brief Action to be shown in the "no search" placeholder
*/
property Kirigami.Action noSearchHelpfulAction
/**
* @brief Action to be shown in the "no result" placeholder
*/
property Kirigami.Action noResultHelpfulAction
/**
* @brief Force the search field to be focussed.
*/
@@ -179,12 +189,14 @@ Kirigami.ScrollablePage {
id: noSearchMessage
anchors.centerIn: parent
visible: searchField.text.length === 0 && listView.count === 0 && customPlaceholder.text.length === 0
helpfulAction: root.noSearchHelpfulAction
}
Kirigami.PlaceholderMessage {
id: noResultMessage
anchors.centerIn: parent
visible: searchField.text.length > 0 && listView.count === 0 && !root.model.searching && customPlaceholder.text.length === 0
helpfulAction: root.noResultHelpfulAction
}
Kirigami.PlaceholderMessage {