mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-07-19 15:05:40 +02:00
Emoji Picker: correct position
GitLab: #1431 Change-Id: I5d86598da3120df5b34b375e1019bb0d0c8d88f0
This commit is contained in:
parent
74120737ca
commit
c72e847bd4
1 changed files with 23 additions and 6 deletions
|
@ -40,7 +40,7 @@ BaseContextMenu {
|
|||
property bool closeWithoutAnimation: false
|
||||
property var emojiPicker
|
||||
|
||||
function xPositionProvider(width) {
|
||||
function xPosition(width) {
|
||||
// Use the width at function scope to retrigger property evaluation.
|
||||
const listViewWidth = listView.width;
|
||||
const parentX = parent.x;
|
||||
|
@ -51,9 +51,30 @@ BaseContextMenu {
|
|||
}
|
||||
}
|
||||
|
||||
x: xPositionProvider(width)
|
||||
x: xPosition(width)
|
||||
y: parent.y
|
||||
|
||||
function xPositionProvider(width) {
|
||||
// Use the width at function scope to retrigger property evaluation.
|
||||
const listViewWidth = listView.width;
|
||||
if (isOutgoing) {
|
||||
return -5 - width;
|
||||
} else {
|
||||
const rightMargin = listViewWidth - (msgBubble.x + width);
|
||||
return width > rightMargin + 35 ? -5 - width : 35;
|
||||
}
|
||||
}
|
||||
function yPositionProvider(height) {
|
||||
const topOffset = msgBubble.mapToItem(listView, 0, 0).y;
|
||||
const listViewHeight = listView.height;
|
||||
const bottomMargin = listViewHeight - height - topOffset;
|
||||
if (bottomMargin < 0 || (topOffset < 0 && topOffset + height > 0)) {
|
||||
return 30 - height;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
signal addMoreEmoji
|
||||
onAddMoreEmoji: {
|
||||
JamiQmlUtils.updateMessageBarButtonsPoints();
|
||||
|
@ -74,7 +95,6 @@ BaseContextMenu {
|
|||
});
|
||||
if (emojiPicker !== null) {
|
||||
root.opacity = 0;
|
||||
emojiPicker.closed.connect(() => close());
|
||||
emojiPicker.x = xPositionProvider(JamiTheme.emojiPickerWidth);
|
||||
emojiPicker.y = yPositionProvider(JamiTheme.emojiPickerHeight);
|
||||
emojiPicker.open();
|
||||
|
@ -83,11 +103,8 @@ BaseContextMenu {
|
|||
}
|
||||
}
|
||||
|
||||
// Close the picker when listView vertical properties change.
|
||||
property real listViewHeight: listView.height
|
||||
onListViewHeightChanged: close()
|
||||
property bool isScrolling: listView.verticalScrollBar.active
|
||||
onIsScrollingChanged: close()
|
||||
|
||||
onOpened: root.closeWithoutAnimation = false
|
||||
onClosed: if (emojiPicker)
|
||||
|
|
Loading…
Add table
Reference in a new issue