feat(PrivateChatPopupSearchResults): introduce reset() and config API

This commit introduces a `reset()` function so that search results inside
the application can be easily reset. It also introduces a `resultClickable`
flag which allows consumers of this component to decide whether a search result
is clickable and emits a dedicated event.

This is useful when UIs should only allow actions via the result icon button
(as it's the case with the new add-to-contact modal).
This commit is contained in:
Pascal Precht 2021-03-22 15:46:50 +01:00 committed by Iuri Matias
parent 20d0d162b5
commit e2113553b9
1 changed files with 16 additions and 2 deletions

View File

@ -16,9 +16,19 @@ Item {
property string username: ""
property string userAlias: ""
property string pubKey: ""
property bool resultClickable: true
signal resultClicked(string pubKey)
signal addToContactsButtonClicked(string pubKey)
function reset() {
hasExistingContacts = false
showProfileNotFoundMessage = false
username = ""
userAlias = ""
pubKey = ""
}
width: parent.width
StyledText {
@ -82,12 +92,16 @@ Item {
}
MouseArea {
cursorShape: Qt.PointingHandCursor
cursorShape: root.resultClickable ? Qt.PointingHandCursor : Qt.ArrowCursor
anchors.fill: parent
hoverEnabled: true
onEntered: foundContact.hovered = true
onExited: foundContact.hovered = false
onClicked: root.resultClicked(root.pubKey)
onClicked: {
if (root.resultClickable) {
root.resultClicked(root.pubKey)
}
}
}
StatusIconButton {