Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 9e6ea097 authored by Laurent Montel's avatar Laurent Montel 😁

Fix generate config plugin

parent 494ef459
......@@ -45,27 +45,28 @@ install( FILES birthdaysresource.desktop DESTINATION "${KDE_INSTALL_DATAROOTDIR}
############################# Config plugin ################################
#set(birthdaysconfig_SRCS)
#ki18n_wrap_ui(birthdaysconfig_SRCS birthdaysconfigwidget.ui)
#set(birthdaysconfig_SRCS
# birthdaysconfigagentwidget.cpp
# ${birthdayresource_common_SRCS}
# )
set(birthdaysconfig_ui_SRCS)
ki18n_wrap_ui(birthdaysconfig_ui_SRCS birthdaysconfigwidget.ui)
set(birthdaysconfig_SRCS
birthdaysconfigagentwidget.cpp
${birthdaysconfig_ui_SRCS}
${birthdayresource_common_SRCS}
)
#kcoreaddons_add_plugin(birthdaysconfig
# SOURCES ${birthdaysconfig_SRCS}
# JSON "birthdaysconfig.json"
# INSTALL_NAMESPACE "akonadi/config"
# )
#target_link_libraries(birthdaysconfig
# KF5::AkonadiCore
# KF5::CalendarCore
# KF5::Codecs
# KF5::AkonadiAgentBase
# KF5::Contacts
# KF5::AkonadiWidgets
# KF5::I18n
# KF5::TextWidgets
# KF5::WindowSystem
# )
kcoreaddons_add_plugin(birthdaysconfig
SOURCES ${birthdaysconfig_SRCS}
JSON "birthdaysconfig.json"
INSTALL_NAMESPACE "akonadi/config"
)
target_link_libraries(birthdaysconfig
KF5::AkonadiCore
KF5::CalendarCore
KF5::Codecs
KF5::AkonadiAgentBase
KF5::Contacts
KF5::AkonadiWidgets
KF5::I18n
KF5::TextWidgets
KF5::WindowSystem
)
......@@ -21,7 +21,7 @@
#include "birthdaysconfigagentwidget.h"
#include "settings.h"
#include <AkonadiCore/Tag>
#include <kbirthdaysconfigwidgetmanager.h>
#include <kconfigdialogmanager.h>
#include <QIcon>
#include <KLocalizedString>
#include <QPushButton>
......@@ -33,18 +33,16 @@ BirthdaysConfigAgentWidget::BirthdaysConfigAgentWidget(const KSharedConfigPtr &c
{
//setWindowIcon(QIcon::fromTheme(QStringLiteral("view-calendar-birthday")));
QWidget *mainWidget = new QWidget(this);
Settings::instance(config);
QWidget *mainWidget = new QWidget(parent);
ui.setupUi(mainWidget);
mainLayout->addWidget(mainWidget);
parent->layout()->addWidget(mainWidget);
mainLayout->addWidget(buttonBox);
mManager = new KBirthdaysConfigWidgetManager(this, Settings::self());
mManager = new KConfigDialogManager(mainWidget, Settings::self());
mManager->updateWidgets();
ui.kcfg_AlarmDays->setSuffix(ki18np(" day", " days"));
connect(okButton, &QPushButton::clicked, this, &BirthdaysConfigWidget::save);
loadTags();
}
BirthdaysConfigAgentWidget::~BirthdaysConfigAgentWidget()
......@@ -52,50 +50,29 @@ BirthdaysConfigAgentWidget::~BirthdaysConfigAgentWidget()
}
void BirthdaysConfigAgentWidget::load()
{
}
bool BirthdaysConfigAgentWidget::save() const
{
}
void BirthdaysConfigAgentWidget::loadTags()
{
const QStringList categories = Settings::self()->filterCategories();
ui.FilterCategories->setSelectionFromStringList(categories);
}
void BirthdaysConfigWidget::save()
bool BirthdaysConfigAgentWidget::save() const
{
mManager->updateSettings();
Settings::self()->setFilterCategories(ui.FilterCategories->tagToStringList());
Settings::self()->save();
return true;
}
//void BirthdaysConfigWidget::readConfig()
//{
// KConfigGroup group(KSharedConfig::openConfig(), "BirthdaysConfigWidget");
// const QSize size = group.readEntry("Size", QSize(600, 400));
// if (size.isValid()) {
// resize(size);
// }
//}
//void BirthdaysConfigWidget::writeConfig()
//{
// KConfigGroup group(KSharedConfig::openConfig(), "BirthdaysConfigWidget");
// group.writeEntry("Size", size());
// group.sync();
//}
QSize BirthdaysConfigAgentWidget::restoreDialogSize() const
{
auto group = config()->group("BirthdaysConfigWidget");
const QSize size = group.readEntry("Size", QSize(600, 400));
return size;
}
void BirthdaysConfigAgentWidget::saveDialogSize(const QSize &size)
{
auto group = config()->group("BirthdaysConfigWidget");
group.writeEntry("Size", size);
}
......@@ -25,13 +25,13 @@
#include "ui_birthdaysconfigwidget.h"
#include <AkonadiCore/AgentConfigurationBase>
class KBirthdaysConfigWidgetManager;
class KConfigDialogManager;
class BirthdaysConfigAgentWidget : public Akonadi::AgentConfigurationBase
{
Q_OBJECT
public:
explicit BirthdaysConfigAgentWidget(QWidget *parent = nullptr);
explicit BirthdaysConfigAgentWidget(const KSharedConfigPtr &config, QWidget *parent, const QVariantList &args);
~BirthdaysConfigAgentWidget() override;
void load() override;
......@@ -39,11 +39,10 @@ public:
QSize restoreDialogSize() const override;
void saveDialogSize(const QSize &size) override;
private:
void loadTags();
Ui::BirthdaysConfigWidget ui;
KBirthdaysConfigWidgetManager *mManager = nullptr;
KConfigDialogManager *mManager = nullptr;
};
AKONADI_AGENTCONFIG_FACTORY(BirthdaysConfigFactory, "birthdaysconfig.json", BirthdaysConfig)
AKONADI_AGENTCONFIG_FACTORY(BirthdaysConfigAgentWidgetFactory, "birthdaysconfig.json", BirthdaysConfigAgentWidget)
#endif
......@@ -47,12 +47,12 @@ using namespace KCalCore;
BirthdaysResource::BirthdaysResource(const QString &id)
: ResourceBase(id)
{
Settings::instance(KSharedConfig::openConfig());
new SettingsAdaptor(Settings::self());
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"),
Settings::self(), QDBusConnection::ExportAdaptors);
setName(i18n("Birthdays & Anniversaries"));
Monitor *monitor = new Monitor(this);
monitor->setMimeTypeMonitored(Addressee::mimeType());
monitor->itemFetchScope().fetchFullPayload();
......@@ -60,28 +60,18 @@ BirthdaysResource::BirthdaysResource(const QString &id)
connect(monitor, &Monitor::itemChanged, this, &BirthdaysResource::contactChanged);
connect(monitor, &Monitor::itemRemoved, this, &BirthdaysResource::contactRemoved);
connect(this, &BirthdaysResource::reloadConfiguration, this, &BirthdaysResource::doFullSearch);
connect(this, &BirthdaysResource::reloadConfiguration, this, &BirthdaysResource::slotReloadConfig);
}
BirthdaysResource::~BirthdaysResource()
{
}
#if 0
void BirthdaysResource::configure(WId windowId)
void BirthdaysResource::slotReloadConfig()
{
ConfigDialog dlg;
if (windowId) {
KWindowSystem::setMainWindow(&dlg, windowId);
}
if (dlg.exec()) {
Q_EMIT configurationDialogAccepted();
} else {
Q_EMIT configurationDialogRejected();
}
doFullSearch();
synchronizeCollectionTree();
}
#endif
void BirthdaysResource::retrieveCollections()
{
......
......@@ -63,6 +63,7 @@ private Q_SLOTS:
void contactRetrieved(KJob *job);
private:
void slotReloadConfig();
QHash<QString, Akonadi::Item> mPendingItems;
QHash<QString, Akonadi::Item> mDeletedItems;
};
......
......@@ -4,8 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile/>
<kcfgfile arg="true" />
<group name="Filter">
<entry type="Bool" name="FilterOnCategories">
......
# Code generation options for kconfig_compiler
File=birthdaysresource.kcfg
ClassName=Settings
Mutators=true
ItemAccessors=true
Singleton=true
GlobalEnums=true
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