Commit 9ce69fac authored by David Jarvie's avatar David Jarvie
Browse files

Add preferences option to enable/disable Akonadi plugin

parent c3181a03
Pipeline #167944 passed with stage
in 3 minutes and 27 seconds
KAlarm Change Log
=== Version 3.5.0 (KDE Gear 22.08) --- 22 April 2022 ===
* Provide option to build KAlarm without any Akonadi dependency.
=== Version 3.5.0 (KDE Gear 22.08) --- 24 April 2022 ===
* Provide options to build and/or run KAlarm without any Akonadi dependency.
=== Version 3.4.1 (KDE Gear 22.04.1) --- 20 April 2022 ===
* Fix checkboxes being disabled in Preferences dialogue.
......
......@@ -39,7 +39,7 @@
<!-- Don't change format of date and version of the documentation -->
<date>2022-4-22</date>
<date>2022-4-24</date>
<releaseinfo>3.5.0 (KDE Gear 22.08)</releaseinfo>
<abstract>
......@@ -1088,7 +1088,7 @@ context menu.</para>
<note><para>This function is only available if &kalarm;'s
<link linkend="akonadi-plugin">Akonadi plugin</link> is
installed.</para>
installed and enabled.</para>
</note>
<para>You can set up display alarms for birthdays stored in
......@@ -1527,7 +1527,8 @@ message body in the three edit fields. Use the button beside the
addressee edit box to display your &kde; address book from which you
can select email recipients. (Note that the button is only shown if
&kalarm;'s
<link linkend="akonadi-plugin">Akonadi plugin</link> is installed.)
<link linkend="akonadi-plugin">Akonadi plugin</link> is installed and
enabled.)
Attachments may be added using the <guibutton>Add...</guibutton>
button. Note that attached files must still exist when the alarm is
triggered; no copy is stored at the time the alarm is configured. To
......@@ -2677,6 +2678,13 @@ codes:</para>
quoted before being inserted into the terminal window command.</para>
</listitem>
<listitem><para><guilabel>Enable Akonadi</guilabel>:
Choose whether to use &akonadi; to provide features which depend on it.
See <link linkend="akonadi-plugin">Akonadi plugin</link> for details.
Note that this option is only shown if the Akonadi plugin is
installed.</para>
</listitem>
</itemizedlist>
</sect1>
......@@ -2801,7 +2809,8 @@ be archived according to the selected options.</para>
for sending and addressing email alarms:</para>
<note><para>Options dependent on &kmail; are only available if &kalarm;'s
<link linkend="akonadi-plugin">Akonadi plugin</link> is installed.</para>
<link linkend="akonadi-plugin">Akonadi plugin</link> is installed and
enabled.</para>
</note>
<itemizedlist>
......@@ -5049,8 +5058,8 @@ distributed with &kalarm;.</para>
<answer>
<para>&kalarm; uses its Akonadi plugin to provide all features which
depend on &akonadi; (the &kde; &PIM; cross-desktop storage service).
If this plugin is not installed, &kalarm; will lack the following
features:
If this plugin is not installed and enabled, &kalarm; will lack the
following features:
<itemizedlist>
<listitem>
<simpara>Sending emails via &kmail;, leaving &Sendmail; as the only
......@@ -5072,6 +5081,9 @@ run of a new version of &kalarm;.</simpara>
</listitem>
</itemizedlist>
</para>
<para>If the plugin is installed, it can be enabled or disabled in the
<link linkend="preferences-general">General</link> tab of the
Configuration dialog.</para>
</answer>
</qandaentry>
......
......@@ -8,7 +8,6 @@
#include "birthdaydlg.h"
#include "akonadiplugin/akonadiplugin.h"
#include "editdlgtypes.h"
#include "fontcolourbutton.h"
#include "kalarmapp.h"
......@@ -20,8 +19,8 @@
#include "soundpicker.h"
#include "specialactions.h"
#include "lib/checkbox.h"
#include "pluginmanager.h"
#include "lib/shellprocess.h"
#include "akonadiplugin/akonadiplugin.h"
#include "kalarm_debug.h"
#include <KLocalizedString>
......@@ -106,9 +105,9 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
auto layout = new QVBoxLayout(group);
layout->setContentsMargins(0, 0, 0, 0);
AkonadiPlugin* akonadiPlugin = PluginManager::instance()->akonadiPlugin();
AkonadiPlugin* akonadiPlugin = Preferences::akonadiPlugin();
if (!akonadiPlugin)
return; // no error message - this constructor should only be called if Akonadi plugin exists
return; // no error message - this constructor should only be called if using Akonadi plugin
mBirthdaySortModel = akonadiPlugin->createBirthdayModels(mainWidget, this);
connect(akonadiPlugin, &AkonadiPlugin::birthdayModelDataChanged, this, &BirthdayDlg::resizeViewColumns);
setSortModelSelectionList();
......@@ -365,7 +364,7 @@ void BirthdayDlg::slotTextLostFocus()
*/
void BirthdayDlg::setSortModelSelectionList()
{
AkonadiPlugin* akonadiPlugin = PluginManager::instance()->akonadiPlugin();
AkonadiPlugin* akonadiPlugin = Preferences::akonadiPlugin();
if (!akonadiPlugin)
return;
......
......@@ -71,6 +71,11 @@ SPDX-License-Identifier: GPL-2.0-or-later
<choice name="FileResources"><label context="@option">File Resources</label></choice>
</choices>
</entry>
<entry name="UseAkonadiIfAvailable" type="Bool">
<label context="@label">Enable Akonadi plugin</label>
<whatsthis context="@info:whatsthis">Choose whether to enable KAlarm's Akonadi plugin, which uses Akonadi to provide features including birthday import, some email functions, email address book lookup, and Akonadi resource migration on first run.</whatsthis>
<default>true</default>
</entry>
<entry name="Base_TimeZone" key="TimeZone" type="String">
<label context="@label">Time zone</label>
<whatsthis context="@info:whatsthis">Select the time zone which KAlarm should use as its default for displaying and entering dates and times.</whatsthis>
......
......@@ -18,7 +18,6 @@
#include "mainwindow.h"
#include "messagewindow.h"
#include "pickfileradio.h"
#include "pluginmanager.h"
#include "reminder.h"
#include "soundpicker.h"
#include "sounddlg.h"
......@@ -1196,7 +1195,7 @@ void EditEmailAlarmDlg::type_init(QWidget* parent, QVBoxLayout* frameLayout)
"commas or semicolons."));
connect(mEmailToEdit, &LineEdit::textChanged, this, &EditEmailAlarmDlg::contentsChanged);
if (PluginManager::instance()->akonadiPlugin())
if (Preferences::useAkonadi())
{
grid->addWidget(mEmailToEdit, 1, 1);
......@@ -1505,7 +1504,7 @@ void EditEmailAlarmDlg::slotTrySuccess()
*/
void EditEmailAlarmDlg::openAddressBook()
{
AkonadiPlugin* akonadiPlugin = PluginManager::instance()->akonadiPlugin();
AkonadiPlugin* akonadiPlugin = Preferences::akonadiPlugin();
if (akonadiPlugin)
{
Person person;
......
......@@ -14,7 +14,6 @@
#include "kamail.h"
#include "mainwindow.h"
#include "messagewindow.h"
#include "pluginmanager.h"
#include "preferences.h"
#include "resourcescalendar.h"
#include "templatelistview.h"
......@@ -1871,7 +1870,7 @@ bool dropAkonadiEmail(const QMimeData* data, QUrl& url, AlarmText& alarmText)
else
{
url = urls.at(0);
AkonadiPlugin* akonadiPlugin = PluginManager::instance()->akonadiPlugin();
AkonadiPlugin* akonadiPlugin = Preferences::akonadiPlugin();
if (akonadiPlugin)
{
KAEvent::EmailId emailId;
......@@ -2090,7 +2089,7 @@ KAlarm::UpdateResult sendToKOrganizer(const KAEvent& event)
*/
KAlarm::UpdateResult deleteFromKOrganizer(const QString& eventID)
{
AkonadiPlugin* akonadiPlugin = PluginManager::instance()->akonadiPlugin();
AkonadiPlugin* akonadiPlugin = Preferences::akonadiPlugin();
if (!akonadiPlugin)
return KAlarm::UpdateResult(KAlarm::UPDATE_KORG_ERR);
......
......@@ -12,7 +12,6 @@
#include "functions.h"
#include "kalarmapp.h"
#include "mainwindow.h"
#include "pluginmanager.h"
#include "preferences.h"
#include "lib/messagebox.h"
#include "kalarmcalendar/identities.h"
......@@ -202,7 +201,7 @@ int KAMail::send(JobData& jobdata, QStringList& errmsgs)
notifyQueued(jobdata.event);
return 1;
}
else if (PluginManager::instance()->akonadiPlugin())
else if (Preferences::useAkonadi())
{
qCDebug(KALARM_LOG) << "KAMail::send: Sending via KDE";
initHeaders(*message, jobdata);
......@@ -216,7 +215,7 @@ int KAMail::send(JobData& jobdata, QStringList& errmsgs)
if (!mAkonadiPlugin)
{
mAkonadiPlugin = PluginManager::instance()->akonadiPlugin();
mAkonadiPlugin = Preferences::akonadiPlugin();
connect(mAkonadiPlugin, &AkonadiPlugin::emailSent, instance(), &KAMail::akonadiEmailSent);
connect(mAkonadiPlugin, &AkonadiPlugin::emailQueued, instance(), [](const KAEvent& e) { notifyQueued(e); });
}
......
......@@ -18,7 +18,6 @@
#include "kamail.h"
#include "messagedisplay.h"
#include "newalarmaction.h"
#include "pluginmanager.h"
#include "prefdlg.h"
#include "preferences.h"
#include "resourcescalendar.h"
......@@ -540,7 +539,7 @@ void MainWindow::initActions()
actions->addAction(QStringLiteral("importAlarms"), mActionImportAlarms);
connect(mActionImportAlarms, &QAction::triggered, this, &MainWindow::slotImportAlarms);
if (PluginManager::instance()->akonadiPlugin())
if (Preferences::useAkonadi())
{
mActionImportBirthdays = new QAction(i18nc("@action", "Import Birthdays..."), this);
actions->addAction(QStringLiteral("importBirthdays"), mActionImportBirthdays);
......@@ -959,7 +958,7 @@ void MainWindow::slotExportAlarms()
*/
void MainWindow::slotBirthdays()
{
if (PluginManager::instance()->akonadiPlugin())
if (Preferences::useAkonadi())
{
// Use AutoQPointer to guard against crash on application exit while
// the dialogue is still open. It prevents double deletion (both on
......
......@@ -15,7 +15,6 @@
#include "functions.h"
#include "kalarmapp.h"
#include "mainwindow.h"
#include "pluginmanager.h"
#include "preferences.h"
#include "resourcescalendar.h"
#include "lib/config.h"
......@@ -467,7 +466,7 @@ void MessageWindow::setUpDisplay()
mHelper->setSilenceButton(mSilenceButton);
}
if (mEmailId() >= 0 && PluginManager::instance()->akonadiPlugin())
if (mEmailId() >= 0 && Preferences::useAkonadi())
{
// KMail button
mKMailButton = new PushButton(topWidget);
......@@ -1092,7 +1091,7 @@ void MessageWindow::slotOk()
*/
void MessageWindow::slotShowKMailMessage()
{
AkonadiPlugin* akonadiPlugin = PluginManager::instance()->akonadiPlugin();
AkonadiPlugin* akonadiPlugin = Preferences::akonadiPlugin();
if (!akonadiPlugin)
return;
qCDebug(KALARM_LOG) << "MessageWindow::slotShowKMailMessage";
......
......@@ -537,6 +537,22 @@ MiscPrefTab::MiscPrefTab(StackedScrollGroup* scrollGroup)
radio->setWhatsThis(wt);
mXtermCommand->setWhatsThis(wt);
if (PluginManager::instance()->akonadiPlugin())
{
// Plugins
group = new QGroupBox(i18nc("@title:group", "Plugins"));
topLayout()->addWidget(group);
vlayout = new QVBoxLayout(group);
// Akonadi plugin
mUseAkonadi = new QCheckBox(i18nc("@option:check", "Enable Akonadi"), group);
mUseAkonadi->setToolTip(i18nc("@info:tooltip",
"Enable the use of Akonadi to provide features including birthday import, some email functions, and email address book lookup."));
mUseAkonadi->setWhatsThis(i18nc("@info:whatsthis",
"Enable the use of Akonadi to provide features including birthday import, some email functions, and email address book lookup."));
vlayout->addWidget(mUseAkonadi, 0, Qt::AlignLeft);
}
topLayout()->addStretch(); // top adjust the widgets
}
......@@ -560,6 +576,8 @@ void MiscPrefTab::restore(bool defaults, bool)
mXtermType->setButton(id);
mXtermCommand->setEnabled(id == mXtermCount);
mXtermCommand->setText(id == mXtermCount ? xtermCmd : QString());
if (mUseAkonadi)
mUseAkonadi->setChecked(Preferences::useAkonadi());
}
void MiscPrefTab::apply(bool syncToDisc)
......@@ -617,6 +635,12 @@ void MiscPrefTab::apply(bool syncToDisc)
QString text = (xtermID < mXtermCount) ? xtermCommands[xtermID] : mXtermCommand->text();
if (text != Preferences::cmdXTermCommand())
Preferences::setCmdXTermCommand(text);
if (mUseAkonadi)
{
b = mUseAkonadi->isChecked();
if (b != Preferences::useAkonadi())
Preferences::setUseAkonadi(b);
}
PrefsTabBase::apply(syncToDisc);
}
......@@ -1150,6 +1174,21 @@ void EmailPrefTab::apply(bool syncToDisc)
PrefsTabBase::apply(syncToDisc);
}
void EmailPrefTab::showEvent(QShowEvent* e)
{
bool enable = Preferences::useAkonadiIfAvailable();
if (mKMailButton)
{
mKMailButton->setEnabled(enable);
if (!enable)
mEmailClient->setButton(Preferences::sendmail);
}
if (mEmailCopyToKMail)
mEmailCopyToKMail->setEnabled(enable);
PrefsTabBase::showEvent(e);
}
void EmailPrefTab::setEmailAddress(Preferences::MailFrom from, const QString& address)
{
mFromAddressGroup->setButton(from);
......@@ -1165,7 +1204,7 @@ void EmailPrefTab::setEmailBccAddress(bool useSystemSettings, const QString& add
void EmailPrefTab::slotEmailClientChanged(QAbstractButton* button)
{
if (mEmailCopyToKMail)
mEmailCopyToKMail->setEnabled(button == mSendmailButton);
mEmailCopyToKMail->setEnabled(button == mSendmailButton && Preferences::useAkonadiIfAvailable());
}
void EmailPrefTab::slotFromAddrChanged(QAbstractButton* button)
......
......@@ -86,6 +86,7 @@ private:
QCheckBox* mQuitWarn;
QCheckBox* mUseAlarmNames;
QCheckBox* mConfirmAlarmDeletion;
QCheckBox* mUseAkonadi {nullptr};
TimeSpinBox* mDefaultDeferTime;
ButtonGroup* mXtermType;
QLineEdit* mXtermCommand;
......@@ -158,6 +159,9 @@ public:
void restore(bool defaults, bool allTabs) override;
void apply(bool syncToDisc) override;
protected:
void showEvent(QShowEvent*) override;
private Q_SLOTS:
void slotEmailClientChanged(QAbstractButton*);
void slotFromAddrChanged(QAbstractButton*);
......
......@@ -103,6 +103,30 @@ Preferences::Preferences()
setVersion(QStringLiteral(KALARM_VERSION));
}
/******************************************************************************
* Get whether the Akonadi plugin should be used, if available.
*/
bool Preferences::useAkonadi()
{
return self()->mUseAkonadiIfAvailable && PluginManager::instance()->akonadiPlugin();
}
/******************************************************************************
* Return the Akonadi plugin to use, or null if not being used or not available.
*/
AkonadiPlugin* Preferences::akonadiPlugin()
{
if (!self()->mUseAkonadiIfAvailable)
return nullptr;
return PluginManager::instance()->akonadiPlugin();
}
void Preferences::setUseAkonadi(bool yes)
{
if (PluginManager::instance()->akonadiPlugin())
self()->setUseAkonadiIfAvailable(yes);
}
/******************************************************************************
* Auto hiding of the system tray icon is only allowed on desktops which provide
* GUI controls to show hidden icons.
......@@ -380,28 +404,28 @@ void Preferences::workTimeChange(const QDateTime& start, const QDateTime& end, i
Preferences::MailClient Preferences::emailClient()
{
if (!PluginManager::instance()->akonadiPlugin())
if (!useAkonadi())
return sendmail;
return static_cast<MailClient>(self()->mBase_EmailClient);
}
void Preferences::setEmailClient(MailClient client)
{
if (!PluginManager::instance()->akonadiPlugin())
if (!useAkonadi())
client = sendmail;
self()->setBase_EmailClient(client);
}
bool Preferences::emailCopyToKMail()
{
if (!PluginManager::instance()->akonadiPlugin())
if (!useAkonadi())
return false;
return self()->mBase_EmailCopyToKMail && static_cast<MailClient>(self()->mBase_EmailClient) == sendmail;
}
void Preferences::setEmailCopyToKMail(bool yes)
{
if (!PluginManager::instance()->akonadiPlugin())
if (!useAkonadi())
yes = false;
self()->setBase_EmailCopyToKMail(yes);
}
......
......@@ -18,6 +18,7 @@
using namespace KAlarmCal;
namespace KHolidays { class HolidayRegion; }
class AkonadiPlugin;
// Settings configured in the Preferences dialog
......@@ -36,6 +37,22 @@ public:
{
QObject::connect(self(), signal, receiver, member);
}
/** Return whether Akonadi plugin is available and should be used.
* @see useAkonadiIfAvailable().
*/
static bool useAkonadi();
/** Return the Akonadi plugin.
* @return the Akonadi plugin, or null if not available or not to be used.
*/
static AkonadiPlugin* akonadiPlugin();
/** Set whether to use the Akonadi plugin if available.
* @see setUseAkonadiIfAvailable().
*/
static void setUseAkonadi(bool yes);
static int autoHideSystemTray();
static void setAutoHideSystemTray(int timeout);
static bool autoStartChangedByUser() { return mAutoStartChangedByUser; }
......
......@@ -9,7 +9,7 @@
#include "fileresourcemigrator.h"
#include "dirresourceimportdialog.h"
#include "pluginmanager.h"
#include "preferences.h"
#include "resources/calendarfunctions.h"
#include "resources/fileresourcecalendarupdater.h"
#include "resources/fileresourceconfigmanager.h"
......@@ -109,7 +109,7 @@ void FileResourceMigrator::start()
else
{
// There are no file system resources, so migrate any Akonadi resources.
mAkonadiPlugin = PluginManager::instance()->akonadiPlugin();
mAkonadiPlugin = Preferences::akonadiPlugin();
if (!mAkonadiPlugin)
akonadiMigrationComplete(false); // Akonadi plugin is not available
else
......
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