File indexing completed on 2024-11-17 05:01:38

0001 /* This file is part of the KDE libraries
0002     SPDX-FileCopyrightText: 2000, 2006 David Faure <faure@kde.org>
0003     SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
0004     SPDX-FileCopyrightText: 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #ifndef KFONTSETTINGSDATA_H
0010 #define KFONTSETTINGSDATA_H
0011 
0012 #include <QDBusVariant>
0013 #include <QFont>
0014 #include <QObject>
0015 #include <ksharedconfig.h>
0016 
0017 struct KFontData {
0018     const char *ConfigGroupKey;
0019     const char *ConfigKey;
0020     const char *FontName;
0021     int Size;
0022     int Weight;
0023     QFont::StyleHint StyleHint;
0024     const char *StyleName;
0025 };
0026 
0027 class KFontSettingsData : public QObject
0028 {
0029     Q_OBJECT
0030 public:
0031     // if adding a new type here also add an entry to DefaultFontData
0032     enum FontTypes {
0033         GeneralFont = 0,
0034         FixedFont,
0035         ToolbarFont,
0036         MenuFont,
0037         WindowTitleFont,
0038         TaskbarFont,
0039         SmallestReadableFont,
0040         FontTypesCount,
0041     };
0042 
0043 public:
0044     KFontSettingsData();
0045     ~KFontSettingsData() override;
0046 
0047 public Q_SLOTS:
0048     void dropFontSettingsCache();
0049 
0050 private Q_SLOTS:
0051     void delayedDBusConnects();
0052     void slotPortalSettingChanged(const QString &group, const QString &key, const QDBusVariant &value);
0053 
0054 public: // access, is not const due to caching
0055     QFont *font(FontTypes fontType);
0056 
0057 private:
0058     QString readConfigValue(const QString &group, const QString &key, const QString &defaultValue = QString()) const;
0059 
0060     bool mUsePortal;
0061     QFont *mFonts[FontTypesCount];
0062     KSharedConfigPtr mKdeGlobals;
0063 };
0064 
0065 #endif // KFONTSETTINGSDATA_H