Commit 29a74cd1 authored by Volker Krause's avatar Volker Krause
Browse files

Don't make notifications for already ended events persistent

This affects both events that had already ended on startup as well as
active notifications while an event ended. Those are then still present
but are only listed in the notification panel after some time, putting
the focus more strongly on the upcoming/current reminders.

Reminders related to tasks are not affected by this.

# Conflicts:
#	reminder-daemon/alarmnotification.cpp
parent be3c95e8
Pipeline #179472 passed with stage
in 3 minutes and 22 seconds
......@@ -32,7 +32,6 @@ void AlarmNotification::send(KalendarAlarmClient *client, const KCalendarCore::I
const bool notificationExists = m_notification;
if (!notificationExists) {
m_notification = new KNotification(QStringLiteral("alarm"));
m_notification->setFlags(KNotification::Persistent);
// dismiss both with the explicit action and just closing the notification
// there is no signal for explicit closing though, we only can observe that
......@@ -99,6 +98,14 @@ void AlarmNotification::send(KalendarAlarmClient *client, const KCalendarCore::I
}
}
bool eventHasEnded = false;
if (incidence->type() == KCalendarCore::Incidence::TypeEvent) {
const auto event = incidence.staticCast<KCalendarCore::Event>();
const auto eventEndTime = startTime.addSecs(event->dtStart().secsTo(event->dtEnd()));
eventHasEnded = eventEndTime < QDateTime::currentDateTime();
}
m_notification->setFlags(eventHasEnded ? KNotification::CloseOnTimeout : KNotification::Persistent);
if (!m_text.isEmpty() && m_text != incidence->summary()) { // MS Teams sometimes repeats the summary as the alarm text, we don't need that
text = m_text + QLatin1Char('\n') + text;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment