From ee18ab89ddae705dd7fa22b541c55fbd02827ecd Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 22 Feb 2022 09:54:26 -0500 Subject: [PATCH] fix(StatusListItem): add propagateTitleClicks property to StatusListItem Makes it possible disable the propagation of the mouse event when it's not wanted, for example in the search popup, where if the user clicks the title, we want to show the profile popup, but not navigate to the channel --- ui/StatusQ/src/StatusQ/Components/StatusListItem.qml | 3 ++- .../src/StatusQ/Popups/StatusSearchLocationMenu.qml | 5 +++-- ui/StatusQ/src/StatusQ/Popups/StatusSearchPopup.qml | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ui/StatusQ/src/StatusQ/Components/StatusListItem.qml b/ui/StatusQ/src/StatusQ/Components/StatusListItem.qml index 61f48e3512..d831360d5b 100644 --- a/ui/StatusQ/src/StatusQ/Components/StatusListItem.qml +++ b/ui/StatusQ/src/StatusQ/Components/StatusListItem.qml @@ -20,6 +20,7 @@ Rectangle { property real rightPadding: 16 property bool enabled: true property bool highlighted: false + property bool propagateTitleClicks: true property int type: StatusListItem.Type.Primary property list components @@ -175,7 +176,7 @@ Rectangle { anchors.fill: parent cursorShape: containsMouse? Qt.PointingHandCursor : Qt.ArrowCursor hoverEnabled: true - propagateComposedEvents: true + propagateComposedEvents: statusListItem.propagateTitleClicks onClicked: { statusListItem.titleClicked(statusListItem.titleId) mouse.accepted = false diff --git a/ui/StatusQ/src/StatusQ/Popups/StatusSearchLocationMenu.qml b/ui/StatusQ/src/StatusQ/Popups/StatusSearchLocationMenu.qml index ba6dcf357c..d488b39c7d 100644 --- a/ui/StatusQ/src/StatusQ/Popups/StatusSearchLocationMenu.qml +++ b/ui/StatusQ/src/StatusQ/Popups/StatusSearchLocationMenu.qml @@ -10,6 +10,7 @@ StatusPopupMenu { property var searchPopup property var locationModel + readonly property int numDefaultItems: 2 signal itemClicked(string firstLevelItemValue, string secondLevelItemValue) @@ -43,7 +44,7 @@ StatusPopupMenu { color: model.iconColor, isLetterIdenticon: !model.imageSource && !model.iconName }); - root.insertMenu(index+2, item); + root.insertMenu(index + numDefaultItems, item); } else { item.value = model.value item.text = model.title; @@ -52,7 +53,7 @@ StatusPopupMenu { item.iconSettings.isLetterIdenticon = !model.imageSource && !model.iconName item.image.source = model.imageSource; item.image.isIdenticon = model.isIdenticon; - root.insertItem(index+2, item); + root.insertItem(index + numDefaultItems, item); } } } diff --git a/ui/StatusQ/src/StatusQ/Popups/StatusSearchPopup.qml b/ui/StatusQ/src/StatusQ/Popups/StatusSearchPopup.qml index c932d8eabe..0eb6aa105b 100644 --- a/ui/StatusQ/src/StatusQ/Popups/StatusSearchPopup.qml +++ b/ui/StatusQ/src/StatusQ/Popups/StatusSearchPopup.qml @@ -24,6 +24,9 @@ StatusModal { property Menu searchOptionsPopupMenu: Menu { } property var searchResults: [ ] property var searchSelectionButton + // This function is called to know if the popup accepts clicks in the title + // If it does not, the clicks on the titles mousearea will be propagated to the main body instead + property var acceptsTitleClick: function(titleId) {return true} signal resultItemClicked(string itemId) signal resultItemTitleClicked(string titleId) @@ -275,8 +278,11 @@ StatusModal { root.resultItemClicked(itemId) } + propagateTitleClicks: !root.acceptsTitleClick(titleId) onTitleClicked: { - root.resultItemTitleClicked(titleId) + if (root.acceptsTitleClick(titleId)) { + root.resultItemTitleClicked(titleId) + } } } section.property: "sectionName"