From e2113553b98f1ad70b277ca30cf443ee30ef19d0 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 22 Mar 2021 15:46:50 +0100 Subject: [PATCH] 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). --- .../PrivateChatPopupSearchResults.qml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/app/AppLayouts/Chat/components/PrivateChatPopupSearchResults.qml b/ui/app/AppLayouts/Chat/components/PrivateChatPopupSearchResults.qml index faa6769b98..3ba2bab726 100644 --- a/ui/app/AppLayouts/Chat/components/PrivateChatPopupSearchResults.qml +++ b/ui/app/AppLayouts/Chat/components/PrivateChatPopupSearchResults.qml @@ -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 {