diff options
author | DeepBlueV7.X <nicolas.werner@hotmail.de> | 2022-03-09 17:54:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-09 17:54:13 +0000 |
commit | 64a939481a34017e8739c526e3e51487cdd990f5 (patch) | |
tree | fcf731405ccf7100c682ee3cedc0d337e1bd51d4 | |
parent | 5b09dd1a112d9910e0fa032f5708fc32d4cd0682 (diff) | |
parent | ddf749d3a2fda3bcc203c481faf329bbb635622d (diff) |
Merge pull request #982 from tastytea/reaction-tooltip
Show long reaction text in tooltip; Remove extra …
-rw-r--r-- | resources/qml/Reactions.qml | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml index 63115ec0..cb2bcb24 100644 --- a/resources/qml/Reactions.qml +++ b/resources/qml/Reactions.qml @@ -33,12 +33,19 @@ Flow { implicitWidth: contentItem.childrenRect.width + contentItem.leftPadding * 2 implicitHeight: contentItem.childrenRect.height ToolTip.visible: hovered - ToolTip.text: modelData.users ToolTip.delay: Nheko.tooltipDelay onClicked: { console.debug("Picked " + modelData.key + "in response to " + reactionFlow.eventId + ". selfReactedEvent: " + modelData.selfReactedEvent); 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 { anchors.centerIn: parent @@ -59,7 +66,15 @@ Flow { id: reactionText 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 color: reaction.hovered ? Nheko.colors.highlight : Nheko.colors.text maximumLineCount: 1 |