Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/fonts.h
Show All 27 Lines | |||||
28 | #define FONTS_H | 28 | #define FONTS_H | ||
29 | 29 | | |||
30 | #include <config-X11.h> | 30 | #include <config-X11.h> | ||
31 | #include <QAbstractItemModel> | 31 | #include <QAbstractItemModel> | ||
32 | #include <QStandardItemModel> | 32 | #include <QStandardItemModel> | ||
33 | 33 | | |||
34 | #include <KQuickAddons/ManagedConfigModule> | 34 | #include <KQuickAddons/ManagedConfigModule> | ||
35 | 35 | | |||
36 | #include "kxftconfig.h" | | |||
37 | | ||||
38 | class FontsSettings; | 36 | class FontsSettings; | ||
39 | 37 | class FontsAASettings; | |||
40 | class FontAASettings : public QObject | | |||
41 | { | | |||
42 | Q_OBJECT | | |||
43 | | ||||
44 | Q_PROPERTY(QAbstractItemModel *subPixelOptionsModel READ subPixelOptionsModel CONSTANT) | | |||
45 | Q_PROPERTY(int subPixelCurrentIndex READ subPixelCurrentIndex WRITE setSubPixelCurrentIndex NOTIFY subPixelCurrentIndexChanged) | | |||
46 | Q_PROPERTY(QAbstractItemModel *hintingOptionsModel READ hintingOptionsModel CONSTANT) | | |||
47 | Q_PROPERTY(int hintingCurrentIndex READ hintingCurrentIndex WRITE setHintingCurrentIndex NOTIFY hintingCurrentIndexChanged) | | |||
48 | | ||||
49 | Q_PROPERTY(bool exclude READ exclude WRITE setExclude NOTIFY excludeChanged) | | |||
50 | Q_PROPERTY(int excludeTo READ excludeTo WRITE setExcludeTo NOTIFY excludeToChanged) | | |||
51 | Q_PROPERTY(int excludeFrom READ excludeFrom WRITE setExcludeFrom NOTIFY excludeFromChanged) | | |||
52 | Q_PROPERTY(bool antiAliasing READ antiAliasing WRITE setAntiAliasing NOTIFY aliasingChanged) | | |||
53 | Q_PROPERTY(int dpi READ dpi WRITE setDpi NOTIFY dpiChanged) | | |||
54 | | ||||
55 | struct State | | |||
56 | { | | |||
57 | bool exclude; | | |||
58 | int excludeFrom; | | |||
59 | int excludeTo; | | |||
60 | int antiAliasing; | | |||
61 | bool antiAliasingHasLocalConfig; | | |||
62 | bool subPixelHasLocalConfig; | | |||
63 | bool hintingHasLocalConfig; | | |||
64 | int dpi; | | |||
65 | int subPixel; | | |||
66 | int hinting; | | |||
67 | | ||||
68 | bool operator==(const State& other) const; | | |||
69 | bool operator!=(const State& other) const; | | |||
70 | }; | | |||
71 | | ||||
72 | public: | | |||
73 | enum AASetting { AAEnabled, AASystem, AADisabled }; | | |||
74 | #if defined(HAVE_FONTCONFIG) && HAVE_X11 | | |||
75 | FontAASettings(QObject *parent); | | |||
76 | | ||||
77 | bool save(KXftConfig::AntiAliasing::State aaState); | | |||
78 | void load(); | | |||
79 | void defaults(); | | |||
80 | QAbstractItemModel* subPixelOptionsModel() { return m_subPixelOptionsModel; } | | |||
81 | QAbstractItemModel* hintingOptionsModel() { return m_hintingOptionsModel; } | | |||
82 | | ||||
83 | void setExclude(bool exclude); | | |||
84 | bool exclude() const; | | |||
85 | | ||||
86 | void setExcludeTo(int excludeTo); | | |||
87 | int excludeTo() const; | | |||
88 | | ||||
89 | void setExcludeFrom(int excludeFrom); | | |||
90 | int excludeFrom() const; | | |||
91 | | ||||
92 | void setAntiAliasing(bool antiAliasing); | | |||
93 | bool antiAliasing() const; | | |||
94 | | ||||
95 | bool antiAliasingNeedsSave() const; | | |||
96 | bool subPixelNeedsSave() const; | | |||
97 | bool hintingNeedsSave() const; | | |||
98 | | ||||
99 | void setDpi(const int &dpi); | | |||
100 | int dpi() const; | | |||
101 | | ||||
102 | int subPixelCurrentIndex(); | | |||
103 | void setSubPixelCurrentIndex(int idx); | | |||
104 | void setSubPixel(int idx); | | |||
105 | int hintingCurrentIndex(); | | |||
106 | void setHintingCurrentIndex(int idx); | | |||
107 | void setHinting(int idx); | | |||
108 | | ||||
109 | bool needsSave() const; | | |||
110 | bool isDefaults() const; | | |||
111 | | ||||
112 | #endif | | |||
113 | | ||||
114 | Q_SIGNALS: | | |||
115 | void excludeChanged(); | | |||
116 | void excludeToChanged(); | | |||
117 | void excludeFromChanged(); | | |||
118 | void antiAliasingChanged(); | | |||
119 | void aliasingChangeApplied(); | | |||
120 | void aliasingChanged(); | | |||
121 | void dpiChanged(); | | |||
122 | void subPixelCurrentIndexChanged(); | | |||
123 | void hintingCurrentIndexChanged(); | | |||
124 | | ||||
125 | #if defined(HAVE_FONTCONFIG) && HAVE_X11 | | |||
126 | private: | | |||
127 | State m_state; | | |||
128 | State m_originalState; | | |||
129 | QStandardItemModel *m_subPixelOptionsModel; | | |||
130 | QStandardItemModel *m_hintingOptionsModel; | | |||
131 | #endif | | |||
132 | }; | | |||
133 | 38 | | |||
134 | /** | 39 | /** | ||
135 | * The Desktop/fonts tab in kcontrol. | 40 | * The Desktop/fonts tab in kcontrol. | ||
136 | */ | 41 | */ | ||
137 | class KFonts : public KQuickAddons::ManagedConfigModule | 42 | class KFonts : public KQuickAddons::ManagedConfigModule | ||
138 | { | 43 | { | ||
139 | Q_OBJECT | 44 | Q_OBJECT | ||
140 | Q_PROPERTY(FontsSettings *fontsSettings READ fontsSettings CONSTANT) | 45 | Q_PROPERTY(FontsSettings *fontsSettings READ fontsSettings CONSTANT) | ||
141 | Q_PROPERTY(QObject *fontAASettings READ fontAASettings CONSTANT) | 46 | Q_PROPERTY(FontsAASettings *fontsAASettings READ fontsAASettings CONSTANT) | ||
47 | Q_PROPERTY(QAbstractItemModel *subPixelOptionsModel READ subPixelOptionsModel CONSTANT) | ||||
48 | Q_PROPERTY(int subPixelCurrentIndex READ subPixelCurrentIndex WRITE setSubPixelCurrentIndex NOTIFY subPixelCurrentIndexChanged) | ||||
49 | Q_PROPERTY(QAbstractItemModel *hintingOptionsModel READ hintingOptionsModel CONSTANT) | ||||
50 | Q_PROPERTY(int hintingCurrentIndex READ hintingCurrentIndex WRITE setHintingCurrentIndex NOTIFY hintingCurrentIndexChanged) | ||||
142 | 51 | | |||
143 | public: | 52 | public: | ||
144 | KFonts(QObject *parent, const QVariantList &); | 53 | KFonts(QObject *parent, const QVariantList &); | ||
145 | ~KFonts() override; | 54 | ~KFonts() override; | ||
146 | 55 | | |||
147 | FontsSettings *fontsSettings() const; | 56 | FontsSettings *fontsSettings() const; | ||
57 | FontsAASettings *fontsAASettings() const; | ||||
148 | 58 | | |||
149 | QObject* fontAASettings() { return m_fontAASettings; } | 59 | int subPixelCurrentIndex() const; | ||
60 | void setHintingCurrentIndex(int idx); | ||||
61 | int hintingCurrentIndex() const; | ||||
62 | void setSubPixelCurrentIndex(int idx); | ||||
63 | QAbstractItemModel *subPixelOptionsModel() const; | ||||
64 | QAbstractItemModel *hintingOptionsModel() const; | ||||
150 | 65 | | |||
151 | public Q_SLOTS: | 66 | public Q_SLOTS: | ||
152 | void load() override; | 67 | void load() override; | ||
153 | void save() override; | 68 | void save() override; | ||
154 | void defaults() override; | | |||
155 | Q_INVOKABLE void adjustAllFonts(); | 69 | Q_INVOKABLE void adjustAllFonts(); | ||
156 | 70 | | |||
157 | Q_SIGNALS: | 71 | Q_SIGNALS: | ||
158 | void fontsHaveChanged(); | 72 | void fontsHaveChanged(); | ||
73 | void hintingCurrentIndexChanged(); | ||||
74 | void subPixelCurrentIndexChanged(); | ||||
75 | void aliasingChangeApplied(); | ||||
159 | 76 | | |||
160 | private: | 77 | private: | ||
161 | bool isSaveNeeded() const override; | | |||
162 | bool isDefaults() const override; | | |||
163 | QFont applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags); | 78 | QFont applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags); | ||
164 | void setNearestExistingFonts(); | 79 | void setNearestExistingFonts(); | ||
165 | 80 | | |||
166 | FontsSettings *m_settings; | 81 | FontsSettings *m_settings; | ||
167 | 82 | FontsAASettings *m_settingsAA; | |||
168 | FontAASettings *m_fontAASettings; | 83 | QStandardItemModel *m_subPixelOptionsModel; | ||
84 | QStandardItemModel *m_hintingOptionsModel; | ||||
169 | }; | 85 | }; | ||
170 | 86 | | |||
171 | #endif | 87 | #endif | ||
172 | 88 | |