Merge pull request #982 from tastytea/reaction-tooltip

Show long reaction text in tooltip; Remove extra …
This commit is contained in:
DeepBlueV7.X 2022-03-09 17:54:13 +00:00 committed by GitHub
commit 64a939481a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -33,12 +33,19 @@ Flow {
implicitWidth: contentItem.childrenRect.width + contentItem.leftPadding * 2 implicitWidth: contentItem.childrenRect.width + contentItem.leftPadding * 2
implicitHeight: contentItem.childrenRect.height implicitHeight: contentItem.childrenRect.height
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: modelData.users
ToolTip.delay: Nheko.tooltipDelay ToolTip.delay: Nheko.tooltipDelay
onClicked: { onClicked: {
console.debug("Picked " + modelData.key + "in response to " + reactionFlow.eventId + ". selfReactedEvent: " + modelData.selfReactedEvent); console.debug("Picked " + modelData.key + "in response to " + reactionFlow.eventId + ". selfReactedEvent: " + modelData.selfReactedEvent);
room.input.reaction(reactionFlow.eventId, modelData.key); room.input.reaction(reactionFlow.eventId, modelData.key);
} }
Component.onCompleted: {
ToolTip.text = Qt.binding(function() {
if (textMetrics.elidedText === textMetrics.text) {
return modelData.users;
}
return modelData.displayKey + "\n" + modelData.users;
})
}
contentItem: Row { contentItem: Row {
anchors.centerIn: parent anchors.centerIn: parent
@ -59,7 +66,15 @@ Flow {
id: reactionText id: reactionText
anchors.baseline: reactionCounter.baseline anchors.baseline: reactionCounter.baseline
text: textMetrics.elidedText + (textMetrics.elidedText == modelData.displayKey ? "" : "…") text: {
// When an emoji font is selected that doesn't have , it is dropped from elidedText. So we add it back.
if (textMetrics.elidedText !== modelData.displayKey) {
if (!textMetrics.elidedText.endsWith("…")) {
return textMetrics.elidedText + "…";
}
}
return textMetrics.elidedText;
}
font.family: Settings.emojiFont font.family: Settings.emojiFont
color: reaction.hovered ? Nheko.colors.highlight : Nheko.colors.text color: reaction.hovered ? Nheko.colors.highlight : Nheko.colors.text
maximumLineCount: 1 maximumLineCount: 1