File indexing completed on 2024-05-19 05:38:05

0001 /*
0002     SPDX-FileCopyrightText: 1997 Mark Donohoe
0003     SPDX-FileCopyrightText: 1999 Lars Knoll
0004     SPDX-FileCopyrightText: 2000 Rik Hemsley
0005     SPDX-FileCopyrightText: 2015 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org>
0006     SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org>
0007     SPDX-FileCopyrightText: 2019 Benjamin Port <benjamin.port@enioka.com>
0008 
0009     Ported to kcontrol2:
0010     SPDX-FileCopyrightText: Geert Jansen
0011 
0012     SPDX-License-Identifier: LGPL-2.0-or-later
0013 */
0014 
0015 #pragma once
0016 
0017 #include <QAbstractItemModel>
0018 #include <QStandardItemModel>
0019 #include <config-X11.h>
0020 
0021 #include <KQuickManagedConfigModule>
0022 
0023 #include "fontsaasettings.h"
0024 #include "fontssettings.h"
0025 
0026 class FontsData;
0027 
0028 /**
0029  * The Desktop/fonts tab in kcontrol.
0030  */
0031 class KFonts : public KQuickManagedConfigModule
0032 {
0033     Q_OBJECT
0034     Q_PROPERTY(FontsSettings *fontsSettings READ fontsSettings CONSTANT)
0035     Q_PROPERTY(FontsAASettings *fontsAASettings READ fontsAASettings CONSTANT)
0036     Q_PROPERTY(QAbstractItemModel *subPixelOptionsModel READ subPixelOptionsModel CONSTANT)
0037     Q_PROPERTY(int subPixelCurrentIndex READ subPixelCurrentIndex WRITE setSubPixelCurrentIndex NOTIFY subPixelCurrentIndexChanged)
0038     Q_PROPERTY(QAbstractItemModel *hintingOptionsModel READ hintingOptionsModel CONSTANT)
0039     Q_PROPERTY(int hintingCurrentIndex READ hintingCurrentIndex WRITE setHintingCurrentIndex NOTIFY hintingCurrentIndexChanged)
0040 
0041 public:
0042     KFonts(QObject *parent, const KPluginMetaData &metaData);
0043     ~KFonts() override;
0044 
0045     FontsSettings *fontsSettings() const;
0046     FontsAASettings *fontsAASettings() const;
0047 
0048     int subPixelCurrentIndex() const;
0049     void setHintingCurrentIndex(int idx);
0050     int hintingCurrentIndex() const;
0051     void setSubPixelCurrentIndex(int idx);
0052     QAbstractItemModel *subPixelOptionsModel() const;
0053     QAbstractItemModel *hintingOptionsModel() const;
0054 
0055 public Q_SLOTS:
0056     void load() override;
0057     void save() override;
0058     Q_INVOKABLE void adjustAllFonts();
0059     Q_INVOKABLE void adjustFont(const QFont &font, const QString &category);
0060 
0061 Q_SIGNALS:
0062     void fontsHaveChanged();
0063     void hintingCurrentIndexChanged();
0064     void subPixelCurrentIndexChanged();
0065     void aliasingChangeApplied();
0066     void fontDpiSettingsChanged();
0067 
0068 private:
0069     QFont applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags);
0070 
0071     FontsData *m_data;
0072     QStandardItemModel *m_subPixelOptionsModel;
0073     QStandardItemModel *m_hintingOptionsModel;
0074 };