From b82b724795f4f35401e5b8d669b6582a78cef4ac Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 9 Mar 2022 10:25:23 +0100 Subject: [PATCH 1/2] Show long reaction text in tooltip If the reaction text is elided, it will be shown in the tooltip. --- resources/qml/Reactions.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml index 63115ec0..f79cfe73 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 From ddf749d3a2fda3bcc203c481faf329bbb635622d Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 9 Mar 2022 18:37:50 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Remove=20extra=20=E2=80=A6=20from=20reactio?= =?UTF-8?q?n=20text=20if=20it=20is=20already=20there?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit elidedText should have … in it if the text doesn't fit, but it seems that it is omitted if the emoji font doesn't have it. 🙄 See . --- resources/qml/Reactions.qml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml index f79cfe73..cb2bcb24 100644 --- a/resources/qml/Reactions.qml +++ b/resources/qml/Reactions.qml @@ -66,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