KConfig

kconfigskeleton.cpp
1/*
2 This file is part of KOrganizer.
3 SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
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
23KConfigSkeleton::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 = configGroup(config);
31
32 mReference = cg.readEntry(mKey, mDefault);
33 mLoadedValue = mReference;
34
35 readImmutability(cg);
36}
37
39{
40 mReference = qvariant_cast<QColor>(p);
41}
42
44{
45 return mReference == qvariant_cast<QColor>(v);
46}
47
49{
50 return QVariant(mReference);
51}
52
53KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue)
54 : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue)
55{
56}
57
59{
60 KConfigGroup cg = configGroup(config);
61
62 mReference = cg.readEntry(mKey, mDefault);
63 mLoadedValue = mReference;
64
65 readImmutability(cg);
66}
67
69{
70 mReference = qvariant_cast<QFont>(p);
71}
72
74{
75 return mReference == qvariant_cast<QFont>(v);
76}
77
79{
80 return QVariant(mReference);
81}
82
83KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue, const QString &key)
84{
86 item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
87 addItem(item, name);
88 return item;
89}
90
91KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue, const QString &key)
92{
94 item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
95 addItem(item, name);
96 return item;
97}
98
99#include "moc_kconfigskeleton.cpp"
A class for one specific group in a KConfig object.
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
Base class for storing a preferences setting of type T.
Class for handling a color preferences item.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file.
bool isEqual(const QVariant &p) const override
void setProperty(const QVariant &p) override
Set item to p.
ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue=QColor(128, 128, 128))
Constructor.
QVariant property() const override
Return item as property.
Class for handling a font preferences item.
void setProperty(const QVariant &p) override
Set item to p.
QVariant property() const override
Return item as property.
ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue=QFont())
Constructor.
bool isEqual(const QVariant &p) const override
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file.
ItemColor * addItemColor(const QString &name, QColor &reference, const QColor &defaultValue=QColor(128, 128, 128), const QString &key=QString())
Register an item of type QColor.
KConfigSkeleton(const QString &configname=QString(), QObject *parent=nullptr)
Constructor.
ItemFont * addItemFont(const QString &name, QFont &reference, const QFont &defaultValue=QFont(), const QString &key=QString())
Register an item of type QFont.
The central class of the KDE configuration data system.
Definition kconfig.h:56
Class for handling preferences settings for an application.
KConfig * config()
Return the KConfig object used for reading and writing the settings.
void addItem(KConfigSkeletonItem *item, const QString &name=QString())
Register a custom KConfigSkeletonItem item with a given name.
bool isNull() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.