Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/fonts.h
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright 1997 Mark Donohoe | 2 | Copyright 1997 Mark Donohoe | ||
3 | Copyright 1999 Lars Knoll | 3 | Copyright 1999 Lars Knoll | ||
4 | Copyright 2000 Rik Hemsley | 4 | Copyright 2000 Rik Hemsley | ||
5 | Copyright 2015 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org> | ||||
6 | Copyright 2017 Marco Martin <mart@kde.org> | ||||
5 | 7 | | |||
6 | Ported to kcontrol2 by Geert Jansen. | 8 | Ported to kcontrol2 by Geert Jansen. | ||
7 | 9 | | |||
8 | This library is free software; you can redistribute it and/or | 10 | This library is free software; you can redistribute it and/or | ||
9 | modify it under the terms of the GNU Library General Public | 11 | modify it under the terms of the GNU Library General Public | ||
10 | License as published by the Free Software Foundation; either | 12 | License as published by the Free Software Foundation; either | ||
11 | version 2 of the License, or (at your option) any later version. | 13 | version 2 of the License, or (at your option) any later version. | ||
12 | 14 | | |||
13 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | Library General Public License for more details. | 18 | Library General Public License for more details. | ||
17 | 19 | | |||
18 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License | ||
19 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to | ||
20 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 22 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
21 | Boston, MA 02110-1301, USA. | 23 | Boston, MA 02110-1301, USA. | ||
22 | */ | 24 | */ | ||
23 | 25 | | |||
24 | #ifndef FONTS_H | 26 | #ifndef FONTS_H | ||
25 | #define FONTS_H | 27 | #define FONTS_H | ||
26 | 28 | | |||
27 | #include <QDialog> | | |||
28 | #include <QLabel> | | |||
29 | #include <QList> | | |||
30 | #include <config-X11.h> | 29 | #include <config-X11.h> | ||
30 | #include <QAbstractItemModel> | ||||
31 | #include <QStandardItemModel> | ||||
31 | 32 | | |||
32 | #include <KCModule> | 33 | #include <KQuickAddons/ConfigModule> | ||
33 | #include <KFontRequester> | | |||
34 | 34 | | |||
35 | #include "kxftconfig.h" | 35 | #include "kxftconfig.h" | ||
36 | 36 | | |||
37 | class QCheckBox; | 37 | class FontAASettings : public QObject | ||
38 | class QComboBox; | | |||
39 | class QDoubleSpinBox; | | |||
40 | class QSpinBox; | | |||
41 | class FontAASettings; | | |||
42 | | ||||
43 | class FontUseItem : public KFontRequester | | |||
44 | { | 38 | { | ||
45 | Q_OBJECT | 39 | Q_OBJECT | ||
46 | 40 | | |||
47 | public: | 41 | Q_PROPERTY(QAbstractItemModel *subPixelOptionsModel READ subPixelOptionsModel CONSTANT) | ||
48 | FontUseItem(QWidget *parent, const QString &name, const QString &grp, | 42 | Q_PROPERTY(int subPixelCurrentIndex READ subPixelCurrentIndex WRITE setSubPixelCurrentIndex NOTIFY subPixelCurrentIndexChanged); | ||
49 | const QString &key, const QString &rc, const QFont &default_fnt, | 43 | Q_PROPERTY(QAbstractItemModel *hintingOptionsModel READ hintingOptionsModel CONSTANT) | ||
50 | bool fixed = false); | 44 | Q_PROPERTY(int hintingCurrentIndex READ hintingCurrentIndex WRITE setHintingCurrentIndex NOTIFY hintingCurrentIndexChanged); | ||
51 | 45 | | |||
52 | void readFont(); | 46 | Q_PROPERTY(bool exclude READ exclude WRITE setExclude NOTIFY excludeChanged) | ||
53 | void writeFont(); | 47 | Q_PROPERTY(int excludeTo READ excludeTo WRITE setExcludeTo NOTIFY excludeToChanged) | ||
54 | void setDefault(); | 48 | Q_PROPERTY(int excludeFrom READ excludeFrom WRITE setExcludeFrom NOTIFY excludeFromChanged) | ||
55 | void applyFontDiff(const QFont &fnt, int fontDiffFlags); | 49 | Q_PROPERTY(int antiAliasing READ antiAliasing WRITE setAntiAliasing NOTIFY aliasingChanged) | ||
56 | 50 | Q_PROPERTY(int dpi READ dpi WRITE setDpi NOTIFY dpiChanged) | |||
57 | const QString &rcFile() | | |||
58 | { | | |||
59 | return _rcfile; | | |||
60 | } | | |||
61 | const QString &rcGroup() | | |||
62 | { | | |||
63 | return _rcgroup; | | |||
64 | } | | |||
65 | const QString &rcKey() | | |||
66 | { | | |||
67 | return _rckey; | | |||
68 | } | | |||
69 | | ||||
70 | private: | | |||
71 | QString _rcfile; | | |||
72 | QString _rcgroup; | | |||
73 | QString _rckey; | | |||
74 | QFont _default; | | |||
75 | }; | | |||
76 | | ||||
77 | class FontAASettings : public QDialog | | |||
78 | { | | |||
79 | Q_OBJECT | | |||
80 | 51 | | |||
81 | public: | 52 | public: | ||
82 | 53 | enum AASetting { AAEnabled, AASystem, AADisabled }; | |||
83 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 54 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
84 | FontAASettings(QWidget *parent); | 55 | FontAASettings(QObject *parent); | ||
85 | 56 | | |||
86 | bool save(KXftConfig::AntiAliasing::State aaState); | 57 | bool save(KXftConfig::AntiAliasing::State aaState); | ||
87 | bool load(); | 58 | void load(); | ||
88 | void defaults(); | 59 | void defaults(); | ||
89 | int getIndex(KXftConfig::SubPixel::Type spType); | | |||
90 | KXftConfig::SubPixel::Type getSubPixelType(); | | |||
91 | int getIndex(KXftConfig::Hint::Style hStyle); | | |||
92 | KXftConfig::Hint::Style getHintStyle(); | | |||
93 | void setAntiAliasingState(KXftConfig::AntiAliasing::State aaState); | 60 | void setAntiAliasingState(KXftConfig::AntiAliasing::State aaState); | ||
94 | void enableWidgets(); | 61 | QAbstractItemModel* subPixelOptionsModel() { return m_subPixelOptionsModel; } | ||
95 | int exec() Q_DECL_OVERRIDE; | 62 | QAbstractItemModel* hintingOptionsModel() { return m_hintingOptionsModel; } | ||
96 | #endif | 63 | | ||
64 | void setExclude(bool exclude); | ||||
65 | bool exclude() const; | ||||
66 | | ||||
67 | void setExcludeTo(const int &excludeTo); | ||||
68 | int excludeTo() const; | ||||
69 | | ||||
70 | void setExcludeFrom(const int &excludeTo); | ||||
71 | int excludeFrom() const; | ||||
72 | | ||||
73 | void setAntiAliasing(const int& antiAliasing); | ||||
74 | int antiAliasing() const; | ||||
97 | 75 | | |||
98 | protected Q_SLOTS: | 76 | void setDpi(const int &dpi); | ||
77 | int dpi() const; | ||||
99 | 78 | | |||
100 | void changed(); | 79 | int subPixelCurrentIndex(); | ||
80 | void setSubPixelCurrentIndex(int idx); | ||||
81 | int hintingCurrentIndex(); | ||||
82 | void setHintingCurrentIndex(int idx); | ||||
83 | | ||||
84 | #endif | ||||
85 | | ||||
86 | Q_SIGNALS: | ||||
87 | void excludeChanged(); | ||||
88 | void excludeToChanged(); | ||||
89 | void excludeFromChanged(); | ||||
90 | void antiAliasingChanged(); | ||||
91 | void aliasingChanged(); | ||||
92 | void dpiChanged(); | ||||
93 | void subPixelCurrentIndexChanged(); | ||||
94 | void hintingCurrentIndexChanged(); | ||||
101 | 95 | | |||
102 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 96 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
103 | private: | 97 | private: | ||
104 | 98 | int m_excludeTo; | |||
105 | QCheckBox *excludeRange; | 99 | int m_excludeFrom; | ||
106 | QDoubleSpinBox *excludeFrom; | 100 | int m_antiAliasing; | ||
107 | QDoubleSpinBox *excludeTo; | 101 | int m_antiAliasingOriginal; | ||
108 | QComboBox *subPixelType; | 102 | int m_dpi; | ||
109 | QComboBox *hintingStyle; | 103 | int m_dpiOriginal; | ||
110 | QLabel *subPixelLabel; | 104 | int m_subPixelCurrentIndex = 0; | ||
111 | QLabel *excludeToLabel; | 105 | int m_hintingCurrentIndex = 0; | ||
112 | bool changesMade; | 106 | QStandardItemModel *m_subPixelOptionsModel; | ||
107 | QStandardItemModel *m_hintingOptionsModel; | ||||
108 | bool m_exclude = false; | ||||
113 | #endif | 109 | #endif | ||
114 | }; | 110 | }; | ||
115 | 111 | | |||
116 | /** | 112 | /** | ||
117 | * The Desktop/fonts tab in kcontrol. | 113 | * The Desktop/fonts tab in kcontrol. | ||
118 | */ | 114 | */ | ||
119 | class KFonts : public KCModule | 115 | class KFonts : public KQuickAddons::ConfigModule | ||
120 | { | 116 | { | ||
121 | Q_OBJECT | 117 | Q_OBJECT | ||
118 | Q_PROPERTY(QFont generalFont READ generalFont WRITE setGeneralFont NOTIFY generalFontChanged) | ||||
119 | Q_PROPERTY(QFont fixedWidthFont READ fixedWidthFont WRITE setFixedWidthFont NOTIFY fixedWidthFontChanged) | ||||
120 | Q_PROPERTY(QFont smallFont READ smallFont WRITE setSmallFont NOTIFY smallFontChanged) | ||||
121 | Q_PROPERTY(QFont toolbarFont READ toolbarFont WRITE setToolbarFont NOTIFY toolbarFontChanged) | ||||
122 | Q_PROPERTY(QFont menuFont READ menuFont WRITE setMenuFont NOTIFY menuFontChanged) | ||||
123 | Q_PROPERTY(QFont windowTitleFont READ windowTitleFont WRITE setWindowTitleFont NOTIFY windowTitleFontChanged) | ||||
124 | Q_PROPERTY(QObject *fontAASettings READ fontAASettings CONSTANT) | ||||
122 | 125 | | |||
123 | public: | 126 | public: | ||
124 | KFonts(QWidget *parent, const QVariantList &); | 127 | KFonts(QObject *parent, const QVariantList &); | ||
125 | ~KFonts(); | 128 | ~KFonts(); | ||
126 | 129 | | |||
127 | void load() Q_DECL_OVERRIDE; | 130 | void setGeneralFont(const QFont &font); | ||
128 | void save() Q_DECL_OVERRIDE; | 131 | QFont generalFont() const; | ||
129 | void defaults() Q_DECL_OVERRIDE; | 132 | | ||
130 | 133 | void setFixedWidthFont(const QFont &font); | |||
131 | protected Q_SLOTS: | 134 | QFont fixedWidthFont() const; | ||
132 | void fontSelected(); | 135 | | ||
133 | void slotApplyFontDiff(); | 136 | void setSmallFont(const QFont &font); | ||
134 | void slotUseAntiAliasing(); | 137 | QFont smallFont() const; | ||
135 | void slotCfgAa(); | 138 | | ||
139 | void setToolbarFont(const QFont &font); | ||||
140 | QFont toolbarFont() const; | ||||
141 | | ||||
142 | void setMenuFont(const QFont &font); | ||||
143 | QFont menuFont() const; | ||||
144 | | ||||
145 | void setWindowTitleFont(const QFont &font); | ||||
146 | QFont windowTitleFont() const; | ||||
147 | | ||||
148 | QObject* fontAASettings() { return m_fontAASettings; } | ||||
149 | | ||||
150 | public Q_SLOTS: | ||||
151 | void load(); | ||||
152 | void save(); | ||||
153 | void defaults(); | ||||
154 | Q_INVOKABLE void adjustAllFonts(); | ||||
155 | | ||||
156 | Q_SIGNALS: | ||||
157 | void fontsHaveChanged(); | ||||
158 | | ||||
159 | void generalFontChanged(); | ||||
160 | void fixedWidthFontChanged(); | ||||
161 | void smallFontChanged(); | ||||
162 | void toolbarFontChanged(); | ||||
163 | void menuFontChanged(); | ||||
164 | void windowTitleFontChanged(); | ||||
136 | 165 | | |||
137 | private: | 166 | private: | ||
138 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 167 | QFont applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags); | ||
139 | enum AASetting { AAEnabled, AASystem, AADisabled }; | 168 | | ||
140 | AASetting useAA, useAA_original; | 169 | QFont m_defaultFont; | ||
141 | QComboBox *cbAA; | 170 | QFont m_generalFont; | ||
142 | QPushButton *aaSettingsButton; | 171 | QFont m_fixedWidthFont; | ||
143 | FontAASettings *aaSettings; | 172 | QFont m_smallFont; | ||
144 | #endif | 173 | QFont m_toolbarFont; | ||
145 | int dpi_original; | 174 | QFont m_menuFont; | ||
146 | QCheckBox *checkboxForceDpi; | 175 | QFont m_windowTitleFont; | ||
147 | QSpinBox *spinboxDpi; | 176 | | ||
148 | QList<FontUseItem *> fontUseList; | 177 | FontAASettings *m_fontAASettings; | ||
149 | }; | 178 | }; | ||
150 | 179 | | |||
151 | #endif | 180 | #endif | ||
152 | 181 | |