fix notif coordinates
This commit is contained in:
parent
640eaefade
commit
f40797af3b
2 changed files with 25 additions and 15 deletions
|
|
@ -169,19 +169,28 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
||||||
window->setProperty(NotificationPropertyData, data);
|
window->setProperty(NotificationPropertyData, data);
|
||||||
// for (auto it = data.begin(); it != data.end(); ++it)
|
// for (auto it = data.begin(); it != data.end(); ++it)
|
||||||
// window->setProperty(it.key().toLatin1(), it.value());
|
// 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;
|
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,
|
QObject::connect(window, &QQuickWindow::closing, window,
|
||||||
[this, window] { deleteNotification(QVariant::fromValue(window)); });
|
[this, window] { deleteNotification(QVariant::fromValue(window)); });
|
||||||
showNotification(window, timeout);
|
showNotification(window, timeout);
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import UtilsCpp
|
||||||
Notification {
|
Notification {
|
||||||
id: mainItem
|
id: mainItem
|
||||||
radius: 20 * DefaultStyle.dp
|
radius: 20 * DefaultStyle.dp
|
||||||
overriddenWidth: content.width//101 * DefaultStyle.dp
|
overriddenWidth: 450 * DefaultStyle.dp//content.width//101 * DefaultStyle.dp
|
||||||
overriddenHeight: content.height//422 * DefaultStyle.dp
|
overriddenHeight: 101 * DefaultStyle.dp//content.height//
|
||||||
|
|
||||||
readonly property var call: notificationData && notificationData.call
|
readonly property var call: notificationData && notificationData.call
|
||||||
property var state: call.core.state
|
property var state: call.core.state
|
||||||
|
|
@ -33,7 +33,7 @@ Notification {
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
id: notifContent
|
id: notifContent
|
||||||
|
|
||||||
spacing: 30 * DefaultStyle.dp
|
spacing: 15 * DefaultStyle.dp
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
@ -51,6 +51,7 @@ Notification {
|
||||||
Text {
|
Text {
|
||||||
text: call.core.remoteName
|
text: call.core.remoteName
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: 200 * DefaultStyle.dp
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
color: DefaultStyle.grey_600
|
color: DefaultStyle.grey_600
|
||||||
font {
|
font {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue