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 
24  QColor &reference,
25  const QColor &defaultValue)
26  : KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue)
27 {
28 }
29 
31 {
32  KConfigGroup cg(config, mGroup);
33  mReference = cg.readEntry(mKey, mDefault);
34  mLoadedValue = mReference;
35 
36  readImmutability(cg);
37 }
38 
40 {
41  mReference = qvariant_cast<QColor>(p);
42 }
43 
45 {
46  return mReference == qvariant_cast<QColor>(v);
47 }
48 
50 {
51  return QVariant(mReference);
52 }
53 
55  QFont &reference,
56  const QFont &defaultValue)
57  : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue)
58 {
59 }
60 
62 {
63  KConfigGroup cg(config, mGroup);
64  mReference = cg.readEntry(mKey, mDefault);
65  mLoadedValue = mReference;
66 
67  readImmutability(cg);
68 }
69 
71 {
72  mReference = qvariant_cast<QFont>(p);
73 }
74 
76 {
77  return mReference == qvariant_cast<QFont>(v);
78 }
79 
81 {
82  return QVariant(mReference);
83 }
84 
86  const QColor &defaultValue, const QString &key)
87 {
89  item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key,
90  reference, defaultValue);
91  addItem(item, name);
92  return item;
93 }
94 
96  const QFont &defaultValue, const QString &key)
97 {
99  item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key,
100  reference, defaultValue);
101  addItem(item, name);
102  return item;
103 }
104 
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:250
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 14 2020 22:47:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.