Akonadi

agentconfigurationbase.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Daniel Vrátil <dvratil@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "agentconfigurationbase.h"
8#include "akonadicore_debug.h"
9
10#include <KAboutData>
11#include <KConfigGroup>
12#include <QSize>
13
14namespace Akonadi
15{
16class AgentConfigurationBasePrivate
17{
18public:
19 AgentConfigurationBasePrivate(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args)
20 : config(config)
21 , parentWidget(parentWidget)
22 {
23 Q_ASSERT(!args.empty());
24 if (args.empty()) {
25 qCCritical(AKONADICORE_LOG, "AgentConfigurationBase instantiated with invalid arguments");
26 return;
27 }
28 identifier = args.at(0).toString();
29 }
30
31 KSharedConfigPtr config;
32 QString identifier;
34 QWidget *const parentWidget;
35};
36} // namespace Akonadi
37
38using namespace Akonadi;
39
40AgentConfigurationBase::AgentConfigurationBase(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args)
41 : QObject(reinterpret_cast<QObject *>(parentWidget))
42 , d(new AgentConfigurationBasePrivate(config, parentWidget, args))
43{
44}
45
46AgentConfigurationBase::~AgentConfigurationBase()
47{
48}
49
50KSharedConfigPtr AgentConfigurationBase::config() const
51{
52 return d->config;
53}
54
56{
57 return d->identifier;
58}
59
61{
62 d->config->reparseConfiguration();
63}
64
66{
67 d->config->sync();
68 d->config->reparseConfiguration();
69 return true;
70}
71
72QWidget *AgentConfigurationBase::parentWidget() const
73{
74 return d->parentWidget;
75}
76
78{
79 d->aboutData.reset(new KAboutData(aboutData));
80}
81
83{
84 return d->aboutData.data();
85}
86
91
92void AgentConfigurationBase::saveDialogSize(const QSize & /*unused*/) // clazy:exclude=function-args-by-value
93{
94}
95
96QDialogButtonBox::StandardButtons AgentConfigurationBase::standardButtons() const
97{
99}
100
101void AgentConfigurationBase::saveActivitiesSettings(const ActivitySettings &activities) const
102{
103 KConfigGroup activitiesGroup = d->config->group(QStringLiteral("Agent"));
104 activitiesGroup.writeEntry(QStringLiteral("ActivitiesEnabled"), activities.enabled);
105 activitiesGroup.writeEntry(QStringLiteral("Activities"), activities.activities);
106}
107
108AgentConfigurationBase::ActivitySettings AgentConfigurationBase::restoreActivitiesSettings() const
109{
110 AgentConfigurationBase::ActivitySettings settings;
111 const KConfigGroup activitiesGroup = d->config->group(QStringLiteral("Agent"));
112 settings.enabled = activitiesGroup.readEntry(QStringLiteral("ActivitiesEnabled"), false);
113 settings.activities = activitiesGroup.readEntry(QStringLiteral("Activities"), QStringList());
114 return settings;
115}
116
117#include "moc_agentconfigurationbase.cpp"
AgentConfigurationBase(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args)
Creates a new AgentConfigurationBase objects.
virtual QSize restoreDialogSize() const
Reimplement to restore dialog size.
ActivitySettings restoreActivitiesSettings() const
restoreActivitiesSettings
virtual void saveDialogSize(const QSize &size)
Reimplement to save dialog size.
QString identifier() const
Returns identifier of the Akonadi agent instance currently being configured.
void setKAboutData(const KAboutData &aboutData)
When KAboutData is provided the dialog will also contain KHelpMenu with access to user help etc.
void saveActivitiesSettings(const ActivitySettings &activities) const
saveActivitiesSettings
KAboutData * aboutData() const
Returns about data for the currently configured component.
virtual void load()
Reimplement to load settings from the configuration object into widgets.
virtual bool save() const
Reimplement to save new settings into the configuration object.
KSharedConfigPtr config() const
Returns KConfig object belonging to the current Akonadi agent instance.
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
Helper integration between Akonadi and Qt.
const QChar at(qsizetype position) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.