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
This commit is contained in:
Jonathan Rainville 2022-02-22 09:54:26 -05:00 committed by r4bbit.eth
parent 07a5dc09ac
commit 8495fae8a5
3 changed files with 12 additions and 4 deletions

View File

@ -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<Item> 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

View File

@ -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);
}
}
}

View File

@ -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"