diff --git a/notificationd/notificationserver.cpp b/notificationd/notificationserver.cpp index ae2fa80..a208b2a 100644 --- a/notificationd/notificationserver.cpp +++ b/notificationd/notificationserver.cpp @@ -82,6 +82,15 @@ uint NotificationServer::Notify(const QString &app_name, } } + if (m_lastNotification.appName == notification.appName && + m_lastNotification.summary == notification.summary && + m_lastNotification.body == notification.body && + m_lastNotification.created.msecsTo(notification.created) < 1000) { + return 0; + } + + m_lastNotification = notification; + if (wasReplaced) { notification.updated = QDateTime::currentDateTimeUtc(); emit notificationReplaced(replaces_id, notification); diff --git a/notificationd/notificationsmodel.cpp b/notificationd/notificationsmodel.cpp index 66dfd69..1a621e7 100644 --- a/notificationd/notificationsmodel.cpp +++ b/notificationd/notificationsmodel.cpp @@ -186,7 +186,6 @@ void NotificationsModel::onNotificationAdded(const Notification ¬ification) void NotificationsModel::onNotificationReplaced(uint replacedId, const Notification ¬ification) { - } void NotificationsModel::onNotificationRemoved(uint removedId, NotificationServer::CloseReason reason) diff --git a/notificationd/qml/NotificationPopup.qml b/notificationd/qml/NotificationPopup.qml index 086caea..000fa3d 100644 --- a/notificationd/qml/NotificationPopup.qml +++ b/notificationd/qml/NotificationPopup.qml @@ -27,17 +27,15 @@ import Cutefish.Notification 1.0 Window { id: control - flags: Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup - width: 400 height: 70 color: "transparent" - visible: false - onVisibleChanged: if (visible) timer.restart() + property int defaultTimeout: 7000 + FishUI.WindowShadow { view: control radius: _background.radius @@ -118,21 +116,22 @@ Window { } } -// Image { -// anchors.top: parent.top -// anchors.right: parent.right -// anchors.topMargin: FishUI.Units.smallSpacing / 2 -// anchors.rightMargin: FishUI.Units.smallSpacing -// width: 24 -// height: 24 -// source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark" : "light") + "/close.svg" -// sourceSize: Qt.size(width, height) -// visible: _mouseArea.containsMouse -// } + Image { + anchors.top: parent.top + anchors.right: parent.right + anchors.topMargin: FishUI.Units.smallSpacing / 2 + anchors.rightMargin: FishUI.Units.smallSpacing + width: 24 + height: 24 + source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark" : "light") + "/close.svg" + sourceSize: Qt.size(width, height) + visible: _mouseArea.containsMouse + } Timer { id: timer - interval: 5000 + interval: control.defaultTimeout + onTriggered: { notificationsModel.close(model.notificationId) } diff --git a/notificationd/qml/main.qml b/notificationd/qml/main.qml index 57be550..03d862a 100644 --- a/notificationd/qml/main.qml +++ b/notificationd/qml/main.qml @@ -32,6 +32,8 @@ Item { return rect } + onScreenRectChanged: positionPopups() + property Instantiator popupInstantiator: Instantiator { model: notificationsModel delegate: NotificationPopup {}