Improved duplicate notification

pull/15/head
reionwong 4 years ago
parent e0e0a726ea
commit 1bfda3c8d3

@ -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) { if (wasReplaced) {
notification.updated = QDateTime::currentDateTimeUtc(); notification.updated = QDateTime::currentDateTimeUtc();
emit notificationReplaced(replaces_id, notification); emit notificationReplaced(replaces_id, notification);

@ -186,7 +186,6 @@ void NotificationsModel::onNotificationAdded(const Notification &notification)
void NotificationsModel::onNotificationReplaced(uint replacedId, const Notification &notification) void NotificationsModel::onNotificationReplaced(uint replacedId, const Notification &notification)
{ {
} }
void NotificationsModel::onNotificationRemoved(uint removedId, NotificationServer::CloseReason reason) void NotificationsModel::onNotificationRemoved(uint removedId, NotificationServer::CloseReason reason)

@ -27,17 +27,15 @@ import Cutefish.Notification 1.0
Window { Window {
id: control id: control
flags: Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup flags: Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup
width: 400 width: 400
height: 70 height: 70
color: "transparent" color: "transparent"
visible: false visible: false
onVisibleChanged: if (visible) timer.restart() onVisibleChanged: if (visible) timer.restart()
property int defaultTimeout: 7000
FishUI.WindowShadow { FishUI.WindowShadow {
view: control view: control
radius: _background.radius radius: _background.radius
@ -118,21 +116,22 @@ Window {
} }
} }
// Image { Image {
// anchors.top: parent.top anchors.top: parent.top
// anchors.right: parent.right anchors.right: parent.right
// anchors.topMargin: FishUI.Units.smallSpacing / 2 anchors.topMargin: FishUI.Units.smallSpacing / 2
// anchors.rightMargin: FishUI.Units.smallSpacing anchors.rightMargin: FishUI.Units.smallSpacing
// width: 24 width: 24
// height: 24 height: 24
// source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark" : "light") + "/close.svg" source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark" : "light") + "/close.svg"
// sourceSize: Qt.size(width, height) sourceSize: Qt.size(width, height)
// visible: _mouseArea.containsMouse visible: _mouseArea.containsMouse
// } }
Timer { Timer {
id: timer id: timer
interval: 5000 interval: control.defaultTimeout
onTriggered: { onTriggered: {
notificationsModel.close(model.notificationId) notificationsModel.close(model.notificationId)
} }

@ -32,6 +32,8 @@ Item {
return rect return rect
} }
onScreenRectChanged: positionPopups()
property Instantiator popupInstantiator: Instantiator { property Instantiator popupInstantiator: Instantiator {
model: notificationsModel model: notificationsModel
delegate: NotificationPopup {} delegate: NotificationPopup {}

Loading…
Cancel
Save