From f40797af3b2d4829bf1000e657d21655baeff997 Mon Sep 17 00:00:00 2001 From: gaelle Date: Fri, 15 Nov 2024 15:47:49 +0100 Subject: [PATCH] fix notif coordinates --- Linphone/core/notifier/Notifier.cpp | 33 ++++++++++++------- .../Notification/NotificationReceivedCall.qml | 7 ++-- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Linphone/core/notifier/Notifier.cpp b/Linphone/core/notifier/Notifier.cpp index 0dce0c260..888128ea5 100644 --- a/Linphone/core/notifier/Notifier.cpp +++ b/Linphone/core/notifier/Notifier.cpp @@ -169,19 +169,28 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d window->setProperty(NotificationPropertyData, data); // for (auto it = data.begin(); it != data.end(); ++it) // window->setProperty(it.key().toLatin1(), it.value()); - int *screenHeightOffset = &mScreenHeightOffset[screen->name()]; // Access optimization - QRect availableGeometry = screen->availableGeometry(); - int heightOffset = - availableGeometry.y() + - (availableGeometry.height() - - window->height()); //*screen->devicePixelRatio(); when using manual scaler - - window->setX(availableGeometry.x() + - (availableGeometry.width() - - window->property("width") - .toInt())); //*screen->devicePixelRatio()); when using manual scaler - window->setY(heightOffset - (*screenHeightOffset % heightOffset)); const int timeout = Notifications[type].getTimeout() * 1000; + auto updateNotificationCoordinates = [this, window, screen](int width, int height) { + int *screenHeightOffset = &mScreenHeightOffset[screen->name()]; // Access optimization + QRect availableGeometry = screen->availableGeometry(); + int heightOffset = availableGeometry.y() + + (availableGeometry.height() - + height); //*screen->devicePixelRatio(); when using manual scaler + + window->setX(availableGeometry.x() + + (availableGeometry.width() - + width)); //*screen->devicePixelRatio()); when using manual scaler + window->setY(heightOffset - (*screenHeightOffset % heightOffset)); + }; + QObject::connect(window, &QQuickWindow::widthChanged, + [window, updateNotificationCoordinates](int w) { + updateNotificationCoordinates(w, window->height()); + }); + QObject::connect(window, &QQuickWindow::heightChanged, + [window, updateNotificationCoordinates](int h) { + updateNotificationCoordinates(window->width(), h); + }); + updateNotificationCoordinates(window->width(), window->height()); QObject::connect(window, &QQuickWindow::closing, window, [this, window] { deleteNotification(QVariant::fromValue(window)); }); showNotification(window, timeout); diff --git a/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml b/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml index ab6f07094..bf01a20fd 100644 --- a/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml +++ b/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml @@ -7,8 +7,8 @@ import UtilsCpp Notification { id: mainItem radius: 20 * DefaultStyle.dp - overriddenWidth: content.width//101 * DefaultStyle.dp - overriddenHeight: content.height//422 * DefaultStyle.dp + overriddenWidth: 450 * DefaultStyle.dp//content.width//101 * DefaultStyle.dp + overriddenHeight: 101 * DefaultStyle.dp//content.height// readonly property var call: notificationData && notificationData.call property var state: call.core.state @@ -33,7 +33,7 @@ Notification { contentItem: RowLayout { id: notifContent - spacing: 30 * DefaultStyle.dp + spacing: 15 * DefaultStyle.dp height: childrenRect.height width: childrenRect.width RowLayout { @@ -51,6 +51,7 @@ Notification { Text { text: call.core.remoteName Layout.fillWidth: true + Layout.maximumWidth: 200 * DefaultStyle.dp maximumLineCount: 1 color: DefaultStyle.grey_600 font {