KConfigWidgets

kconfigdialogmanager.cpp
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2003 Benjamin C Meyer <ben+kdelibs at meyerhome dot net>
4 SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
5 SPDX-FileCopyrightText: 2017 Friedrich W. H. Kossebau <kossebau@kde.org>
6 SPDX-FileCopyrightText: 2020 Kevin Ottens <kevin.ottens@enioka.com>
7 SPDX-FileCopyrightText: 2020 Cyril Rossi <cyril.rossi@enioka.com>
8
9 SPDX-License-Identifier: LGPL-2.0-or-later
10*/
11
12#include "kconfigdialogmanager.h"
13#include "kconfigdialogmanager_p.h"
14#include "kconfigwidgets_debug.h"
15
16#include <QComboBox>
17#include <QGroupBox>
18#include <QLabel>
19#include <QLayout>
20#include <QMetaObject>
21#include <QMetaProperty>
22#include <QRadioButton>
23#include <QTimer>
24
25#include <KConfigSkeleton>
26
28Q_GLOBAL_STATIC(MyHash, s_propertyMap)
29Q_GLOBAL_STATIC(MyHash, s_changedMap)
30
32 : QObject(parent)
33 , d(new KConfigDialogManagerPrivate(this))
34{
35 d->m_conf = conf;
36 d->m_dialog = parent;
37 init(true);
38}
39
41
42// KF6: Drop this and get signals only from metaObject and/or widget's dynamic properties kcfg_property/kcfg_propertyNotify
44{
45 if (s_propertyMap()->isEmpty()) {
46 s_propertyMap()->insert(QStringLiteral("KButtonGroup"), "current");
47 s_propertyMap()->insert(QStringLiteral("KColorButton"), "color");
48 s_propertyMap()->insert(QStringLiteral("KColorCombo"), "color");
49 s_propertyMap()->insert(QStringLiteral("KKeySequenceWidget"), "keySequence");
50 }
51
52 if (s_changedMap()->isEmpty()) {
53 // Qt
54#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
55 s_changedMap()->insert(QStringLiteral("QCheckBox"), SIGNAL(checkStateChanged(Qt::CheckState)));
56#else
57 s_changedMap()->insert(QStringLiteral("QCheckBox"), SIGNAL(stateChanged(int)));
58#endif
59 s_changedMap()->insert(QStringLiteral("QPushButton"), SIGNAL(clicked(bool)));
60 s_changedMap()->insert(QStringLiteral("QRadioButton"), SIGNAL(toggled(bool)));
61 s_changedMap()->insert(QStringLiteral("QGroupBox"), SIGNAL(toggled(bool)));
62 s_changedMap()->insert(QStringLiteral("QComboBox"), SIGNAL(activated(int)));
63 s_changedMap()->insert(QStringLiteral("QDateEdit"), SIGNAL(dateChanged(QDate)));
64 s_changedMap()->insert(QStringLiteral("QTimeEdit"), SIGNAL(timeChanged(QTime)));
65 s_changedMap()->insert(QStringLiteral("QDateTimeEdit"), SIGNAL(dateTimeChanged(QDateTime)));
66 s_changedMap()->insert(QStringLiteral("QDial"), SIGNAL(valueChanged(int)));
67 s_changedMap()->insert(QStringLiteral("QDoubleSpinBox"), SIGNAL(valueChanged(double)));
68 s_changedMap()->insert(QStringLiteral("QLineEdit"), SIGNAL(textChanged(QString)));
69 s_changedMap()->insert(QStringLiteral("QSlider"), SIGNAL(valueChanged(int)));
70 s_changedMap()->insert(QStringLiteral("QSpinBox"), SIGNAL(valueChanged(int)));
71 s_changedMap()->insert(QStringLiteral("QTextEdit"), SIGNAL(textChanged()));
72 s_changedMap()->insert(QStringLiteral("QTextBrowser"), SIGNAL(sourceChanged(QString)));
73 s_changedMap()->insert(QStringLiteral("QPlainTextEdit"), SIGNAL(textChanged()));
74 s_changedMap()->insert(QStringLiteral("QTabWidget"), SIGNAL(currentChanged(int)));
75
76 // KDE
77 s_changedMap()->insert(QStringLiteral("KComboBox"), SIGNAL(activated(int)));
78 s_changedMap()->insert(QStringLiteral("KFontComboBox"), SIGNAL(activated(int)));
79 s_changedMap()->insert(QStringLiteral("KFontRequester"), SIGNAL(fontSelected(QFont)));
80 s_changedMap()->insert(QStringLiteral("KFontChooser"), SIGNAL(fontSelected(QFont)));
81 s_changedMap()->insert(QStringLiteral("KColorCombo"), SIGNAL(activated(QColor)));
82 s_changedMap()->insert(QStringLiteral("KColorButton"), SIGNAL(changed(QColor)));
83 s_changedMap()->insert(QStringLiteral("KDatePicker"), SIGNAL(dateSelected(QDate)));
84 s_changedMap()->insert(QStringLiteral("KDateWidget"), SIGNAL(changed(QDate)));
85 s_changedMap()->insert(QStringLiteral("KDateTimeWidget"), SIGNAL(valueChanged(QDateTime)));
86 s_changedMap()->insert(QStringLiteral("KEditListWidget"), SIGNAL(changed()));
87 s_changedMap()->insert(QStringLiteral("KListWidget"), SIGNAL(itemSelectionChanged()));
88 s_changedMap()->insert(QStringLiteral("KLineEdit"), SIGNAL(textChanged(QString)));
89 s_changedMap()->insert(QStringLiteral("KRestrictedLine"), SIGNAL(textChanged(QString)));
90 s_changedMap()->insert(QStringLiteral("KTextEdit"), SIGNAL(textChanged()));
91 s_changedMap()->insert(QStringLiteral("KUrlRequester"), SIGNAL(textChanged(QString)));
92 s_changedMap()->insert(QStringLiteral("KUrlComboRequester"), SIGNAL(textChanged(QString)));
93 s_changedMap()->insert(QStringLiteral("KUrlComboBox"), SIGNAL(urlActivated(QUrl)));
94 s_changedMap()->insert(QStringLiteral("KButtonGroup"), SIGNAL(changed(int)));
95 }
96}
97
99{
100 initMaps();
101 return s_propertyMap();
102}
103
104void KConfigDialogManager::init(bool trackChanges)
105{
106 initMaps();
107 d->trackChanges = trackChanges;
108
109 // Go through all of the children of the widgets and find all known widgets
110 (void)parseChildren(d->m_dialog, trackChanges);
111}
112
114{
115 (void)parseChildren(widget, true);
116}
117
119{
120 QVariant minValue = item->minValue();
121 if (minValue.isValid()) {
122 // KSelector is using this property
123 if (widget->metaObject()->indexOfProperty("minValue") != -1) {
124 widget->setProperty("minValue", minValue);
125 }
126 if (widget->metaObject()->indexOfProperty("minimum") != -1) {
127 widget->setProperty("minimum", minValue);
128 }
129 }
130 QVariant maxValue = item->maxValue();
131 if (maxValue.isValid()) {
132 // KSelector is using this property
133 if (widget->metaObject()->indexOfProperty("maxValue") != -1) {
134 widget->setProperty("maxValue", maxValue);
135 }
136 if (widget->metaObject()->indexOfProperty("maximum") != -1) {
137 widget->setProperty("maximum", maxValue);
138 }
139 }
140
141 if (widget->whatsThis().isEmpty()) {
142 QString whatsThis = item->whatsThis();
143 if (!whatsThis.isEmpty()) {
144 widget->setWhatsThis(whatsThis);
145 }
146 }
147
148 if (widget->toolTip().isEmpty()) {
149 QString toolTip = item->toolTip();
150 if (!toolTip.isEmpty()) {
151 widget->setToolTip(toolTip);
152 }
153 }
154
155 // If it is a QGroupBox with only autoExclusive buttons
156 // and has no custom property and the config item type
157 // is an integer, assume we want to save the index like we did with
158 // KButtonGroup instead of if it is checked or not
160 if (gb && getCustomProperty(gb).isEmpty()) {
161 const KConfigSkeletonItem *item = d->m_conf->findItem(widget->objectName().mid(5));
162 if (item->property().userType() == QMetaType::Int) {
164 children.removeAll(gb->layout());
166 bool allAutoExclusiveDirectChildren = true;
167 for (QAbstractButton *button : buttons) {
168 allAutoExclusiveDirectChildren = allAutoExclusiveDirectChildren && button->autoExclusive() && button->parent() == gb;
169 }
170 if (allAutoExclusiveDirectChildren) {
171 d->allExclusiveGroupBoxes << widget;
172 }
173 }
174 }
175
176 if (!item->isEqual(property(widget))) {
177 setProperty(widget, item->property());
178 }
179
180 d->updateWidgetIndicator(item->name(), widget);
181}
182
183bool KConfigDialogManager::parseChildren(const QWidget *widget, bool trackChanges)
184{
185 bool valueChanged = false;
186 const QList<QObject *> listOfChildren = widget->children();
187 if (listOfChildren.isEmpty()) { //?? XXX
188 return valueChanged;
189 }
190
191 const QMetaMethod onWidgetModifiedSlot = metaObject()->method(metaObject()->indexOfSlot("onWidgetModified()"));
192 Q_ASSERT(onWidgetModifiedSlot.isValid() && metaObject()->indexOfSlot("onWidgetModified()") >= 0);
193
194 for (QObject *object : listOfChildren) {
195 if (!object->isWidgetType()) {
196 continue; // Skip non-widgets
197 }
198
199 QWidget *childWidget = static_cast<QWidget *>(object);
200
201 QString widgetName = childWidget->objectName();
202 bool bParseChildren = true;
203 bool bSaveInsideGroupBox = d->insideGroupBox;
204
205 if (widgetName.startsWith(QLatin1String("kcfg_"))) {
206 // This is one of our widgets!
207 QString configId = widgetName.mid(5);
208 KConfigSkeletonItem *item = d->m_conf->findItem(configId);
209 if (item) {
210 d->knownWidget.insert(configId, childWidget);
211
212 setupWidget(childWidget, item);
213
214 if (trackChanges) {
215 bool changeSignalFound = false;
216
217 if (d->allExclusiveGroupBoxes.contains(childWidget)) {
218 const QList<QAbstractButton *> buttons = childWidget->findChildren<QAbstractButton *>();
219 for (QAbstractButton *button : buttons) {
220 connect(button, &QAbstractButton::toggled, this, [this] {
221 d->onWidgetModified();
222 });
223 }
224 }
225
226 QByteArray propertyChangeSignal = getCustomPropertyChangedSignal(childWidget);
227 if (propertyChangeSignal.isEmpty()) {
228 propertyChangeSignal = getUserPropertyChangedSignal(childWidget);
229 }
230
231 if (propertyChangeSignal.isEmpty()) {
232 // get the change signal from the meta object
233 const QMetaObject *metaObject = childWidget->metaObject();
234 QByteArray userproperty = getCustomProperty(childWidget);
235 if (userproperty.isEmpty()) {
236 userproperty = getUserProperty(childWidget);
237 }
238 if (!userproperty.isEmpty()) {
239 const int indexOfProperty = metaObject->indexOfProperty(userproperty.constData());
240 if (indexOfProperty != -1) {
241 const QMetaProperty property = metaObject->property(indexOfProperty);
242 const QMetaMethod notifySignal = property.notifySignal();
243 if (notifySignal.isValid()) {
244 connect(childWidget, notifySignal, this, onWidgetModifiedSlot);
245 changeSignalFound = true;
246 }
247 }
248 } else {
249 qCWarning(KCONFIG_WIDGETS_LOG) << "Don't know how to monitor widget" << childWidget->metaObject()->className() << "for changes!";
250 }
251 } else {
252 connect(childWidget, propertyChangeSignal.constData(), this, SLOT(onWidgetModified()));
253 changeSignalFound = true;
254 }
255
256 if (changeSignalFound) {
257 QComboBox *cb = qobject_cast<QComboBox *>(childWidget);
258 if (cb && cb->isEditable()) {
260 }
261 }
262 }
263 QGroupBox *gb = qobject_cast<QGroupBox *>(childWidget);
264 if (!gb) {
265 bParseChildren = false;
266 } else {
267 d->insideGroupBox = true;
268 }
269 } else {
270 qCWarning(KCONFIG_WIDGETS_LOG) << "A widget named" << widgetName << "was found but there is no setting named" << configId;
271 }
272 } else if (QLabel *label = qobject_cast<QLabel *>(childWidget)) {
273 QWidget *buddy = label->buddy();
274 if (!buddy) {
275 continue;
276 }
277 QString buddyName = buddy->objectName();
278 if (buddyName.startsWith(QLatin1String("kcfg_"))) {
279 // This is one of our widgets!
280 QString configId = buddyName.mid(5);
281 d->buddyWidget.insert(configId, childWidget);
282 }
283 }
284 // kf5: commented out to reduce debug output
285 // #ifndef NDEBUG
286 // else if (!widgetName.isEmpty() && trackChanges)
287 // {
288 // QHash<QString, QByteArray>::const_iterator changedIt = s_changedMap()->constFind(childWidget->metaObject()->className());
289 // if (changedIt != s_changedMap()->constEnd())
290 // {
291 // if ((!d->insideGroupBox || !qobject_cast<QRadioButton*>(childWidget)) &&
292 // !qobject_cast<QGroupBox*>(childWidget) &&!qobject_cast<QTabWidget*>(childWidget) )
293 // qCDebug(KCONFIG_WIDGETS_LOG) << "Widget '" << widgetName << "' (" << childWidget->metaObject()->className() << ") remains unmanaged.";
294 // }
295 // }
296 // #endif
297
298 if (bParseChildren) {
299 // this widget is not known as something we can store.
300 // Maybe we can store one of its children.
301 valueChanged |= parseChildren(childWidget, trackChanges);
302 }
303 d->insideGroupBox = bSaveInsideGroupBox;
304 }
305 return valueChanged;
306}
307
309{
310 bool changed = false;
311 bool bSignalsBlocked = signalsBlocked();
312 blockSignals(true);
313
314 QWidget *widget;
315 QHashIterator<QString, QWidget *> it(d->knownWidget);
316 while (it.hasNext()) {
317 it.next();
318 widget = it.value();
319
320 KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
321 if (!item) {
322 qCWarning(KCONFIG_WIDGETS_LOG) << "The setting" << it.key() << "has disappeared!";
323 continue;
324 }
325
326 if (!item->isEqual(property(widget))) {
327 setProperty(widget, item->property());
328 // qCDebug(KCONFIG_WIDGETS_LOG) << "The setting" << it.key() << "[" << widget->className() << "] has changed";
329 changed = true;
330 }
331 if (item->isImmutable()) {
332 widget->setEnabled(false);
333 QWidget *buddy = d->buddyWidget.value(it.key(), nullptr);
334 if (buddy) {
335 buddy->setEnabled(false);
336 }
337 }
338 }
339 blockSignals(bSignalsBlocked);
340
341 if (changed) {
343 d->updateAllWidgetIndicators();
344 }
345}
346
348{
349 bool bUseDefaults = d->m_conf->useDefaults(true);
351 d->m_conf->useDefaults(bUseDefaults);
352 d->updateAllWidgetIndicators();
353}
354
356{
357 d->setDefaultsIndicatorsVisible(enabled);
358}
359
361{
362 bool changed = false;
363
364 QWidget *widget;
365 QHashIterator<QString, QWidget *> it(d->knownWidget);
366 while (it.hasNext()) {
367 it.next();
368 widget = it.value();
369
370 KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
371 if (!item) {
372 qCWarning(KCONFIG_WIDGETS_LOG) << "The setting" << it.key() << "has disappeared!";
373 continue;
374 }
375
376 QVariant fromWidget = property(widget);
377 if (!item->isEqual(fromWidget)) {
378 item->setProperty(fromWidget);
379 changed = true;
380 }
381 }
382 if (changed) {
383 d->m_conf->save();
385 d->updateAllWidgetIndicators();
386 }
387}
388
390{
391 MyHash *map = s_propertyMap();
392 const QMetaObject *metaObject = widget->metaObject();
393 const QString className(QLatin1String(metaObject->className()));
394 auto it = map->find(className);
395 if (it == map->end()) {
396 const QMetaProperty userProp = metaObject->userProperty();
397 if (userProp.isValid()) {
398 it = map->insert(className, userProp.name());
399 // qCDebug(KCONFIG_WIDGETS_LOG) << "class name: '" << className
400 //<< " 's USER property: " << metaProperty.name() << endl;
401 } else {
402 return QByteArray(); // no USER property
403 }
404 }
405
406 const QComboBox *cb = qobject_cast<const QComboBox *>(widget);
407 if (cb) {
408 const char *qcomboUserPropertyName = cb->QComboBox::metaObject()->userProperty().name();
409 const int qcomboUserPropertyIndex = qcomboUserPropertyName ? cb->QComboBox::metaObject()->indexOfProperty(qcomboUserPropertyName) : -1;
410 const char *widgetUserPropertyName = metaObject->userProperty().name();
411 const int widgetUserPropertyIndex = widgetUserPropertyName ? cb->metaObject()->indexOfProperty(widgetUserPropertyName) : -1;
412
413 // no custom user property set on subclass of QComboBox?
414 if (qcomboUserPropertyIndex == widgetUserPropertyIndex) {
415 return QByteArray(); // use the q/kcombobox special code
416 }
417 }
418
419 return it != map->end() ? it.value() : QByteArray{};
420}
421
423{
424 QVariant prop(widget->property("kcfg_property"));
425 if (prop.isValid()) {
426 if (!prop.canConvert<QByteArray>()) {
427 qCWarning(KCONFIG_WIDGETS_LOG) << "kcfg_property on" << widget->metaObject()->className() << "is not of type ByteArray";
428 } else {
429 return prop.toByteArray();
430 }
431 }
432 return QByteArray();
433}
434
436{
437 const QString className = QLatin1String(widget->metaObject()->className());
438 auto changedIt = s_changedMap()->constFind(className);
439
440 if (changedIt == s_changedMap()->constEnd()) {
441 // If the class name of the widget wasn't in the monitored widgets map, then look for
442 // it again using the super class name. This fixes a problem with using QtRuby/Korundum
443 // widgets with KConfigXT where 'Qt::Widget' wasn't being seen a the real deal, even
444 // though it was a 'QWidget'.
445 if (widget->metaObject()->superClass()) {
446 const QString parentClassName = QLatin1String(widget->metaObject()->superClass()->className());
447 changedIt = s_changedMap()->constFind(parentClassName);
448 }
449 }
450
451 return (changedIt == s_changedMap()->constEnd()) ? QByteArray() : *changedIt;
452}
453
455{
456 QVariant prop(widget->property("kcfg_propertyNotify"));
457 if (prop.isValid()) {
458 if (!prop.canConvert<QByteArray>()) {
459 qCWarning(KCONFIG_WIDGETS_LOG) << "kcfg_propertyNotify on" << widget->metaObject()->className() << "is not of type ByteArray";
460 } else {
461 return prop.toByteArray();
462 }
463 }
464 return QByteArray();
465}
466
468{
469 if (d->allExclusiveGroupBoxes.contains(w)) {
471 if (v.toInt() < buttons.count()) {
472 buttons[v.toInt()]->setChecked(true);
473 }
474 return;
475 }
476
477 QByteArray userproperty = getCustomProperty(w);
478 if (userproperty.isEmpty()) {
479 userproperty = getUserProperty(w);
480 }
481 if (userproperty.isEmpty()) {
483 if (cb) {
484 if (cb->isEditable()) {
485 int i = cb->findText(v.toString());
486 if (i != -1) {
487 cb->setCurrentIndex(i);
488 } else {
489 cb->setEditText(v.toString());
490 }
491 } else {
492 cb->setCurrentIndex(v.toInt());
493 }
494 return;
495 }
496 }
497 if (userproperty.isEmpty()) {
498 qCWarning(KCONFIG_WIDGETS_LOG) << w->metaObject()->className() << "widget not handled!";
499 return;
500 }
501
502 w->setProperty(userproperty.constData(), v);
503}
504
506{
507 if (d->allExclusiveGroupBoxes.contains(w)) {
509 for (int i = 0; i < buttons.count(); ++i) {
510 if (buttons[i]->isChecked()) {
511 return i;
512 }
513 }
514 return -1;
515 }
516
517 QByteArray userproperty = getCustomProperty(w);
518 if (userproperty.isEmpty()) {
519 userproperty = getUserProperty(w);
520 }
521 if (userproperty.isEmpty()) {
523 if (cb) {
524 if (cb->isEditable()) {
525 return QVariant(cb->currentText());
526 } else {
527 return QVariant(cb->currentIndex());
528 }
529 }
530 }
531 if (userproperty.isEmpty()) {
532 qCWarning(KCONFIG_WIDGETS_LOG) << w->metaObject()->className() << "widget not handled!";
533 return QVariant();
534 }
535
536 return w->property(userproperty.constData());
537}
538
540{
541 QWidget *widget;
542 QHashIterator<QString, QWidget *> it(d->knownWidget);
543 while (it.hasNext()) {
544 it.next();
545 widget = it.value();
546
547 KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
548 if (!item) {
549 qCWarning(KCONFIG_WIDGETS_LOG) << "The setting" << it.key() << "has disappeared!";
550 continue;
551 }
552
553 if (!item->isEqual(property(widget))) {
554 // qCDebug(KCONFIG_WIDGETS_LOG) << "Widget for '" << it.key() << "' has changed.";
555 return true;
556 }
557 }
558 return false;
559}
560
562{
563 QWidget *widget;
564 QHashIterator<QString, QWidget *> it(d->knownWidget);
565 while (it.hasNext()) {
566 it.next();
567 widget = it.value();
568
569 KConfigSkeletonItem *item = d->m_conf->findItem(it.key());
570 if (!item) {
571 qCWarning(KCONFIG_WIDGETS_LOG) << "The setting" << it.key() << "has disappeared!";
572 continue;
573 }
574
575 if (property(widget) != item->getDefault()) {
576 return false;
577 }
578 }
579 return true;
580}
581
582KConfigDialogManagerPrivate::KConfigDialogManagerPrivate(KConfigDialogManager *qq)
583 : q(qq)
584 , insideGroupBox(false)
585 , defaultsIndicatorsVisible(false)
586{
587}
588
589void KConfigDialogManagerPrivate::setDefaultsIndicatorsVisible(bool enabled)
590{
591 if (defaultsIndicatorsVisible != enabled) {
592 defaultsIndicatorsVisible = enabled;
593 updateAllWidgetIndicators();
594 }
595}
596
597void KConfigDialogManagerPrivate::onWidgetModified()
598{
599 const auto widget = qobject_cast<QWidget *>(q->sender());
600 Q_ASSERT(widget);
601
602 const QLatin1String prefix("kcfg_");
603 QString configId = widget->objectName();
604 if (configId.startsWith(prefix)) {
605 configId.remove(0, prefix.size());
606 updateWidgetIndicator(configId, widget);
607 } else {
608 auto *parent = qobject_cast<QWidget *>(widget->parent());
609 Q_ASSERT(parent);
610 configId = parent->objectName();
611 Q_ASSERT(configId.startsWith(prefix));
612 configId.remove(0, prefix.size());
613 updateWidgetIndicator(configId, parent);
614 }
615
616 Q_EMIT q->widgetModified();
617}
618
619void KConfigDialogManagerPrivate::updateWidgetIndicator(const QString &configId, QWidget *widget)
620{
621 const auto item = m_conf->findItem(configId);
622 Q_ASSERT(item);
623
624 const auto widgetValue = q->property(widget);
625 const auto defaultValue = item->getDefault();
626
627 const auto defaulted = widgetValue == defaultValue;
628
629 if (allExclusiveGroupBoxes.contains(widget)) {
630 const QList<QAbstractButton *> buttons = widget->findChildren<QAbstractButton *>();
631 for (int i = 0; i < buttons.count(); i++) {
632 const auto value = widgetValue.toInt() == i && !defaulted && defaultsIndicatorsVisible;
633 buttons.at(i)->setProperty("_kde_highlight_neutral", value);
634 buttons.at(i)->update();
635 }
636 } else {
637 widget->setProperty("_kde_highlight_neutral", !defaulted && defaultsIndicatorsVisible);
638 widget->update();
639 }
640}
641
642void KConfigDialogManagerPrivate::updateAllWidgetIndicators()
643{
644 QHashIterator<QString, QWidget *> it(knownWidget);
645 while (it.hasNext()) {
646 it.next();
647 updateWidgetIndicator(it.key(), it.value());
648 }
649}
650
651#include "moc_kconfigdialogmanager.cpp"
Provides a means of automatically retrieving, saving and resetting KConfigSkeleton based settings in ...
void setupWidget(QWidget *widget, KConfigSkeletonItem *item)
Setup secondary widget properties.
~KConfigDialogManager() override
Destructor.
void updateWidgetsDefault()
Traverse the specified widgets, sets the state of all known widgets according to the default state in...
QVariant property(QWidget *w) const
Retrieve a property.
static void initMaps()
Initializes the property maps.
QByteArray getCustomProperty(const QWidget *widget) const
Find the property to use for a widget by querying the "kcfg_property" property of the widget.
QByteArray getUserProperty(const QWidget *widget) const
Finds the USER property name using Qt's MetaProperty system, and caches it in the property map (the c...
void widgetModified()
If retrieveSettings() was told to track changes then if any known setting was changed this signal wil...
void setDefaultsIndicatorsVisible(bool enabled)
Show or hide an indicator when settings have changed from their default value.
static QHash< QString, QByteArray > * propertyMap()
Retrieve the map between widgets class names and the USER properties used for the configuration value...
void settingsChanged()
One or more of the settings have been saved (such as when the user clicks on the Apply button).
void updateWidgets()
Traverse the specified widgets, sets the state of all known widgets according to the state in the set...
QByteArray getUserPropertyChangedSignal(const QWidget *widget) const
Finds the changed signal of the USER property using Qt's MetaProperty system.
void setProperty(QWidget *w, const QVariant &v)
Set a property.
void addWidget(QWidget *widget)
Add additional widgets to manage.
bool hasChanged() const
Returns whether the current state of the known widgets are different from the state in the config obj...
bool parseChildren(const QWidget *widget, bool trackChanges)
Recursive function that finds all known children.
void updateSettings()
Traverse the specified widgets, saving the settings of all known widgets in the settings object.
QByteArray getCustomPropertyChangedSignal(const QWidget *widget) const
Find the changed signal of the property to use for a widget by querying the "kcfg_propertyNotify" pro...
bool isDefault() const
Returns whether the current state of the known widgets are the same as the default state in the confi...
void init(bool trackChanges)
virtual bool isEqual(const QVariant &p) const=0
bool isImmutable() const
virtual QVariant minValue() const
QString name() const
QVariant getDefault() const
QString whatsThis() const
QString toolTip() const
virtual void setProperty(const QVariant &p)=0
virtual QVariant maxValue() const
virtual QVariant property() const=0
void toggled(bool checked)
const char * constData() const const
bool isEmpty() const const
void setCurrentIndex(int index)
void editTextChanged(const QString &text)
bool isEditable() const const
int findText(const QString &text, Qt::MatchFlags flags) const const
void setEditText(const QString &text)
bool hasNext() const const
const Key & key() const const
const T & value() const const
const_reference at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
bool isValid() const const
const char * className() const const
int indexOfProperty(const char *name) const const
QMetaMethod method(int index) const const
QMetaProperty property(int index) const const
const QMetaObject * superClass() const const
QMetaProperty userProperty() const const
bool isValid() const const
const char * name() const const
Q_EMITQ_EMIT
bool blockSignals(bool block)
const QObjectList & children() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QList< T > findChildren(Qt::FindChildOptions options) const const
virtual const QMetaObject * metaObject() const const
QVariant property(const char *name) const const
T qobject_cast(QObject *object)
bool setProperty(const char *name, QVariant &&value)
bool signalsBlocked() const const
bool isEmpty() const const
QString mid(qsizetype position, qsizetype n) const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
CheckState
bool canConvert() const const
bool isValid() const const
QByteArray toByteArray() const const
int toInt(bool *ok) const const
QString toString() const const
int userType() const const
void setEnabled(bool)
QLayout * layout() const const
void update()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.