Commit f744790d authored by David Jarvie's avatar David Jarvie

Add option to use the standard notification system to display alarms

parent 3e98df68
Pipeline #33632 passed with stage
in 7 minutes and 57 seconds
......@@ -104,6 +104,7 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><td class=cont></td><td class=cont><tt>BCC</tt></td><td class=cont>For an email alarm, the email will be blind copied to the user</td></tr>
<tr><td class=cont></td><td class=cont><tt>REMINDER;<em>[</em>ONCE;<em>]interval</em></tt></td><td class=cont>The reminder interval for the alarm: &lt; 0 for a reminder before the main alarm, &gt; 0 for a reminder after the main alarm. A suffix indicates the time units: <tt>M</tt> = minutes, <tt>H</tt> = hours, <tt>D</tt> = days. E.g. <tt class=eg>-12M</tt>. If <tt>ONCE</tt> is specified, this indicates that the reminder should be shown only for the first recurrence.</td></tr>
<tr><td class=cont></td><td class=cont><tt>LOGIN</tt></td><td class=cont>For an active alarm, when its main alarm has expired, records that the original alarm was triggered each time KAlarm started up (normally at each login)</td></tr>
<tr><td class=cont></td><td class=cont><tt>NOTIFY</tt></td><td class=cont>For a display alarm, indicates that it should be displayed using the notification system instead of showing it in a window</td></tr>
<tr><td class=cont></td><td class=cont><tt>ARCHIVE</tt></td><td class=cont>For an active alarm, indicates that the alarm has triggered at least once and should be archived when it expires or is deleted</td></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-NEXTRECUR</tt></td><td>The single parameter records the next due recurrence date/time of the main alarm or, if sub-repetitions are still pending after the latest recurrence, the date/time of that recurrence</td></tr>
......
......@@ -13,11 +13,11 @@
#include "kacalendar.h"
#include "kaevent.h"
#include <AkonadiCore/item.h>
#include <AkonadiCore/abstractdifferencesreporter.h>
#include <AkonadiCore/attributefactory.h>
#include <AkonadiCore/Item>
#include <AkonadiCore/AbstractDifferencesReporter>
#include <AkonadiCore/AttributeFactory>
#include <klocalizedstring.h>
#include <KLocalizedString>
#include <QLocale>
#include <qplugin.h>
......@@ -243,6 +243,9 @@ void SerializerPluginKAlarm::compare(AbstractDifferencesReporter *reporter, cons
if (eventL.reminderOnceOnly() != eventR.reminderOnceOnly()) {
reportDifference(reporter, KAEventFormatter::ReminderOnce);
}
if (eventL.notify() != eventR.notify()) {
reportDifference(reporter, KAEventFormatter::Notify);
}
if (eventL.deferred() != eventR.deferred()) {
reportDifference(reporter, KAEventFormatter::DeferralType);
}
......
......@@ -13,7 +13,7 @@
#include <KCalUtils/IncidenceFormatter>
#include <klocalizedstring.h>
#include <KLocalizedString>
#include <QLocale>
......@@ -118,6 +118,8 @@ QString KAEventFormatter::label(Parameter param)
return i18nc("@label Whether the alarm has a reminder", "Reminder");
case ReminderOnce:
return i18nc("@label Whether reminder is on first recurrence only", "Reminder once only");
case Notify:
return i18nc("@label Whether to use standard notification system", "Notify");
case DeferralType:
return i18nc("@label Deferral type", "Deferral");
case DeferralTime:
......@@ -197,6 +199,7 @@ bool KAEventFormatter::isApplicable(Parameter param) const
case ConfirmAck:
case AkonadiItem:
case Reminder:
case Notify:
case DeferralType:
case DeferDefault:
return mEvent.actionTypes() & KAEvent::ACT_DISPLAY;
......@@ -351,6 +354,8 @@ QString KAEventFormatter::value(Parameter param) const
return mEvent.reminderMinutes() ? minutesHoursDays(mEvent.reminderMinutes()) : trueFalse(false);
case ReminderOnce:
return trueFalse(mEvent.reminderOnceOnly());
case Notify:
return trueFalse(mEvent.notify());
case DeferralType:
return mEvent.reminderDeferral() ? i18nc("@info", "Reminder") : trueFalse(mEvent.deferred());
case DeferralTime:
......
......@@ -63,6 +63,7 @@ public:
SoundFadeTime,
Reminder,
ReminderOnce,
Notify,
DeferralType,
DeferralTime,
DeferDefault,
......
/*
* kaevent.cpp - represents calendar events
* kaevent.cpp - represents KAlarm calendar events
* This file is part of kalarmcal library, which provides access to KAlarm
* calendar data.
* SPDX-FileCopyrightText: 2001-2019 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2020 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -301,6 +301,7 @@ public:
bool mCopyToKOrganizer{false}; // KOrganizer should hold a copy of the event
bool mReminderOnceOnly{false}; // the reminder is output only for the first recurrence
bool mAutoClose{false}; // whether to close the alarm window after the late-cancel period
bool mNotify{false}; // alarm should be shown by the notification system, not in a window
bool mMainExpired; // main alarm has expired (in which case a deferral alarm will exist)
bool mRepeatAtLogin{false}; // whether to repeat the alarm at every login
bool mArchiveRepeatAtLogin{false}; // if now archived, original event was repeat-at-login
......@@ -323,6 +324,7 @@ public:
static const QString DEFER_FLAG;
static const QString LATE_CANCEL_FLAG;
static const QString AUTO_CLOSE_FLAG;
static const QString NOTIFY_FLAG;
static const QString TEMPL_AFTER_TIME_FLAG;
static const QString KMAIL_ITEM_FLAG;
static const QString ARCHIVE_FLAG;
......@@ -391,6 +393,7 @@ const QString KAEventPrivate::REMINDER_ONCE_FLAG = QStringLiteral("ONCE");
const QString KAEventPrivate::DEFER_FLAG = QStringLiteral("DEFER"); // default defer interval for this alarm
const QString KAEventPrivate::LATE_CANCEL_FLAG = QStringLiteral("LATECANCEL");
const QString KAEventPrivate::AUTO_CLOSE_FLAG = QStringLiteral("LATECLOSE");
const QString KAEventPrivate::NOTIFY_FLAG = QStringLiteral("NOTIFY");
const QString KAEventPrivate::TEMPL_AFTER_TIME_FLAG = QStringLiteral("TMPLAFTTIME");
const QString KAEventPrivate::KMAIL_ITEM_FLAG = QStringLiteral("KMAIL");
const QString KAEventPrivate::ARCHIVE_FLAG = QStringLiteral("ARCHIVE");
......@@ -534,6 +537,7 @@ KAEventPrivate::KAEventPrivate(const KADateTime &dateTime, const QString &text,
mDisplaying = flags & DISPLAYING_;
mReminderOnceOnly = flags & KAEvent::REMINDER_ONCE;
mAutoClose = (flags & KAEvent::AUTO_CLOSE) && mLateCancel;
mNotify = flags & KAEvent::NOTIFY;
mRepeatSoundPause = (flags & KAEvent::REPEAT_SOUND) ? 0 : -1;
mSpeak = (flags & KAEvent::SPEAK) && action != KAEvent::AUDIO;
mBeep = (flags & KAEvent::BEEP) && action != KAEvent::AUDIO && !mSpeak;
......@@ -628,6 +632,8 @@ KAEventPrivate::KAEventPrivate(const KCalendarCore::Event::Ptr &event)
mExcludeHolidayRegion = holidays();
} else if (flag == WORK_TIME_ONLY_FLAG) {
mWorkTimeOnly = 1;
} else if (flag == NOTIFY_FLAG) {
mNotify = true;
} else if (flag == KMAIL_ITEM_FLAG) {
const Akonadi::Item::Id id = flags.at(i + 1).toLongLong(&ok);
if (!ok) {
......@@ -1050,6 +1056,7 @@ void KAEventPrivate::copy(const KAEventPrivate &event)
mCopyToKOrganizer = event.mCopyToKOrganizer;
mReminderOnceOnly = event.mReminderOnceOnly;
mAutoClose = event.mAutoClose;
mNotify = event.mNotify;
mMainExpired = event.mMainExpired;
mRepeatAtLogin = event.mRepeatAtLogin;
mArchiveRepeatAtLogin = event.mArchiveRepeatAtLogin;
......@@ -1158,6 +1165,9 @@ bool KAEventPrivate::updateKCalEvent(const Event::Ptr &ev, KAEvent::UidAction ui
if (mWorkTimeOnly) {
flags += WORK_TIME_ONLY_FLAG;
}
if (mNotify) {
flags += NOTIFY_FLAG;
}
if (mLateCancel) {
(flags += (mAutoClose ? AUTO_CLOSE_FLAG : LATE_CANCEL_FLAG)) += QString::number(mLateCancel);
}
......@@ -1633,6 +1643,9 @@ KAEvent::Flags KAEventPrivate::flags() const
if (mAutoClose) {
result |= KAEvent::AUTO_CLOSE;
}
if (mNotify) {
result |= KAEvent::NOTIFY;
}
if (!mEnabled) {
result |= KAEvent::DISABLED;
}
......@@ -1795,6 +1808,16 @@ bool KAEvent::autoClose() const
return d->mAutoClose;
}
void KAEvent::setNotify(bool useNotify)
{
d->mNotify = useNotify;
}
bool KAEvent::notify() const
{
return d->mNotify;
}
void KAEvent::setAkonadiItemId(Akonadi::Item::Id id)
{
d->mAkonadiItemId = id;
......@@ -3714,6 +3737,7 @@ bool KAEventPrivate::compare(const KAEventPrivate& other, KAEvent::Comparison co
|| mExtraActionOptions != other.mExtraActionOptions
|| mCommandError != other.mCommandError
|| mConfirmAck != other.mConfirmAck
|| mNotify != other.mNotify
|| mAkonadiItemId != other.mAkonadiItemId
|| mBeep != other.mBeep
|| mSpeak != other.mSpeak
......@@ -3855,6 +3879,7 @@ void KAEventPrivate::dumpDebug() const
qCDebug(KALARMCAL_LOG) << "-- mPostAction:" << mPostAction;
qCDebug(KALARMCAL_LOG) << "-- mLateCancel:" << mLateCancel;
qCDebug(KALARMCAL_LOG) << "-- mAutoClose:" << mAutoClose;
qCDebug(KALARMCAL_LOG) << "-- mNotify:" << mNotify;
} else if (mActionSubType == KAEvent::COMMAND) {
qCDebug(KALARMCAL_LOG) << "-- mCommandScript:" << mCommandScript;
qCDebug(KALARMCAL_LOG) << "-- mCommandXterm:" << mCommandXterm;
......
/*
* kaevent.h - represents calendar events
* kaevent.h - represents KAlarm calendar events
* This file is part of kalarmcal library, which provides access to KAlarm
* calendar data.
* SPDX-FileCopyrightText: 2001-2019 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2020 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -209,7 +209,8 @@ public:
WORK_TIME_ONLY = 0x8000, //!< trigger the alarm only during working hours
DISPLAY_COMMAND = 0x10000, //!< display command output in the alarm window
REMINDER_ONCE = 0x20000, //!< only trigger the reminder on the first recurrence
DONT_SHOW_ERROR = 0x40000 //!< do not notify command alarm errors to user
DONT_SHOW_ERROR = 0x40000, //!< do not notify command alarm errors to user
NOTIFY = 0x80000 //!< use the standard notification system instead of alarm message window
// IMPORTANT: if any values are added to this list, ensure that the
// additional enum values in KAEventPrivate are also adjusted.
......@@ -555,6 +556,20 @@ public:
*/
bool autoClose() const;
/** Enable the notification system to be used for a display alarm, instead
* of displaying a window.
* @see notify()
*/
void setNotify(bool useNotify);
/** Return whether the notification system is used instead of displaying
* a window, for a display alarm.
* @return @c true if it is a display alarm and it uses the notification
* system
* @see setNotify()
*/
bool notify() const;
/** Set the Akonadi item ID of the email which the alarm is related to.
*/
void setAkonadiItemId(Akonadi::Item::Id id);
......
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