Attach emoji picker picked to reaction sender

This commit is contained in:
Joseph Donofry 2020-05-16 15:52:51 -04:00
parent a5778bdf40
commit f4ea0b215d
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB
4 changed files with 21 additions and 4 deletions

View file

@ -87,6 +87,8 @@ MouseArea {
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: qsTr("React") ToolTip.text: qsTr("React")
emojiPicker: emojiPopup emojiPicker: emojiPopup
room_id: model.roomId
event_id: model.id
// onClicked: chat.model.reactAction(model.id) // onClicked: chat.model.reactAction(model.id)
} }
ImageButton { ImageButton {

View file

@ -46,6 +46,9 @@ Page {
category: Emoji.Category.People category: Emoji.Category.People
sourceModel: EmojiModel {} sourceModel: EmojiModel {}
} }
Component.onCompleted: {
emojiPopup.picked.connect(timelineManager.queueReactionMessage)
}
} }
Menu { Menu {

View file

@ -8,9 +8,11 @@ import "../"
ImageButton { ImageButton {
property var colors: currentActivePalette property var colors: currentActivePalette
property var emojiPicker property var emojiPicker
property string room_id
property string event_id
image: ":/icons/icons/ui/smile.png" image: ":/icons/icons/ui/smile.png"
id: emojiButton id: emojiButton
onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton) onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, room_id, event_id)
} }

View file

@ -10,12 +10,19 @@ import "../"
Popup { Popup {
function show(showAt) { function show(showAt, room_id, event_id) {
console.debug("Showing emojiPicker for " + event_id + "in room " + room_id)
parent = showAt parent = showAt
x = Math.round((showAt.width - width) / 2) x = Math.round((showAt.width - width) / 2)
y = showAt.height y = showAt.height
emojiPopup.room_id = room_id
emojiPopup.event_id = event_id
open() open()
} }
signal picked(string room_id, string event_id, string key)
property string room_id
property string event_id
property var colors property var colors
property alias model: gridView.model property alias model: gridView.model
property var textArea property var textArea
@ -80,7 +87,7 @@ Popup {
ToolTip.text: model.shortName ToolTip.text: model.shortName
ToolTip.visible: hovered ToolTip.visible: hovered
// give the emoji a little oomf // give the emoji a little oomf
DropShadow { DropShadow {
width: parent.width; width: parent.width;
height: parent.height; height: parent.height;
@ -92,7 +99,10 @@ Popup {
source: parent.contentItem source: parent.contentItem
} }
// TODO: emit a signal and maybe add favorites at some point? // TODO: emit a signal and maybe add favorites at some point?
//onClicked: textArea.insert(textArea.cursorPosition, modelData.unicode) onClicked: {
console.debug("Picked " + model.unicode + "in response to " + emojiPopup.event_id + " in room " + emojiPopup.room_id)
emojiPopup.picked(emojiPopup.room_id, emojiPopup.event_id, model.unicode)
}
} }
// Search field // Search field