Commit 96b1945d authored by Volker Krause's avatar Volker Krause
Browse files

Align the alarm timer to the next minute

This doesn't really change the semantics, but it makes things appear much
more responsive/reliable as alarms now pop up the second your clock
switches to the next minute.

While at it this also no longer spins the alarm timer in case Akonadi isn't
set up yet and removes a few config options that were never written to and
that unnecessarily complicated this.
parent 0578af0c
Pipeline #108600 passed with stage
in 6 minutes and 34 seconds
......@@ -24,6 +24,9 @@ KalendarAlarmClient::KalendarAlarmClient(QObject *parent)
connect(m_notificationHandler, &NotificationHandler::notificationUpdated, this, &KalendarAlarmClient::storeNotification);
connect(m_notificationHandler, &NotificationHandler::notificationRemoved, this, &KalendarAlarmClient::removeNotification);
// Check if Akonadi is already configured
const QString akonadiConfigFile = Akonadi::ServerManager::serverConfigFilePath(Akonadi::ServerManager::ReadWrite);
if (QFileInfo::exists(akonadiConfigFile)) {
......@@ -41,12 +44,8 @@ KalendarAlarmClient::KalendarAlarmClient(QObject *parent)
KConfigGroup alarmGroup(KSharedConfig::openConfig(), "Alarms");
const int interval = alarmGroup.readEntry("Interval", 60);
qDebug() << "KalendarAlarmClient check interval:" << interval << "seconds.";
mLastChecked = alarmGroup.readEntry("CalendarsLastChecked", QDateTime::currentDateTime().addDays(-9));
mCheckTimer.start(1000 * interval); // interval in seconds
......@@ -154,12 +153,6 @@ bool KalendarAlarmClient::collectionsAvailable() const
void KalendarAlarmClient::checkAlarms()
KConfigGroup cfg(KSharedConfig::openConfig(), "General");
if (!cfg.readEntry("Enabled", true)) {
// We do not want to miss any reminders, so don't perform check unless
// the collections are available and populated.
if (!collectionsAvailable()) {
......@@ -201,6 +194,9 @@ void KalendarAlarmClient::checkAlarms()
// schedule next check for the beginning of the next minute
mCheckTimer.start(std::chrono::seconds(60 - mLastChecked.time().second()));
void KalendarAlarmClient::saveLastCheckTime()
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