fix #LINQT-1655 set height offset for new notification if there is already some displayed

This commit is contained in:
Gaelle Braud 2025-07-24 15:59:30 +02:00
parent 46f19d5d64
commit c076a37540
2 changed files with 12 additions and 16 deletions

View file

@ -171,28 +171,24 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
// window->setProperty(it.key().toLatin1(), it.value());
const int timeout = Notifications[type].getTimeout() * 1000;
auto updateNotificationCoordinates = [this, window, screen](int width, int height) {
int *screenHeightOffset = &mScreenHeightOffset[screen->name()]; // Access optimization
auto screenHeightOffset =
screen ? mScreenHeightOffset.value(screen->name()) : 0; // 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));
window->setY(availableGeometry.y() + availableGeometry.height() - screenHeightOffset -
height);
};
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)); });
auto screenHeightOffset =
screen ? mScreenHeightOffset.take(screen->name()) : 0; // Access optimization
mScreenHeightOffset.insert(screen->name(), screenHeightOffset + window->height());
QObject::connect(window, &QQuickWindow::closing, window, [this, window] {
qDebug() << "closing notification";
deleteNotification(QVariant::fromValue(window));
});
showNotification(window, timeout);
lInfo() << QStringLiteral("Create notification:") << QVariant::fromValue(window);
}

View file

@ -40,7 +40,7 @@ Window {
property bool showAsTool : false
// Don't use Popup for flags : it could lead to error in geometry. On Mac, Using Tool ensure to have the Window on Top and fullscreen independant
// flags: Qt.WindowDoesNotAcceptFocus | Qt.BypassWindowManagerHint | (showAsTool?Qt.Tool:Qt.WindowStaysOnTopHint) | Qt.Window | Qt.FramelessWindowHint;
flags: Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint
flags: Qt.Popup | Qt.Dialog | Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
opacity: 1.0
height: _content[0] != null ? _content[0].height : 0
width: _content[0] != null ? _content[0].width : 0