@ -26,6 +26,7 @@ using namespace NotificationManager;
AbstractNotificationsModel : : Private : : Private ( AbstractNotificationsModel * q )
AbstractNotificationsModel : : Private : : Private ( AbstractNotificationsModel * q )
: q ( q )
: q ( q )
, inhibited ( false )
, lastRead ( QDateTime : : currentDateTimeUtc ( ) )
, lastRead ( QDateTime : : currentDateTimeUtc ( ) )
{
{
pendingRemovalTimer . setSingleShot ( true ) ;
pendingRemovalTimer . setSingleShot ( true ) ;
@ -67,10 +68,10 @@ void AbstractNotificationsModel::Private::onNotificationAdded(const Notification
q - > endRemoveRows ( ) ;
q - > endRemoveRows ( ) ;
}
}
setupNotificationTimeout ( notification ) ;
q - > beginInsertRows ( QModelIndex ( ) , notifications . count ( ) , notifications . count ( ) ) ;
q - > beginInsertRows ( QModelIndex ( ) , notifications . count ( ) , notifications . count ( ) ) ;
notifications . append ( std : : move ( notification ) ) ;
notifications . append ( std : : move ( notification ) ) ;
// Timeout must be set after the item appends to the vector
setupNotificationTimeout ( notification ) ;
q - > endInsertRows ( ) ;
q - > endInsertRows ( ) ;
}
}
@ -159,6 +160,12 @@ void AbstractNotificationsModel::Private::setupNotificationTimeout(const Notific
return ;
return ;
}
}
// Don't show the notification popup after switching DND mode off.
if ( inhibited ) {
q - > expire ( notification . id ( ) ) ;
return ;
}
QTimer * timer = notificationTimeouts . value ( notification . id ( ) ) ;
QTimer * timer = notificationTimeouts . value ( notification . id ( ) ) ;
if ( ! timer ) {
if ( ! timer ) {
timer = new QTimer ( ) ;
timer = new QTimer ( ) ;
@ -426,6 +433,11 @@ void AbstractNotificationsModel::stopTimeout(uint notificationId)
delete d - > notificationTimeouts . take ( notificationId ) ;
delete d - > notificationTimeouts . take ( notificationId ) ;
}
}
void AbstractNotificationsModel : : setInhibited ( bool inhibited )
{
d - > inhibited = inhibited ;
}
void AbstractNotificationsModel : : clear ( Notifications : : ClearFlags flags )
void AbstractNotificationsModel : : clear ( Notifications : : ClearFlags flags )
{
{
if ( d - > notifications . isEmpty ( ) ) {
if ( d - > notifications . isEmpty ( ) ) {