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 
81 KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue, const QString &key)
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 }
bool isNull() const const
ItemColor * addItemColor(const QString &name, QColor &reference, const QColor &defaultValue=QColor(128, 128, 128), const QString &key=QString())
Register an item of type QColor.
QVariant property() const override
Return item as property.
Class for handling preferences settings for an application.
The central class of the KDE configuration data system.
Definition: kconfig.h:56
ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue=QColor(128, 128, 128))
Constructor.
ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue=QFont())
Constructor.
bool isEqual(const QVariant &p) const override
Class for handling a font preferences item.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file.
KConfigSkeleton(const QString &configname=QString(), QObject *parent=nullptr)
Constructor.
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
void setProperty(const QVariant &p) override
Set item to p.
ItemFont * addItemFont(const QString &name, QFont &reference, const QFont &defaultValue=QFont(), const QString &key=QString())
Register an item of type QFont.
void addItem(KConfigSkeletonItem *item, const QString &name=QString())
Register a custom KConfigSkeletonItem item with a given name.
Base class for storing a preferences setting of type T.
Class for handling a color preferences item.
QVariant property() const override
Return item as property.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file.
KConfig * config()
Return the KConfig object used for reading and writing the settings.
void setProperty(const QVariant &p) override
Set item to p.
bool isEqual(const QVariant &p) const override
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Jun 28 2022 04:08:29 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.