Commit d6f81703 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Add reminder to new events

When a new event is created, add a reminder by default. Users can opt
out or add a custom alarm time on the settings page.
parent f9f20250
Pipeline #21594 passed with stage
in 15 minutes and 41 seconds
......@@ -171,3 +171,29 @@ void CalindoriConfig::setEventsDuration(int duration)
Q_EMIT eventsDurationChanged();
}
int CalindoriConfig::preEventRemindTime() const
{
return d->config.group("events").readEntry("preEventRemindTime", 15);
}
void CalindoriConfig::setPreEventRemindTime(int remindBefore)
{
d->config.group("events").writeEntry("preEventRemindTime", remindBefore);
d->config.sync();
Q_EMIT preEventRemindTimeChanged();
}
bool CalindoriConfig::alwaysRemind() const
{
return d->config.group("events").readEntry("alwaysRemind", true);
}
void CalindoriConfig::setAlwaysRemind(bool remind)
{
d->config.group("events").writeEntry("alwaysRemind", remind);
d->config.sync();
Q_EMIT alwaysRemindChanged();
}
......@@ -16,6 +16,8 @@ class CalindoriConfig : public QObject
Q_PROPERTY(QString calendars READ calendars NOTIFY calendarsChanged)
Q_PROPERTY(QString activeCalendar READ activeCalendar WRITE setActiveCalendar NOTIFY activeCalendarChanged)
Q_PROPERTY(int eventsDuration READ eventsDuration WRITE setEventsDuration NOTIFY eventsDurationChanged)
Q_PROPERTY(int preEventRemindTime READ preEventRemindTime WRITE setPreEventRemindTime NOTIFY preEventRemindTimeChanged)
Q_PROPERTY(bool alwaysRemind READ alwaysRemind WRITE setAlwaysRemind NOTIFY alwaysRemindChanged)
public:
......@@ -34,13 +36,22 @@ public:
void setEventsDuration(int duration);
Q_SIGNAL void eventsDurationChanged();
int preEventRemindTime() const;
void setPreEventRemindTime(int remindBefore);
Q_SIGNAL void preEventRemindTimeChanged();
bool alwaysRemind() const;
void setAlwaysRemind(bool remind);
Q_SIGNAL void alwaysRemindChanged();
public Q_SLOTS:
QVariantMap canAddCalendar(const QString& calendar);
QVariantMap addCalendar(const QString& calendar);
void removeCalendar(const QString& calendar);
private:
static QString filenameToPath(const QString & calendarName) ;
static QString filenameToPath(const QString & calendarName);
class Private;
Private* d;
......
......@@ -56,6 +56,13 @@ Kirigami.Page {
return result;
}
Component.onCompleted: {
if(incidenceData == null && _calindoriConfig.alwaysRemind)
{
incidenceAlarmsModel.addAlarm(_calindoriConfig.preEventRemindTime * 60)
}
}
title: uid == "" ? i18n("Add event") : i18n("Edit event")
ColumnLayout {
......
......@@ -22,15 +22,31 @@ Kirigami.ScrollablePage {
Kirigami.FormData.label: i18n("Events")
}
RowLayout {
Controls.SpinBox {
Kirigami.FormData.label: i18n("Initial duration (minutes)")
Controls.SpinBox {
from: 0
value: _calindoriConfig.eventsDuration
from: 0
value: _calindoriConfig.eventsDuration
onValueModified: _calindoriConfig.eventsDuration = value
}
Controls.SpinBox {
Kirigami.FormData.label: i18n("Remind before event (minutes)")
from: 0
value: _calindoriConfig.preEventRemindTime
onValueModified: _calindoriConfig.preEventRemindTime = value
}
Controls.SwitchDelegate {
Kirigami.FormData.label: i18n("Add reminder to new events")
onValueModified: _calindoriConfig.eventsDuration = value
}
checked: _calindoriConfig.alwaysRemind
onCheckedChanged: _calindoriConfig.alwaysRemind = checked
}
}
}
Markdown is supported
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