Fix emoji picker appearing in wrong locations

This commit is contained in:
Nicolas Werner 2021-03-23 18:05:43 +01:00
parent e46ddbbb45
commit 0d4ddadb15
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
3 changed files with 17 additions and 22 deletions

View File

@ -12,7 +12,6 @@ import QtQuick.Window 2.2
import im.nheko 1.0 import im.nheko 1.0
ScrollView { ScrollView {
contentWidth: availableWidth
clip: false clip: false
palette: colors palette: colors
padding: 8 padding: 8

View File

@ -35,8 +35,6 @@ Page {
EmojiPicker { EmojiPicker {
id: emojiPopup id: emojiPopup
width: 7 * 52 + 20
height: 6 * 52
colors: palette colors: palette
model: EmojiProxyModel { model: EmojiProxyModel {
@ -96,22 +94,23 @@ Page {
property string eventId property string eventId
property int eventType property int eventType
property bool isEncrypted property bool isEncrypted
property bool isEditable property bool isEditable
function show(eventId_, eventType_, isEncrypted_, isEditable_, showAt_) { function show(eventId_, eventType_, isEncrypted_, isEditable_, showAt_) {
eventId = eventId_; eventId = eventId_;
eventType = eventType_; eventType = eventType_;
isEncrypted = isEncrypted_; isEncrypted = isEncrypted_;
isEditable = isEditable_; isEditable = isEditable_;
if (showAt_) if (showAt_)
open(showAt_); open(showAt_);
else else
open(); open();
} }
Platform.MenuItem { Platform.MenuItem {
id: reactionOption
text: qsTr("React") text: qsTr("React")
onTriggered: emojiPopup.show(messageContextMenu.parent, function(emoji) { onTriggered: emojiPopup.show(null, function(emoji) {
TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji); TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji);
}) })
} }

View File

@ -10,7 +10,7 @@ import QtQuick.Layouts 1.3
import im.nheko 1.0 import im.nheko 1.0
import im.nheko.EmojiModel 1.0 import im.nheko.EmojiModel 1.0
Popup { Menu {
id: emojiPopup id: emojiPopup
property var callback property var callback
@ -24,13 +24,8 @@ Popup {
function show(showAt, callback) { function show(showAt, callback) {
console.debug("Showing emojiPicker"); console.debug("Showing emojiPicker");
if (showAt) {
parent = showAt;
x = Math.round((showAt.width - width) / 2);
y = showAt.height;
}
emojiPopup.callback = callback; emojiPopup.callback = callback;
open(); popup(showAt ? showAt : null);
} }
margins: 0 margins: 0
@ -41,23 +36,25 @@ Popup {
focus: true focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
height: columnView.implicitHeight + 4
ColumnLayout { ColumnLayout {
id: columnView id: columnView
anchors.fill: parent
spacing: 0 spacing: 0
Layout.bottomMargin: 0 anchors.leftMargin: 3
Layout.leftMargin: 3 anchors.rightMargin: 3
Layout.rightMargin: 3 anchors.bottom: parent.bottom
Layout.topMargin: 2 anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 2
// emoji grid // emoji grid
GridView { GridView {
id: gridView id: gridView
Layout.preferredHeight: emojiPopup.height Layout.preferredHeight: cellHeight * 5
Layout.fillWidth: true Layout.preferredWidth: 7 * 52 + 20
Layout.fillHeight: true
Layout.leftMargin: 4 Layout.leftMargin: 4
cellWidth: 52 cellWidth: 52
cellHeight: 52 cellHeight: 52