Changeset View
Changeset View
Standalone View
Standalone View
src/kcmodule.cpp
Show All 27 Lines | |||||
28 | #include <QLayout> | 28 | #include <QLayout> | ||
29 | #include <QTimer> | 29 | #include <QTimer> | ||
30 | #include <QDebug> | 30 | #include <QDebug> | ||
31 | 31 | | |||
32 | #include <kaboutdata.h> | 32 | #include <kaboutdata.h> | ||
33 | #include <kconfigskeleton.h> | 33 | #include <kconfigskeleton.h> | ||
34 | #include <kconfigdialogmanager.h> | 34 | #include <kconfigdialogmanager.h> | ||
35 | #include <klocalizedstring.h> | 35 | #include <klocalizedstring.h> | ||
36 | #ifndef KCONFIGWIDGETS_NO_KAUTH | ||||
36 | #include <kauthexecutejob.h> | 37 | #include <kauthexecutejob.h> | ||
38 | #endif | ||||
37 | 39 | | |||
38 | class KCModulePrivate | 40 | class KCModulePrivate | ||
39 | { | 41 | { | ||
40 | public: | 42 | public: | ||
41 | KCModulePrivate(): | 43 | KCModulePrivate(): | ||
42 | _buttons(KCModule::Help | KCModule::Default | KCModule::Apply), | 44 | _buttons(KCModule::Help | KCModule::Default | KCModule::Apply), | ||
43 | _about(nullptr), | 45 | _about(nullptr), | ||
44 | _useRootOnlyMessage(false), | 46 | _useRootOnlyMessage(false), | ||
45 | _firstshow(true), | 47 | _firstshow(true), | ||
46 | _needsAuthorization(false), | 48 | _needsAuthorization(false), | ||
47 | _authAction(), | | |||
48 | _unmanagedWidgetChangeState(false) | 49 | _unmanagedWidgetChangeState(false) | ||
49 | { } | 50 | { } | ||
50 | 51 | | |||
51 | void authStatusChanged(int status); | 52 | void authStatusChanged(int status); | ||
52 | 53 | | |||
53 | KCModule::Buttons _buttons; | 54 | KCModule::Buttons _buttons; | ||
54 | const KAboutData *_about; | 55 | const KAboutData *_about; | ||
55 | QString _rootOnlyMessage; | 56 | QString _rootOnlyMessage; | ||
56 | QList<KConfigDialogManager *> managers; | 57 | QList<KConfigDialogManager *> managers; | ||
57 | QString _quickHelp; | 58 | QString _quickHelp; | ||
58 | QString m_ExportText; | 59 | QString m_ExportText; | ||
59 | bool _useRootOnlyMessage : 1; | 60 | bool _useRootOnlyMessage : 1; | ||
60 | bool _firstshow : 1; | 61 | bool _firstshow : 1; | ||
61 | 62 | | |||
62 | bool _needsAuthorization : 1; | 63 | bool _needsAuthorization : 1; | ||
64 | #ifndef KCONFIGWIDGETS_NO_KAUTH | ||||
63 | KAuth::Action _authAction; | 65 | KAuth::Action _authAction; | ||
66 | #endif | ||||
64 | 67 | | |||
65 | // this member is used to record the state on non-automatically | 68 | // this member is used to record the state on non-automatically | ||
66 | // managed widgets, allowing for mixed KConfigXT-drive and manual | 69 | // managed widgets, allowing for mixed KConfigXT-drive and manual | ||
67 | // widgets to coexist peacefully and do the correct thing with | 70 | // widgets to coexist peacefully and do the correct thing with | ||
68 | // the changed(bool) signal | 71 | // the changed(bool) signal | ||
69 | bool _unmanagedWidgetChangeState : 1; | 72 | bool _unmanagedWidgetChangeState : 1; | ||
70 | }; | 73 | }; | ||
71 | 74 | | |||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 117 | { | |||
117 | connect(manager, &KConfigDialogManager::widgetModified, this, &KCModule::widgetChanged); | 120 | connect(manager, &KConfigDialogManager::widgetModified, this, &KCModule::widgetChanged); | ||
118 | d->managers.append(manager); | 121 | d->managers.append(manager); | ||
119 | return manager; | 122 | return manager; | ||
120 | } | 123 | } | ||
121 | 124 | | |||
122 | void KCModule::setNeedsAuthorization(bool needsAuth) | 125 | void KCModule::setNeedsAuthorization(bool needsAuth) | ||
123 | { | 126 | { | ||
124 | d->_needsAuthorization = needsAuth; | 127 | d->_needsAuthorization = needsAuth; | ||
128 | #ifndef KCONFIGWIDGETS_NO_KAUTH | ||||
125 | if (needsAuth && d->_about) { | 129 | if (needsAuth && d->_about) { | ||
126 | d->_authAction = KAuth::Action(QStringLiteral("org.kde.kcontrol.") + d->_about->componentName() + QStringLiteral(".save")); | 130 | d->_authAction = KAuth::Action(QStringLiteral("org.kde.kcontrol.") + d->_about->componentName() + QStringLiteral(".save")); | ||
127 | d->_needsAuthorization = d->_authAction.isValid(); | 131 | d->_needsAuthorization = d->_authAction.isValid(); | ||
128 | d->_authAction.setHelperId(QStringLiteral("org.kde.kcontrol.") + d->_about->componentName()); | 132 | d->_authAction.setHelperId(QStringLiteral("org.kde.kcontrol.") + d->_about->componentName()); | ||
129 | d->_authAction.setParentWidget(this); | 133 | d->_authAction.setParentWidget(this); | ||
130 | authStatusChanged(d->_authAction.status()); | 134 | authStatusChanged(d->_authAction.status()); | ||
131 | } else { | 135 | } else { | ||
132 | d->_authAction = KAuth::Action(); | 136 | d->_authAction = KAuth::Action(); | ||
133 | } | 137 | } | ||
138 | #endif | ||||
134 | } | 139 | } | ||
135 | 140 | | |||
136 | bool KCModule::needsAuthorization() const | 141 | bool KCModule::needsAuthorization() const | ||
137 | { | 142 | { | ||
138 | return d->_needsAuthorization; | 143 | return d->_needsAuthorization; | ||
139 | } | 144 | } | ||
140 | 145 | | |||
146 | #ifndef KCONFIGWIDGETS_NO_KAUTH | ||||
141 | void KCModule::setAuthAction(const KAuth::Action &action) | 147 | void KCModule::setAuthAction(const KAuth::Action &action) | ||
142 | { | 148 | { | ||
143 | if (!action.isValid()) { | 149 | if (!action.isValid()) { | ||
144 | qCWarning(KCONFIG_WIDGETS_LOG) << "Auth action" << action.name() << "is invalid"; | 150 | qCWarning(KCONFIG_WIDGETS_LOG) << "Auth action" << action.name() << "is invalid"; | ||
145 | d->_needsAuthorization = false; | 151 | d->_needsAuthorization = false; | ||
146 | return; | 152 | return; | ||
147 | } | 153 | } | ||
148 | d->_authAction = action; | 154 | d->_authAction = action; | ||
Show All 20 Lines | 166 | { | |||
169 | default: | 175 | default: | ||
170 | setUseRootOnlyMessage(true); | 176 | setUseRootOnlyMessage(true); | ||
171 | setRootOnlyMessage(i18n("You are not allowed to save the configuration")); | 177 | setRootOnlyMessage(i18n("You are not allowed to save the configuration")); | ||
172 | break; | 178 | break; | ||
173 | } | 179 | } | ||
174 | 180 | | |||
175 | qCDebug(KCONFIG_WIDGETS_LOG) << useRootOnlyMessage(); | 181 | qCDebug(KCONFIG_WIDGETS_LOG) << useRootOnlyMessage(); | ||
176 | } | 182 | } | ||
183 | #endif | ||||
177 | 184 | | |||
178 | KCModule::~KCModule() | 185 | KCModule::~KCModule() | ||
179 | { | 186 | { | ||
180 | qDeleteAll(d->managers); | 187 | qDeleteAll(d->managers); | ||
181 | d->managers.clear(); | 188 | d->managers.clear(); | ||
182 | delete d->_about; | 189 | delete d->_about; | ||
183 | delete d; | 190 | delete d; | ||
184 | } | 191 | } | ||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |