KConfigDialogManager

Search for usage in LXR

#include <KConfigDialogManager>

Inheritance diagram for KConfigDialogManager:

Signals

void settingsChanged ()
 
void widgetModified ()
 

Public Slots

void setDefaultsIndicatorsVisible (bool enabled)
 
void updateSettings ()
 
void updateWidgets ()
 
void updateWidgetsDefault ()
 

Public Member Functions

 KConfigDialogManager (QWidget *parent, KCoreConfigSkeleton *conf)
 
 ~KConfigDialogManager () override
 
void addWidget (QWidget *widget)
 
bool hasChanged () const
 
bool isDefault () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static QHash< QString, QByteArray > * propertyMap ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

QByteArray getCustomProperty (const QWidget *widget) const
 
QByteArray getCustomPropertyChangedSignal (const QWidget *widget) const
 
QByteArray getUserProperty (const QWidget *widget) const
 
QByteArray getUserPropertyChangedSignal (const QWidget *widget) const
 
void init (bool trackChanges)
 
bool parseChildren (const QWidget *widget, bool trackChanges)
 
QVariant property (QWidget *w) const
 
void setProperty (QWidget *w, const QVariant &v)
 
void setupWidget (QWidget *widget, KConfigSkeletonItem *item)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Static Protected Member Functions

static void initMaps ()
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

Provides a means of automatically retrieving, saving and resetting KConfigSkeleton based settings in a dialog.

The KConfigDialogManager class provides a means of automatically retrieving, saving and resetting basic settings. It also can emit signals when settings have been changed (settings were saved) or modified (the user changes a checkbox from on to off).

The object names of the widgets to be managed have to correspond to the names of the configuration entries in the KConfigSkeleton object plus an additional "kcfg_" prefix. For example a widget with the object name "kcfg_MyOption" would be associated to the configuration entry "MyOption".

The widget classes of Qt and KDE Frameworks are supported out of the box, for other widgets see below:

Using Custom Widgets

Custom widget classes are supported if they have a Q_PROPERTY defined for the property representing the value edited by the widget. By default the property is used for which "USER true" is set. For using another property, see below.

Example:

A class ColorEditWidget is used in the settings UI to select a color. The color value is set and read as type QColor. For that it has a definition of the value property similar to this:

Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged USER true)
Q_PROPERTY(...)
T qobject_cast(QObject *object)

And of course it has the definition and implementation of the respective read & write methods and the notify signal. This class then can be used directly with KConfigDialogManager and does not need further setup.

Using Other Properties than The USER Property
To use a widget's property that is not the USER property, the property to use can be selected by setting onto the widget instance a property with the key "kcfg_property" and as the value the name of the property:
myWidget->setProperty("kcfg_property", QByteArray("redColorPart"));
This selection of the property to use is just valid for this widget instance. When using a UI file, the "kcfg_property" property can also be set using Qt Designer.
Configuring Classes to use Other Properties Globally

Alternatively a non-USER property can be defined for a widget class globally by registering it for the class in the KConfigDialogManager::propertyMap(). This global registration has lower priority than any "kcfg_property" property set on a class instance though, so the latter overrules this global setting. Note: setting the property in the propertyMap affects any instances of that widget class in the current application, so use only when needed and prefer instead the "kcfg_property" property. Especially with software with many libraries and 3rd-party plugins in one process there is a chance of conflicting settings.

Example:

If the ColorEditWidget has another property redColor defined by

and this one should be used in the settings, call somewhere in the code before using the settings:

KConfigDialogManager::propertyMap()->insert("ColorEditWidget", QByteArray("redColorPart"));
static QHash< QString, QByteArray > * propertyMap()
Retrieve the map between widgets class names and the USER properties used for the configuration value...
Using Different Signals than The NOTIFY Signal

If some non-default signal should be used, e.g. because the property to use does not have a NOTIFY setting, for a given widget instance the signal to use can be set by a property with the key "kcfg_propertyNotify" and as the value the signal signature. This will take priority over the signal noted by NOTIFY for the chosen property as well as the content of KConfigDialogManager::changedMap(). Since 5.32.

Example:

If for a class OtherColorEditWidget there was no NOTIFY set on the USER property, but some signal colorSelected(QColor) defined which would be good enough to reflect the settings change, defined by

Q_PROPERTY(QColor color READ color WRITE setColor USER true)
void colorSelected(const QColor &color);
Q_SIGNALSQ_SIGNALS

the signal to use would be defined by this:

myWidget->setProperty("kcfg_propertyNotify", QByteArray(SIGNAL(colorSelected(QColor))));
Author
Benjamin C Meyer <ben+kdelibs at meyerhome dot net>
Waldo Bastian basti.nosp@m.an@k.nosp@m.de.or.nosp@m.g

Definition at line 131 of file kconfigdialogmanager.h.

Constructor & Destructor Documentation

◆ KConfigDialogManager()

KConfigDialogManager::KConfigDialogManager ( QWidget * parent,
KCoreConfigSkeleton * conf )

Constructor.

Parameters
parentDialog widget to manage
confObject that contains settings

Definition at line 31 of file kconfigdialogmanager.cpp.

◆ ~KConfigDialogManager()

KConfigDialogManager::~KConfigDialogManager ( )
overridedefault

Destructor.

Member Function Documentation

◆ addWidget()

void KConfigDialogManager::addWidget ( QWidget * widget)

Add additional widgets to manage.

Parameters
widgetAdditional widget to manage, including all its children

Definition at line 109 of file kconfigdialogmanager.cpp.

◆ getCustomProperty()

QByteArray KConfigDialogManager::getCustomProperty ( const QWidget * widget) const
protected

Find the property to use for a widget by querying the "kcfg_property" property of the widget.

Like a widget can use a property other than the USER property.

Since
4.3

Definition at line 418 of file kconfigdialogmanager.cpp.

◆ getCustomPropertyChangedSignal()

QByteArray KConfigDialogManager::getCustomPropertyChangedSignal ( const QWidget * widget) const
protected

Find the changed signal of the property to use for a widget by querying the "kcfg_propertyNotify" property of the widget.

Like a widget can use a property change signal other than the one for USER property, if there even is one.

Since
5.32

Definition at line 450 of file kconfigdialogmanager.cpp.

◆ getUserProperty()

QByteArray KConfigDialogManager::getUserProperty ( const QWidget * widget) const
protected

Finds the USER property name using Qt's MetaProperty system, and caches it in the property map (the cache could be retrieved by propertyMap() ).

Definition at line 385 of file kconfigdialogmanager.cpp.

◆ getUserPropertyChangedSignal()

QByteArray KConfigDialogManager::getUserPropertyChangedSignal ( const QWidget * widget) const
protected

Finds the changed signal of the USER property using Qt's MetaProperty system.

Since
5.32

Definition at line 431 of file kconfigdialogmanager.cpp.

◆ hasChanged()

bool KConfigDialogManager::hasChanged ( ) const

Returns whether the current state of the known widgets are different from the state in the config object.

Definition at line 535 of file kconfigdialogmanager.cpp.

◆ init()

void KConfigDialogManager::init ( bool trackChanges)
protected
Parameters
trackChanges- If any changes by the widgets should be tracked set true. This causes the emitting the modified() signal when something changes. TODO:
Returns
bool - True if any setting was changed from the default.

Definition at line 100 of file kconfigdialogmanager.cpp.

◆ initMaps()

void KConfigDialogManager::initMaps ( )
staticprotected

Initializes the property maps.

Definition at line 43 of file kconfigdialogmanager.cpp.

◆ isDefault()

bool KConfigDialogManager::isDefault ( ) const

Returns whether the current state of the known widgets are the same as the default state in the config object.

Definition at line 557 of file kconfigdialogmanager.cpp.

◆ parseChildren()

bool KConfigDialogManager::parseChildren ( const QWidget * widget,
bool trackChanges )
protected

Recursive function that finds all known children.

Goes through the children of widget and if any are known and not being ignored, stores them in currentGroup. Also checks if the widget should be disabled because it is set immutable.

Parameters
widget- Parent of the children to look at.
trackChanges- If true then tracks any changes to the children of widget that are known.
Returns
bool - If a widget was set to something other than its default.

Definition at line 179 of file kconfigdialogmanager.cpp.

◆ property()

QVariant KConfigDialogManager::property ( QWidget * w) const
protected

Retrieve a property.

Definition at line 501 of file kconfigdialogmanager.cpp.

◆ propertyMap()

QHash< QString, QByteArray > * KConfigDialogManager::propertyMap ( )
static

Retrieve the map between widgets class names and the USER properties used for the configuration values.

Definition at line 94 of file kconfigdialogmanager.cpp.

◆ setDefaultsIndicatorsVisible

void KConfigDialogManager::setDefaultsIndicatorsVisible ( bool enabled)
slot

Show or hide an indicator when settings have changed from their default value.

Update all widgets to show or hide the indicator accordingly.

Since
5.73

Definition at line 351 of file kconfigdialogmanager.cpp.

◆ setProperty()

void KConfigDialogManager::setProperty ( QWidget * w,
const QVariant & v )
protected

Set a property.

Definition at line 463 of file kconfigdialogmanager.cpp.

◆ settingsChanged

void KConfigDialogManager::settingsChanged ( )
signal

One or more of the settings have been saved (such as when the user clicks on the Apply button).

This is only emitted by updateSettings() whenever one or more setting were changed and consequently saved.

◆ setupWidget()

void KConfigDialogManager::setupWidget ( QWidget * widget,
KConfigSkeletonItem * item )
protected

Setup secondary widget properties.

Definition at line 114 of file kconfigdialogmanager.cpp.

◆ updateSettings

void KConfigDialogManager::updateSettings ( )
slot

Traverse the specified widgets, saving the settings of all known widgets in the settings object.

Example use: User clicks Ok or Apply button in a configure dialog.

Definition at line 356 of file kconfigdialogmanager.cpp.

◆ updateWidgets

void KConfigDialogManager::updateWidgets ( )
slot

Traverse the specified widgets, sets the state of all known widgets according to the state in the settings object.

Example use: Initialisation of dialog. Example use: User clicks Reset button in a configure dialog.

Definition at line 304 of file kconfigdialogmanager.cpp.

◆ updateWidgetsDefault

void KConfigDialogManager::updateWidgetsDefault ( )
slot

Traverse the specified widgets, sets the state of all known widgets according to the default state in the settings object.

Example use: User clicks Defaults button in a configure dialog.

Definition at line 343 of file kconfigdialogmanager.cpp.

◆ widgetModified

void KConfigDialogManager::widgetModified ( )
signal

If retrieveSettings() was told to track changes then if any known setting was changed this signal will be emitted.

Note that a settings can be modified several times and might go back to the original saved state. hasChanged() will tell you if anything has actually changed from the saved values.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.