KCMUtils

kabstractconfigmodule.cpp
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
43{
44 if (d->m_buttons == buttons) {
45 return;
46 }
47
48 d->m_buttons = buttons;
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
68{
69 if (d->m_authActionName == name) {
70 return;
71 }
72
73 d->m_authActionName = name;
75}
76
78{
79 return d->m_authActionName;
80}
81
83{
84 setNeedsSave(false);
85}
86
88{
89 setNeedsSave(false);
90}
91
95
97{
98 if (needs == d->m_needsSave) {
99 return;
100 }
101
102 d->m_needsSave = needs;
104}
105
106bool KAbstractConfigModule::needsSave() const
107{
108 return d->m_needsSave;
109}
110
112{
113 if (defaults == d->m_representsDefaults) {
114 return;
115 }
116
117 d->m_representsDefaults = defaults;
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
132{
133 if (d->m_defaultsIndicatorVisible == visible) {
134 return;
135 }
136 d->m_defaultsIndicatorVisible = visible;
138}
139
141{
142 return d->m_data;
143}
144
145#include "moc_kabstractconfigmodule.cpp"
virtual void defaults()
Sets the configuration to default values.
void setNeedsSave(bool needs)
Set this property to true when the user changes something in the module, signaling that a save (such ...
KPluginMetaData metaData() const
Returns the metaData that was used when instantiating the plugin.
virtual void save()
The save method stores the config information as shown in the user interface in the config files.
void setDefaultsIndicatorsVisible(bool visible)
Change defaultness indicator visibility.
Q_SIGNAL void representsDefaultsChanged()
Indicate that the state of the modules contents has changed in a way that it might represents the def...
Q_SIGNAL void defaultsIndicatorsVisibleChanged()
Emitted when kcm need to display indicators for field with non default value.
Q_SIGNAL void buttonsChanged()
Buttons to display changed.
QString authActionName() const
Returns the action previously set with setAuthActionName().
void setAuthActionName(const QString &action)
Set if the module's save() method requires authorization to be executed.
virtual void load()
Load the configuration data into the module.
Q_SIGNAL void needsSaveChanged()
Indicate that the state of the modules contents has changed.
Q_SIGNAL void authActionNameChanged()
The auth action name has changed.
void setButtons(const Buttons btn)
Sets the buttons to display.
void setRepresentsDefaults(bool defaults)
Set this property to true when the user sets the state of the module to the default settings (e....
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.