1/*
2 SPDX-FileCopyrightText: 2023 Alexander Lohnau <alexander.lohnau@gmx.de>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "kabstractconfigmodule.h"
7#include <kpluginmetadata.h>
8
9class KAbstractConfigModulePrivate
10{
11public:
12 KAbstractConfigModulePrivate(const KPluginMetaData &data)
13 : m_data(data)
14 {
15 }
16 const KPluginMetaData m_data;
17
18 QString m_rootOnlyMessage;
19 QString m_errorString;
20
21 bool m_useRootOnlyMessage = false;
22 bool m_needsSave = false;
23 bool m_representsDefaults = false;
24 bool m_defaultsIndicatorVisible = false;
25 QString m_authActionName;
26 KAbstractConfigModule::Buttons m_buttons = KAbstractConfigModule::Help | KAbstractConfigModule::Default | KAbstractConfigModule::Apply;
27};
28
29KAbstractConfigModule::KAbstractConfigModule(QObject *parent, const KPluginMetaData &metaData)
30 : QObject(parent)
31 , d(new KAbstractConfigModulePrivate(metaData))
32{
33}
34
35KAbstractConfigModule::~KAbstractConfigModule() = default;
36
37KAbstractConfigModule::Buttons KAbstractConfigModule::buttons() const
38{
39 return d->m_buttons;
40}
41
42void KAbstractConfigModule::setButtons(const KAbstractConfigModule::Buttons buttons)
43{
44 if (d->m_buttons == buttons) {
45 return;
46 }
47
48 d->m_buttons = buttons;
49 Q_EMIT buttonsChanged();
50}
51
52bool KAbstractConfigModule::needsAuthorization() const
53{
54 return !d->m_authActionName.isEmpty();
55}
56
57QString KAbstractConfigModule::name() const
58{
59 return d->m_data.name();
60}
61
62QString KAbstractConfigModule::description() const
63{
64 return d->m_data.description();
65}
66
67void KAbstractConfigModule::setAuthActionName(const QString &name)
68{
69 if (d->m_authActionName == name) {
70 return;
71 }
72
73 d->m_authActionName = name;
74 Q_EMIT authActionNameChanged();
75}
76
77QString KAbstractConfigModule::authActionName() const
78{
79 return d->m_authActionName;
80}
81
82void KAbstractConfigModule::load()
83{
84 setNeedsSave(false);
85}
86
87void KAbstractConfigModule::save()
88{
89 setNeedsSave(false);
90}
91
92void KAbstractConfigModule::defaults()
93{
94}
95
96void KAbstractConfigModule::setNeedsSave(bool needs)
97{
98 if (needs == d->m_needsSave) {
99 return;
100 }
101
102 d->m_needsSave = needs;
103 Q_EMIT needsSaveChanged();
104}
105
106bool KAbstractConfigModule::needsSave() const
107{
108 return d->m_needsSave;
109}
110
111void KAbstractConfigModule::setRepresentsDefaults(bool defaults)
112{
113 if (defaults == d->m_representsDefaults) {
114 return;
115 }
116
117 d->m_representsDefaults = defaults;
118 Q_EMIT representsDefaultsChanged();
119}
120
121bool KAbstractConfigModule::representsDefaults() const
122{
123 return d->m_representsDefaults;
124}
125
126bool KAbstractConfigModule::defaultsIndicatorsVisible() const
127{
128 return d->m_defaultsIndicatorVisible;
129}
130
131void KAbstractConfigModule::setDefaultsIndicatorsVisible(bool visible)
132{
133 if (d->m_defaultsIndicatorVisible == visible) {
134 return;
135 }
136 d->m_defaultsIndicatorVisible = visible;
137 Q_EMIT defaultsIndicatorsVisibleChanged();
138}
139
140KPluginMetaData KAbstractConfigModule::metaData() const
141{
142 return d->m_data;
143}
144
145#include "moc_kabstractconfigmodule.cpp"
146

source code of kcmutils/src/core/kabstractconfigmodule.cpp