KConfig 5.109.0
Classes | Public Member Functions | List of all members
KConfigSkeleton

Class for handling preferences settings for an application. More...

#include <KConfigSkeleton>

Classes

class  ItemColor
 Class for handling a color preferences item. More...
 
class  ItemFont
 Class for handling a font preferences item. More...
 

Public Member Functions

 KConfigSkeleton (const QString &configname=QString(), QObject *parent=nullptr)
 Constructor.
 
 KConfigSkeleton (KSharedConfig::Ptr config, QObject *parent=nullptr)
 Constructor.
 
ItemColoraddItemColor (const QString &name, QColor &reference, const QColor &defaultValue=QColor(128, 128, 128), const QString &key=QString())
 Register an item of type QColor.
 
ItemFontaddItemFont (const QString &name, QFont &reference, const QFont &defaultValue=QFont(), const QString &key=QString())
 Register an item of type QFont.
 
- Public Member Functions inherited from KCoreConfigSkeleton
 KCoreConfigSkeleton (const QString &configname=QString(), QObject *parent=nullptr)
 Constructor.
 
 KCoreConfigSkeleton (KSharedConfig::Ptr config, QObject *parent=nullptr)
 Constructor.
 
 ~KCoreConfigSkeleton () override
 Destructor.
 
void addItem (KConfigSkeletonItem *item, const QString &name=QString())
 Register a custom KConfigSkeletonItem item with a given name.
 
ItemBooladdItemBool (const QString &name, bool &reference, bool defaultValue=false, const QString &key=QString())
 Register an item of type bool.
 
ItemDateTimeaddItemDateTime (const QString &name, QDateTime &reference, const QDateTime &defaultValue=QDateTime(), const QString &key=QString())
 Register an item of type QDateTime.
 
ItemDoubleaddItemDouble (const QString &name, double &reference, double defaultValue=0.0, const QString &key=QString())
 Register an item of type double.
 
ItemIntaddItemInt (const QString &name, qint32 &reference, qint32 defaultValue=0, const QString &key=QString())
 Register an item of type qint32.
 
ItemLongLongaddItemInt64 (const QString &name, qint64 &reference, qint64 defaultValue=0, const QString &key=QString())
 
ItemIntListaddItemIntList (const QString &name, QList< int > &reference, const QList< int > &defaultValue=QList< int >(), const QString &key=QString())
 Register an item of type QList<int>.
 
ItemLongLongaddItemLongLong (const QString &name, qint64 &reference, qint64 defaultValue=0, const QString &key=QString())
 Register an item of type qint64.
 
ItemPasswordaddItemPassword (const QString &name, QString &reference, const QString &defaultValue=QLatin1String(""), const QString &key=QString())
 Register a password item of type QString.
 
ItemPathaddItemPath (const QString &name, QString &reference, const QString &defaultValue=QLatin1String(""), const QString &key=QString())
 Register a path item of type QString.
 
ItemPointaddItemPoint (const QString &name, QPoint &reference, const QPoint &defaultValue=QPoint(), const QString &key=QString())
 Register an item of type QPoint.
 
ItemPropertyaddItemProperty (const QString &name, QVariant &reference, const QVariant &defaultValue=QVariant(), const QString &key=QString())
 Register a property item of type QVariant.
 
ItemRectaddItemRect (const QString &name, QRect &reference, const QRect &defaultValue=QRect(), const QString &key=QString())
 Register an item of type QRect.
 
ItemSizeaddItemSize (const QString &name, QSize &reference, const QSize &defaultValue=QSize(), const QString &key=QString())
 Register an item of type QSize.
 
ItemStringaddItemString (const QString &name, QString &reference, const QString &defaultValue=QLatin1String(""), const QString &key=QString())
 Register an item of type QString.
 
ItemStringListaddItemStringList (const QString &name, QStringList &reference, const QStringList &defaultValue=QStringList(), const QString &key=QString())
 Register an item of type QStringList.
 
ItemUIntaddItemUInt (const QString &name, quint32 &reference, quint32 defaultValue=0, const QString &key=QString())
 Register an item of type quint32.
 
ItemULongLongaddItemUInt64 (const QString &name, quint64 &reference, quint64 defaultValue=0, const QString &key=QString())
 
ItemULongLongaddItemULongLong (const QString &name, quint64 &reference, quint64 defaultValue=0, const QString &key=QString())
 Register an item of type quint64.
 
void clearItems ()
 Removes and deletes all items.
 
KConfigconfig ()
 Return the KConfig object used for reading and writing the settings.
 
const KConfigconfig () const
 Return the KConfig object used for reading and writing the settings.
 
QString currentGroup () const
 Returns the current group used for addItem() calls.
 
KConfigSkeletonItemfindItem (const QString &name) const
 Lookup item by name.
 
bool isDefaults () const
 Indicates if all the registered items are set to their default value.
 
bool isImmutable (const QString &name) const
 Return whether a certain item is immutable.
 
bool isSaveNeeded () const
 Indicates if any registered item has a different value than the previously loaded value.
 
KConfigSkeletonItem::List items () const
 Return list of items managed by this KCoreConfigSkeleton object.
 
void load ()
 Read preferences from config file.
 
void read ()
 Read preferences from the KConfig object.
 
void readConfig ()
 
void removeItem (const QString &name)
 Removes and deletes an item by name.
 
void setCurrentGroup (const QString &group)
 Set the config file group for subsequent addItem() calls.
 
virtual void setDefaults ()
 Set all registered items to their default values.
 
void setSharedConfig (KSharedConfig::Ptr pConfig)
 Set the KSharedConfig object used for reading and writing the settings.
 
KSharedConfig::Ptr sharedConfig () const
 Return the KConfig object used for reading and writing the settings.
 
virtual bool useDefaults (bool b)
 Specify whether this object should reflect the actual values or the default values.
 

Additional Inherited Members

- Public Types inherited from KCoreConfigSkeleton
typedef ItemLongLong ItemInt64
 
typedef ItemULongLong ItemUInt64
 
- Signals inherited from KCoreConfigSkeleton
void configChanged ()
 This signal is emitted when the configuration change.
 
- Public Slots inherited from KCoreConfigSkeleton
bool save ()
 Write preferences to config file.
 
void writeConfig ()
 
- Protected Member Functions inherited from KCoreConfigSkeleton
virtual void usrRead ()
 Perform the actual reading of the configuration file.
 
virtual void usrReadConfig ()
 
virtual bool usrSave ()
 Perform the actual writing of the configuration file.
 
virtual void usrSetDefaults ()
 Perform the actual setting of default values.
 
virtual bool usrUseDefaults (bool b)
 Implemented by subclasses that use special defaults.
 
virtual bool usrWriteConfig ()
 

Detailed Description

Class for handling preferences settings for an application.

Author
Cornelius Schumacher

This class extends KCoreConfigSkeleton by support for GUI types.

Constructor & Destructor Documentation

◆ KConfigSkeleton() [1/2]

KConfigSkeleton::KConfigSkeleton ( const QString &  configname = QString(),
QObject *  parent = nullptr 
)
explicit

Constructor.

Parameters
confignamename of config file. If no name is given, the default config file as returned by KSharedConfig::openConfig() is used.

◆ KConfigSkeleton() [2/2]

KConfigSkeleton::KConfigSkeleton ( KSharedConfig::Ptr  config,
QObject *  parent = nullptr 
)
explicit

Constructor.

Parameters
configconfiguration object to use.

Member Function Documentation

◆ addItemColor()

ItemColor * KConfigSkeleton::addItemColor ( const QString &  name,
QColor &  reference,
const QColor &  defaultValue = QColor(128, 128, 128),
const QString &  key = QString() 
)

Register an item of type QColor.

Parameters
nameName used to identify this setting. Names must be unique.
referencePointer to the variable, which is set by read() calls and read by save() calls.
defaultValueDefault value, which is used when the config file does not yet contain the key of this item.
keyKey used in config file. If key is a null string, name is used as key.
Returns
The created item

◆ addItemFont()

ItemFont * KConfigSkeleton::addItemFont ( const QString &  name,
QFont &  reference,
const QFont &  defaultValue = QFont(),
const QString &  key = QString() 
)

Register an item of type QFont.

Parameters
nameName used to identify this setting. Names must be unique.
referencePointer to the variable, which is set by read() calls and read by save() calls.
defaultValueDefault value, which is used when the config file does not yet contain the key of this item.
keyKey used in config file. If key is a null string, name is used as key.
Returns
The created item