From 0d4ddadb150c59185237e77471b9a6d8e6d179eb Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 23 Mar 2021 18:05:43 +0100 Subject: [PATCH] Fix emoji picker appearing in wrong locations --- resources/qml/MessageView.qml | 1 - resources/qml/TimelineView.qml | 11 +++++------ resources/qml/emoji/EmojiPicker.qml | 27 ++++++++++++--------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index cad09475..d418c35e 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -12,7 +12,6 @@ import QtQuick.Window 2.2 import im.nheko 1.0 ScrollView { - contentWidth: availableWidth clip: false palette: colors padding: 8 diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 5732dc73..fca5c366 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -35,8 +35,6 @@ Page { EmojiPicker { id: emojiPopup - width: 7 * 52 + 20 - height: 6 * 52 colors: palette model: EmojiProxyModel { @@ -96,22 +94,23 @@ Page { property string eventId property int eventType property bool isEncrypted - property bool isEditable + property bool isEditable function show(eventId_, eventType_, isEncrypted_, isEditable_, showAt_) { eventId = eventId_; eventType = eventType_; isEncrypted = isEncrypted_; - isEditable = isEditable_; + isEditable = isEditable_; if (showAt_) open(showAt_); else open(); } - Platform.MenuItem { + Platform.MenuItem { + id: reactionOption text: qsTr("React") - onTriggered: emojiPopup.show(messageContextMenu.parent, function(emoji) { + onTriggered: emojiPopup.show(null, function(emoji) { TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji); }) } diff --git a/resources/qml/emoji/EmojiPicker.qml b/resources/qml/emoji/EmojiPicker.qml index 2db9dc07..529a81c1 100644 --- a/resources/qml/emoji/EmojiPicker.qml +++ b/resources/qml/emoji/EmojiPicker.qml @@ -10,7 +10,7 @@ import QtQuick.Layouts 1.3 import im.nheko 1.0 import im.nheko.EmojiModel 1.0 -Popup { +Menu { id: emojiPopup property var callback @@ -24,13 +24,8 @@ Popup { function show(showAt, callback) { console.debug("Showing emojiPicker"); - if (showAt) { - parent = showAt; - x = Math.round((showAt.width - width) / 2); - y = showAt.height; - } emojiPopup.callback = callback; - open(); + popup(showAt ? showAt : null); } margins: 0 @@ -41,23 +36,25 @@ Popup { focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside + height: columnView.implicitHeight + 4 + ColumnLayout { id: columnView - anchors.fill: parent spacing: 0 - Layout.bottomMargin: 0 - Layout.leftMargin: 3 - Layout.rightMargin: 3 - Layout.topMargin: 2 + anchors.leftMargin: 3 + anchors.rightMargin: 3 + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.topMargin: 2 // emoji grid GridView { id: gridView - Layout.preferredHeight: emojiPopup.height - Layout.fillWidth: true - Layout.fillHeight: true + Layout.preferredHeight: cellHeight * 5 + Layout.preferredWidth: 7 * 52 + 20 Layout.leftMargin: 4 cellWidth: 52 cellHeight: 52