File indexing completed on 2026-08-09 07:09:55

0001 /*
0002     SPDX-FileCopyrightText: 2023 Alexander Lohnau <alexander.lohnau@gmx.de>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #include "kabstractconfigmodule.h"
0007 #include <kpluginmetadata.h>
0008 
0009 class KAbstractConfigModulePrivate
0010 {
0011 public:
0012     KAbstractConfigModulePrivate(const KPluginMetaData &data)
0013         : m_data(data)
0014     {
0015     }
0016     const KPluginMetaData m_data;
0017 
0018     QString m_rootOnlyMessage;
0019     QString m_errorString;
0020 
0021     bool m_useRootOnlyMessage = false;
0022     bool m_needsSave = false;
0023     bool m_representsDefaults = false;
0024     bool m_defaultsIndicatorVisible = false;
0025     QString m_authActionName;
0026     KAbstractConfigModule::Buttons m_buttons = KAbstractConfigModule::Help | KAbstractConfigModule::Default | KAbstractConfigModule::Apply;
0027 };
0028 
0029 KAbstractConfigModule::KAbstractConfigModule(QObject *parent, const KPluginMetaData &metaData)
0030     : QObject(parent)
0031     , d(new KAbstractConfigModulePrivate(metaData))
0032 {
0033 }
0034 
0035 KAbstractConfigModule::~KAbstractConfigModule() = default;
0036 
0037 KAbstractConfigModule::Buttons KAbstractConfigModule::buttons() const
0038 {
0039     return d->m_buttons;
0040 }
0041 
0042 void KAbstractConfigModule::setButtons(const KAbstractConfigModule::Buttons buttons)
0043 {
0044     if (d->m_buttons == buttons) {
0045         return;
0046     }
0047 
0048     d->m_buttons = buttons;
0049     Q_EMIT buttonsChanged();
0050 }
0051 
0052 bool KAbstractConfigModule::needsAuthorization() const
0053 {
0054     return !d->m_authActionName.isEmpty();
0055 }
0056 
0057 QString KAbstractConfigModule::name() const
0058 {
0059     return d->m_data.name();
0060 }
0061 
0062 QString KAbstractConfigModule::description() const
0063 {
0064     return d->m_data.description();
0065 }
0066 
0067 void KAbstractConfigModule::setAuthActionName(const QString &name)
0068 {
0069     if (d->m_authActionName == name) {
0070         return;
0071     }
0072 
0073     d->m_authActionName = name;
0074     Q_EMIT authActionNameChanged();
0075 }
0076 
0077 QString KAbstractConfigModule::authActionName() const
0078 {
0079     return d->m_authActionName;
0080 }
0081 
0082 void KAbstractConfigModule::load()
0083 {
0084     setNeedsSave(false);
0085 }
0086 
0087 void KAbstractConfigModule::save()
0088 {
0089     setNeedsSave(false);
0090 }
0091 
0092 void KAbstractConfigModule::defaults()
0093 {
0094 }
0095 
0096 void KAbstractConfigModule::setNeedsSave(bool needs)
0097 {
0098     if (needs == d->m_needsSave) {
0099         return;
0100     }
0101 
0102     d->m_needsSave = needs;
0103     Q_EMIT needsSaveChanged();
0104 }
0105 
0106 bool KAbstractConfigModule::needsSave() const
0107 {
0108     return d->m_needsSave;
0109 }
0110 
0111 void KAbstractConfigModule::setRepresentsDefaults(bool defaults)
0112 {
0113     if (defaults == d->m_representsDefaults) {
0114         return;
0115     }
0116 
0117     d->m_representsDefaults = defaults;
0118     Q_EMIT representsDefaultsChanged();
0119 }
0120 
0121 bool KAbstractConfigModule::representsDefaults() const
0122 {
0123     return d->m_representsDefaults;
0124 }
0125 
0126 bool KAbstractConfigModule::defaultsIndicatorsVisible() const
0127 {
0128     return d->m_defaultsIndicatorVisible;
0129 }
0130 
0131 void KAbstractConfigModule::setDefaultsIndicatorsVisible(bool visible)
0132 {
0133     if (d->m_defaultsIndicatorVisible == visible) {
0134         return;
0135     }
0136     d->m_defaultsIndicatorVisible = visible;
0137     Q_EMIT defaultsIndicatorsVisibleChanged();
0138 }
0139 
0140 KPluginMetaData KAbstractConfigModule::metaData() const
0141 {
0142     return d->m_data;
0143 }
0144 
0145 #include "moc_kabstractconfigmodule.cpp"