From 6e8c3710639643ada346201d2e3a6b99e63a6eeb Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 2 Jul 2020 14:49:02 -0400 Subject: [PATCH] feat: enable adding the clicked emoji to the chat input --- ui/app/AppLayouts/Chat/ChatColumn/ChatButtons.qml | 2 ++ ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml | 7 +++++-- ui/app/AppLayouts/Chat/components/EmojiPopup.qml | 6 ++++-- ui/imports/Emoji.qml | 5 ++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatButtons.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatButtons.qml index 95f332060b..ca27d20197 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatButtons.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatButtons.qml @@ -6,6 +6,7 @@ import "../components" Item { property int iconPadding: 6 + property var addToChat: function () {} id: chatButtonsContainer @@ -149,6 +150,7 @@ Item { height: 440 x: parent.width - width - 8 y: parent.height - sendBtns.height - height - 8 + addToChat: chatButtonsContainer.addToChat } } /*##^## diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml index 0ae15f24d0..90cd365eb8 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml @@ -9,7 +9,7 @@ import "../../../../imports" Rectangle { border.width: 0 - visible: chatsModel.activeChannel.chatType != Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.isMember(profileModel.profile.pubKey) + visible: chatsModel.activeChannel.chatType !== Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.isMember(profileModel.profile.pubKey) Audio { id: sendMessageSound @@ -17,7 +17,7 @@ Rectangle { } function onEnter(event){ - if (event.modifiers == Qt.NoModifier && (event.key == Qt.Key_Enter || event.key == Qt.Key_Return)) { + if (event.modifiers === Qt.NoModifier && (event.key === Qt.Key_Enter || event.key === Qt.Key_Return)) { if(txtData.text.trim().length > 0){ chatsModel.sendMessage(txtData.text.trim()); txtData.text = ""; @@ -65,6 +65,9 @@ Rectangle { Layout.preferredWidth: 30 + Style.current.padding Layout.minimumWidth: 30 + Style.current.padding Layout.maximumWidth: 200 + addToChat: function (text) { + txtData.append(text) + } } } diff --git a/ui/app/AppLayouts/Chat/components/EmojiPopup.qml b/ui/app/AppLayouts/Chat/components/EmojiPopup.qml index c41a3ddd9f..01531cf364 100644 --- a/ui/app/AppLayouts/Chat/components/EmojiPopup.qml +++ b/ui/app/AppLayouts/Chat/components/EmojiPopup.qml @@ -9,6 +9,8 @@ import "../ChatColumn/samples" import "./emojiList.js" as EmojiJSON Popup { + property var addToChat: function () {} + id: popup modal: false property int selectedPackId @@ -79,8 +81,8 @@ Popup { cursorShape: Qt.PointingHandCursor anchors.fill: parent onClicked: { - console.log('SELECT') -// chatsModel.sendSticker(hash, popup.selectedPackId) + const encodedIcon = Emoji.fromCodePoint(filename.replace(".svg", "")) + popup.addToChat(encodedIcon) popup.close() } } diff --git a/ui/imports/Emoji.qml b/ui/imports/Emoji.qml index 81c268a269..823ce3ddb5 100644 --- a/ui/imports/Emoji.qml +++ b/ui/imports/Emoji.qml @@ -11,4 +11,7 @@ QtObject { Twemoji.twemoji.size = size return Twemoji.twemoji.parse(text) } -} \ No newline at end of file + function fromCodePoint(value) { + return Twemoji.twemoji.convert.fromCodePoint(value) + } +}