KConfig

kconfigskeleton.cpp
1 /*
2  This file is part of KOrganizer.
3  SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <[email protected]>
4  SPDX-FileCopyrightText: 2003 Waldo Bastian <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "kconfigskeleton.h"
10 
11 #include <kcoreconfigskeleton_p.h>
12 
14  : KCoreConfigSkeleton(configname, parent)
15 {
16 }
17 
19  : KCoreConfigSkeleton(std::move(pConfig), parent)
20 {
21 }
22 
23 KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue)
24  : KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue)
25 {
26 }
27 
29 {
30  KConfigGroup cg(config, mGroup);
31  mReference = cg.readEntry(mKey, mDefault);
32  mLoadedValue = mReference;
33 
34  readImmutability(cg);
35 }
36 
38 {
39  mReference = qvariant_cast<QColor>(p);
40 }
41 
43 {
44  return mReference == qvariant_cast<QColor>(v);
45 }
46 
48 {
49  return QVariant(mReference);
50 }
51 
52 KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue)
53  : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue)
54 {
55 }
56 
58 {
59  KConfigGroup cg(config, mGroup);
60  mReference = cg.readEntry(mKey, mDefault);
61  mLoadedValue = mReference;
62 
63  readImmutability(cg);
64 }
65 
67 {
68  mReference = qvariant_cast<QFont>(p);
69 }
70 
72 {
73  return mReference == qvariant_cast<QFont>(v);
74 }
75 
77 {
78  return QVariant(mReference);
79 }
80 
82 {
84  item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
85  addItem(item, name);
86  return item;
87 }
88 
89 KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue, const QString &key)
90 {
92  item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
93  addItem(item, name);
94  return item;
95 }
KConfig * config()
Return the KConfig object used for reading and writing the settings.
QVariant property() const override
Return item as property.
ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue=QFont())
bool isEqual(const QVariant &p) const override
void setProperty(const QVariant &p) override
Set item to p.
QVariant property() const override
Return item as property.
ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue=QColor(128, 128, 128))
bool isNull() const const
Class for handling a font preferences item.
KConfigSkeleton(const QString &configname=QString(), QObject *parent=nullptr)
Constructor.
Class for handling preferences settings for an application.
void setProperty(const QVariant &p) override
Set item to p.
QString name() const
Return internal name of entry.
ItemFont * addItemFont(const QString &name, QFont &reference, const QFont &defaultValue=QFont(), const QString &key=QString())
Register an item of type QFont.
QString key() const
Return config file key.
ItemColor * addItemColor(const QString &name, QColor &reference, const QColor &defaultValue=QColor(128, 128, 128), const QString &key=QString())
Register an item of type QColor.
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:38
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
The central class of the KDE configuration data system.
Definition: kconfig.h:56
void readImmutability(const KConfigGroup &group)
sets mIsImmutable to true if mKey in config is immutable
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
QString mKey
The config key for this item.
void addItem(KConfigSkeletonItem *, const QString &name=QString())
Register a custom KConfigSkeletonItem with a given name.
Class for handling a color preferences item.
QString mGroup
The group name for this item.
QObject * parent() const const
bool isEqual(const QVariant &p) const override
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfiggroup.h:258
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 22:51:32 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.