File indexing completed on 2025-01-05 04:50:43

0001 /*  SPDX-FileCopyrightText: 2018 Daniel Vrátil <dvratil@kde.org>
0002 
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #include <Akonadi/AgentConfigurationBase>
0007 
0008 #include "configwidget.h"
0009 #include "settings.h"
0010 
0011 class MixedMaildirConfig : public Akonadi::AgentConfigurationBase
0012 {
0013     Q_OBJECT
0014 public:
0015     MixedMaildirConfig(const KSharedConfigPtr &config, QWidget *parent, const QVariantList &args)
0016         : Akonadi::AgentConfigurationBase(config, parent, args)
0017     {
0018         Settings::instance(config);
0019         mSettings.reset(Settings::self());
0020         mWidget.reset(new ConfigWidget(mSettings.data(), parent));
0021         connect(mWidget.data(), &ConfigWidget::okEnabled, this, &Akonadi::AgentConfigurationBase::enableOkButton);
0022     }
0023 
0024     void load() override
0025     {
0026         Akonadi::AgentConfigurationBase::load();
0027         mWidget->load(mSettings.data());
0028     }
0029 
0030     [[nodiscard]] bool save() const override
0031     {
0032         mWidget->save(mSettings.data());
0033         mSettings->save();
0034         return Akonadi::AgentConfigurationBase::save();
0035     }
0036 
0037 private:
0038     QScopedPointer<Settings> mSettings;
0039     QScopedPointer<ConfigWidget> mWidget;
0040 };
0041 
0042 AKONADI_AGENTCONFIG_FACTORY(MixedMaildirConfigFactory, "mixedmaildirconfig.json", MixedMaildirConfig)
0043 
0044 #include "mixedmaildirconfig.moc"