Git commit 9ce69fac1d318fb3ebf2a9808eb2c06891c17ea3 by David Jarvie. Committed on 24/04/2022 at 17:48. Pushed by djarvie into branch 'master'.
Add preferences option to enable/disable Akonadi plugin M +2 -2 Changelog M +18 -6 doc/index.docbook M +4 -5 src/birthdaydlg.cpp M +5 -0 src/data/kalarmconfig.kcfg M +2 -3 src/editdlgtypes.cpp M +2 -3 src/functions.cpp M +2 -3 src/kamail.cpp M +2 -3 src/mainwindow.cpp M +2 -3 src/messagewindow.cpp M +40 -1 src/prefdlg.cpp M +4 -0 src/prefdlg_p.h M +28 -4 src/preferences.cpp M +17 -0 src/preferences.h M +2 -2 src/resources/migration/fileresourcemigrator.cpp https://invent.kde.org/pim/kalarm/commit/9ce69fac1d318fb3ebf2a9808eb2c06891c17ea3 diff --git a/Changelog b/Changelog index 3099a66c..6171ab49 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,7 @@ 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. diff --git a/doc/index.docbook b/doc/index.docbook index 19c855c0..cac9a6ba 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -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> diff --git a/src/birthdaydlg.cpp b/src/birthdaydlg.cpp index 3dde3e2c..62a0fd0b 100644 --- a/src/birthdaydlg.cpp +++ b/src/birthdaydlg.cpp @@ -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; diff --git a/src/data/kalarmconfig.kcfg b/src/data/kalarmconfig.kcfg index 88eaf3b1..dbcb9d1b 100644 --- a/src/data/kalarmconfig.kcfg +++ b/src/data/kalarmconfig.kcfg @@ -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> diff --git a/src/editdlgtypes.cpp b/src/editdlgtypes.cpp index 4174e87b..482b412b 100644 --- a/src/editdlgtypes.cpp +++ b/src/editdlgtypes.cpp @@ -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; diff --git a/src/functions.cpp b/src/functions.cpp index 4b5c5ea7..3c9b16e9 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -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); diff --git a/src/kamail.cpp b/src/kamail.cpp index 2b4857cf..5f453fa9 100644 --- a/src/kamail.cpp +++ b/src/kamail.cpp @@ -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); }); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8636af53..37eb6a90 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 diff --git a/src/messagewindow.cpp b/src/messagewindow.cpp index 9380eb64..7b33c852 100644 --- a/src/messagewindow.cpp +++ b/src/messagewindow.cpp @@ -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"; diff --git a/src/prefdlg.cpp b/src/prefdlg.cpp index 37e55f44..2a4a4c52 100644 --- a/src/prefdlg.cpp +++ b/src/prefdlg.cpp @@ -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) diff --git a/src/prefdlg_p.h b/src/prefdlg_p.h index bbc6698e..1c5fb8ee 100644 --- a/src/prefdlg_p.h +++ b/src/prefdlg_p.h @@ -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*); diff --git a/src/preferences.cpp b/src/preferences.cpp index e1772e20..173a9b77 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -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); } diff --git a/src/preferences.h b/src/preferences.h index eb2c744d..2bda10ef 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -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; } diff --git a/src/resources/migration/fileresourcemigrator.cpp b/src/resources/migration/fileresourcemigrator.cpp index 13ea3f59..9451a923 100644 --- a/src/resources/migration/fileresourcemigrator.cpp +++ b/src/resources/migration/fileresourcemigrator.cpp @@ -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