fix #LINQT-1655 set height offset for new notification if there is already some displayed
This commit is contained in:
parent
46f19d5d64
commit
c076a37540
2 changed files with 12 additions and 16 deletions
|
|
@ -171,28 +171,24 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
||||||
// window->setProperty(it.key().toLatin1(), it.value());
|
// window->setProperty(it.key().toLatin1(), it.value());
|
||||||
const int timeout = Notifications[type].getTimeout() * 1000;
|
const int timeout = Notifications[type].getTimeout() * 1000;
|
||||||
auto updateNotificationCoordinates = [this, window, screen](int width, int height) {
|
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();
|
QRect availableGeometry = screen->availableGeometry();
|
||||||
int heightOffset = availableGeometry.y() +
|
|
||||||
(availableGeometry.height() -
|
|
||||||
height); //*screen->devicePixelRatio(); when using manual scaler
|
|
||||||
|
|
||||||
window->setX(availableGeometry.x() +
|
window->setX(availableGeometry.x() +
|
||||||
(availableGeometry.width() -
|
(availableGeometry.width() -
|
||||||
width)); //*screen->devicePixelRatio()); when using manual scaler
|
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());
|
updateNotificationCoordinates(window->width(), window->height());
|
||||||
QObject::connect(window, &QQuickWindow::closing, window,
|
auto screenHeightOffset =
|
||||||
[this, window] { deleteNotification(QVariant::fromValue(window)); });
|
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);
|
showNotification(window, timeout);
|
||||||
lInfo() << QStringLiteral("Create notification:") << QVariant::fromValue(window);
|
lInfo() << QStringLiteral("Create notification:") << QVariant::fromValue(window);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ Window {
|
||||||
property bool showAsTool : false
|
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
|
// 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.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
|
opacity: 1.0
|
||||||
height: _content[0] != null ? _content[0].height : 0
|
height: _content[0] != null ? _content[0].height : 0
|
||||||
width: _content[0] != null ? _content[0].width : 0
|
width: _content[0] != null ? _content[0].width : 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue