summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-11-16 18:41:29 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-11-25 19:05:12 +0100
commit82c441dddd9d57f858c62c9fd3c8718d44ca3d7b (patch)
tree757ceef955e6e7574a25dd4f874a69f0ee0dcddb /resources
parentUse old style connection (for Qt5.12) (diff)
downloadnheko-82c441dddd9d57f858c62c9fd3c8718d44ca3d7b.tar.xz
Move emoji picker to qml
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/MessageInput.qml8
-rw-r--r--resources/qml/TimelineView.qml4
-rw-r--r--resources/qml/emoji/EmojiButton.qml4
-rw-r--r--resources/qml/emoji/EmojiPicker.qml12
4 files changed, 18 insertions, 10 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml

index e9f3a6b9..da76c6ac 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml
@@ -88,8 +88,7 @@ Rectangle { } Connections { - onInsertText: textArea.insert(textArea.cursorPosition, text); - + onInsertText: textArea.insert(textArea.cursorPosition, text) target: TimelineManager.timeline.input } @@ -110,6 +109,8 @@ Rectangle { } ImageButton { + id: emojiButton + Layout.alignment: Qt.AlignRight | Qt.AlignBottom hoverEnabled: true width: 22 @@ -119,6 +120,9 @@ Rectangle { Layout.bottomMargin: 8 ToolTip.visible: hovered ToolTip.text: qsTr("Emoji") + onClicked: emojiPopup.visible ? emojiPopup.close() : emojiPopup.show(emojiButton, function(emoji) { + textArea.insert(textArea.cursorPosition, emoji); + }) } ImageButton { diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 5fce0846..c23564c1 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml
@@ -72,7 +72,9 @@ Page { MenuItem { text: qsTr("React") - onClicked: emojiPopup.show(messageContextMenu.parent, messageContextMenu.eventId) + onClicked: emojiPopup.show(messageContextMenu.parent, function(emoji) { + TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji); + }) } MenuItem { diff --git a/resources/qml/emoji/EmojiButton.qml b/resources/qml/emoji/EmojiButton.qml
index 1fcfc0c5..928d6226 100644 --- a/resources/qml/emoji/EmojiButton.qml +++ b/resources/qml/emoji/EmojiButton.qml
@@ -12,5 +12,7 @@ ImageButton { property string event_id image: ":/icons/icons/ui/smile.png" - onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, event_id) + onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, function(emoji) { + TimelineManager.queueReactionMessage(event_id, emoji); + }) } diff --git a/resources/qml/emoji/EmojiPicker.qml b/resources/qml/emoji/EmojiPicker.qml
index afe16350..e0e1ceaf 100644 --- a/resources/qml/emoji/EmojiPicker.qml +++ b/resources/qml/emoji/EmojiPicker.qml
@@ -9,7 +9,7 @@ import im.nheko.EmojiModel 1.0 Popup { id: emojiPopup - property string event_id + property var callback property var colors property alias model: gridView.model property var textArea @@ -18,14 +18,14 @@ Popup { property real highlightSat: colors.highlight.hslSaturation property real highlightLight: colors.highlight.hslLightness - function show(showAt, event_id) { - console.debug("Showing emojiPicker for " + event_id); + function show(showAt, callback) { + console.debug("Showing emojiPicker"); if (showAt) { parent = showAt; x = Math.round((showAt.width - width) / 2); y = showAt.height; } - emojiPopup.event_id = event_id; + emojiPopup.callback = callback; open(); } @@ -70,9 +70,9 @@ Popup { ToolTip.visible: hovered // TODO: maybe add favorites at some point? onClicked: { - console.debug("Picked " + model.unicode + "in response to " + emojiPopup.event_id); + console.debug("Picked " + model.unicode); emojiPopup.close(); - TimelineManager.queueReactionMessage(emojiPopup.event_id, model.unicode); + callback(model.unicode); } // give the emoji a little oomf