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) {
notification.updated = QDateTime::currentDateTimeUtc();
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::onNotificationRemoved(uint removedId, NotificationServer::CloseReason reason)

@ -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)
}

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

Loading…
Cancel
Save