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 | |
9 | class KAbstractConfigModulePrivate |
10 | { |
11 | public: |
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 | |
29 | KAbstractConfigModule::KAbstractConfigModule(QObject *parent, const KPluginMetaData &metaData) |
30 | : QObject(parent) |
31 | , d(new KAbstractConfigModulePrivate(metaData)) |
32 | { |
33 | } |
34 | |
35 | KAbstractConfigModule::~KAbstractConfigModule() = default; |
36 | |
37 | KAbstractConfigModule::Buttons KAbstractConfigModule::buttons() const |
38 | { |
39 | return d->m_buttons; |
40 | } |
41 | |
42 | void 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 | |
52 | bool KAbstractConfigModule::needsAuthorization() const |
53 | { |
54 | return !d->m_authActionName.isEmpty(); |
55 | } |
56 | |
57 | QString KAbstractConfigModule::name() const |
58 | { |
59 | return d->m_data.name(); |
60 | } |
61 | |
62 | QString KAbstractConfigModule::description() const |
63 | { |
64 | return d->m_data.description(); |
65 | } |
66 | |
67 | void 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 | |
77 | QString KAbstractConfigModule::authActionName() const |
78 | { |
79 | return d->m_authActionName; |
80 | } |
81 | |
82 | void KAbstractConfigModule::load() |
83 | { |
84 | setNeedsSave(false); |
85 | } |
86 | |
87 | void KAbstractConfigModule::save() |
88 | { |
89 | setNeedsSave(false); |
90 | } |
91 | |
92 | void KAbstractConfigModule::defaults() |
93 | { |
94 | } |
95 | |
96 | void 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 | |
106 | bool KAbstractConfigModule::needsSave() const |
107 | { |
108 | return d->m_needsSave; |
109 | } |
110 | |
111 | void 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 | |
121 | bool KAbstractConfigModule::representsDefaults() const |
122 | { |
123 | return d->m_representsDefaults; |
124 | } |
125 | |
126 | bool KAbstractConfigModule::defaultsIndicatorsVisible() const |
127 | { |
128 | return d->m_defaultsIndicatorVisible; |
129 | } |
130 | |
131 | void 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 | |
140 | KPluginMetaData KAbstractConfigModule::metaData() const |
141 | { |
142 | return d->m_data; |
143 | } |
144 | |
145 | #include "moc_kabstractconfigmodule.cpp" |
146 |