From 8c69e04e83fdeff2e422103ae42aa7dc531166a2 Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Tue, 27 Oct 2020 21:42:39 +0100 Subject: [PATCH] Fix emoji paths for chat information Items --- .../ChatInformationTabItemMembersGroups.qml | 8 ++++---- .../chatInformationPage/ChatInformationTextItem.qml | 2 +- qml/js/twemoji.js | 4 ++-- qml/pages/ChatInformationPage.qml | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml b/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml index 7077a61..d078191 100644 --- a/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml +++ b/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml @@ -79,18 +79,18 @@ ChatInformationTabItemBase { width: parent.width // chat title isPrivateChat ? () : - primaryText.text: Emoji.emojify(Functions.getUserName(user), primaryText.font.pixelSize) + primaryText.text: Emoji.emojify(Functions.getUserName(user), primaryText.font.pixelSize, "../../js/emoji/") // last user prologSecondaryText.text: "@"+(user.username !== "" ? user.username : user_id) + (user_id === chatInformationPage.myUserId ? " " + qsTr("You") : "") secondaryText { horizontalAlignment: Text.AlignRight property string statusText: Functions.getChatMemberStatusText(model.status["@type"]) - property string customText: model.status.custom_title ? Emoji.emojify(model.status.custom_title, secondaryText.font.pixelSize) : "" + property string customText: model.status.custom_title ? Emoji.emojify(model.status.custom_title, secondaryText.font.pixelSize, "../../js/emoji/") : "" text: (statusText !== "" && customText !== "") ? statusText + ", " + customText : statusText + customText } tertiaryText { maximumLineCount: 1 - text: user.type["@type"] === "userTypeBot" ? (Emoji.emojify("🤖 "+bot_info.description, tertiaryText.font.pixelSize)) : Functions.getChatPartnerStatusText(user.status["@type"], user.status.was_online); + text: user.type["@type"] === "userTypeBot" ? (Emoji.emojify("🤖 "+bot_info.description, tertiaryText.font.pixelSize, "../../js/emoji/")) : Functions.getChatPartnerStatusText(user.status["@type"], user.status.was_online); elide: Text.ElideRight } @@ -162,7 +162,7 @@ ChatInformationTabItemBase { onChatChanged: { if (changedChatId === chat_id) { // Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :( - secondaryText.text = last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall) : qsTr("Unknown") + secondaryText.text = last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall, "../../js/emoji/") : qsTr("Unknown") } } } diff --git a/qml/components/chatInformationPage/ChatInformationTextItem.qml b/qml/components/chatInformationPage/ChatInformationTextItem.qml index 4cffc6e..edb52bb 100644 --- a/qml/components/chatInformationPage/ChatInformationTextItem.qml +++ b/qml/components/chatInformationPage/ChatInformationTextItem.qml @@ -50,7 +50,7 @@ Column { font.pixelSize: Theme.fontSizeExtraSmall textFormat: Text.StyledText color: Theme.highlightColor - text: Emoji.emojify( Functions.replaceUrlsWithLinks(textItem.text).replace(/\n/g, "
"), Theme.fontSizeExtraSmall).replace(/\.\.\/js/g, "../../js") + text: Emoji.emojify( Functions.replaceUrlsWithLinks(textItem.text).replace(/\n/g, "
"), Theme.fontSizeExtraSmall, "../../js/emoji/") linkColor: Theme.primaryColor visible: text !== "" onLinkActivated: { diff --git a/qml/js/twemoji.js b/qml/js/twemoji.js index abfce8f..446931a 100644 --- a/qml/js/twemoji.js +++ b/qml/js/twemoji.js @@ -568,8 +568,8 @@ var twemoji = (function ( }()); -function emojify(rawText, emojiSize) { - var curatedText = twemoji.parse(rawText, { callback: function(icon, options, variant) { return '../js/emoji/' + icon + '.svg'; }, size: emojiSize }); +function emojify(rawText, emojiSize, basePath) { + var curatedText = twemoji.parse(rawText, { callback: function(icon, options, variant) { return (basePath || '../js/emoji/') + icon + '.svg'; }, size: emojiSize }); // QML has a weird bug. If an ampersand is followed by an HTML tag or a character, the tag is ignored and returned as string or the following string is omitted // Therefore replacing the ampersand with & in these cases... return curatedText.replace(/((\&[\w\d]+\;)|((\&)(\<|\w+)))/g, function(match, p1, p2, p3, p4, p5, offset, string) { diff --git a/qml/pages/ChatInformationPage.qml b/qml/pages/ChatInformationPage.qml index 79e3376..0bbe1e1 100644 --- a/qml/pages/ChatInformationPage.qml +++ b/qml/pages/ChatInformationPage.qml @@ -265,8 +265,10 @@ Page { : "../components/chatInformationPage/ChatInformationProfilePicture.qml" } } + // PageHeader changes the html base path: + property url emojiBase: "../js/emoji/" leftMargin: imageContainer.minDimension + Theme.horizontalPageMargin + Theme.paddingMedium - title: chatInformation.title !== "" ? Emoji.emojify(chatInformation.title, Theme.fontSizeLarge) : qsTr("Unknown") + title: chatInformation.title !== "" ? Emoji.emojify(chatInformation.title, Theme.fontSizeLarge, emojiBase) : qsTr("Unknown") description: chatInformationPage.isPrivateChat ? ("@"+(chatInformationPage.privateChatUserInformation.username || chatInformationPage.chatPartnerGroupId)) : "" }