Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (c) 2015 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org> | ||||
3 | Copyright (c) 2017 Marco Martin <mart@kde.org> | ||||
4 | | ||||
5 | This library is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU Library General Public | ||||
7 | License version 2 as published by the Free Software Foundation. | ||||
8 | | ||||
9 | This library is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | Library General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU Library General Public License | ||||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
17 | Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.1 | ||||
21 | import QtQuick.Layouts 1.1 | ||||
22 | import QtQuick.Controls 2.0 as QtControls | ||||
23 | import QtQuick.Dialogs 1.2 as QtDialogs | ||||
24 | import org.kde.kirigami 2.3 as Kirigami | ||||
25 | import org.kde.kcm 1.0 | ||||
26 | | ||||
27 | Kirigami.ScrollablePage { | ||||
28 | id: root | ||||
29 | | ||||
30 | ConfigModule.quickHelp: i18n("Fonts") | ||||
31 | | ||||
32 | | ||||
33 | Kirigami.FormLayout { | ||||
34 | id: formLayout | ||||
35 | | ||||
36 | readonly property int maxImplicitWidth: Math.max(adjustAllFontsButton.implicitWidth, Math.max(antiAliasingComboBox.implicitWidth, Math.max(excludeField.implicitWidth, Math.max(subPixelCombo.implicitWidth, hintingCombo.implicitWidth)))) | ||||
37 | | ||||
38 | QtControls.Button { | ||||
39 | id: adjustAllFontsButton | ||||
40 | Layout.preferredWidth: formLayout.maxImplicitWidth | ||||
41 | text: i18n("&Adjust All Fonts...") | ||||
42 | | ||||
43 | onClicked: kcm.adjustAllFonts(); | ||||
44 | } | ||||
45 | | ||||
46 | FontWidget { | ||||
47 | id: generalFontWidget | ||||
48 | label: i18n("General:") | ||||
49 | category: "generalFont" | ||||
50 | font: kcm.generalFont | ||||
51 | } | ||||
52 | FontWidget { | ||||
53 | label: i18n("Fixed width:") | ||||
54 | category: "fixedWidthFont" | ||||
55 | font: kcm.fixedWidthFont | ||||
56 | } | ||||
57 | FontWidget { | ||||
58 | label: i18n("Small:") | ||||
59 | category: "smallFont" | ||||
60 | font: kcm.smallFont | ||||
61 | } | ||||
62 | FontWidget { | ||||
63 | label: i18n("Toolbar:") | ||||
64 | category: "toolbarFont" | ||||
65 | font: kcm.toolbarFont | ||||
66 | } | ||||
67 | FontWidget { | ||||
68 | label: i18n("Menu:") | ||||
69 | category: "menuFont" | ||||
70 | font: kcm.menuFont | ||||
71 | } | ||||
72 | FontWidget { | ||||
73 | label: i18n("Window title:") | ||||
74 | category: "windowTitleFont" | ||||
75 | font: kcm.windowTitleFont | ||||
76 | } | ||||
77 | | ||||
78 | Kirigami.Separator { | ||||
79 | Kirigami.FormData.isSection: true | ||||
80 | } | ||||
81 | | ||||
82 | QtControls.ComboBox { | ||||
83 | id: antiAliasingComboBox | ||||
84 | Layout.preferredWidth: formLayout.maxImplicitWidth | ||||
85 | Kirigami.FormData.label: i18n("Use anti-aliasing:") | ||||
86 | | ||||
87 | model: [i18n("Enabled"), i18n("Vendor Default"), i18n("Disabled")] | ||||
88 | | ||||
89 | currentIndex: kcm.fontAASettings.antiAliasing | ||||
90 | onCurrentIndexChanged: kcm.fontAASettings.antiAliasing = antiAliasingComboBox.currentIndex | ||||
91 | } | ||||
92 | | ||||
93 | QtControls.CheckBox { | ||||
94 | id: excludeCheckBox | ||||
95 | checked: kcm.fontAASettings.exclude | ||||
96 | onCheckedChanged: kcm.fontAASettings.exclude = checked; | ||||
97 | text: i18n("Exclude range from anti-aliasing") | ||||
98 | Layout.fillWidth: true | ||||
99 | enabled: antiAliasingComboBox.currentIndex == 0 | ||||
100 | } | ||||
101 | | ||||
102 | RowLayout { | ||||
103 | id: excludeField | ||||
104 | Layout.preferredWidth: formLayout.maxImplicitWidth | ||||
105 | enabled: antiAliasingComboBox.currentIndex == 0 | ||||
106 | QtControls.SpinBox { | ||||
107 | id: excludeFromSpinBox | ||||
108 | stepSize: 1 | ||||
109 | onValueChanged: kcm.fontAASettings.excludeFrom = value | ||||
110 | textFromValue: function(value, locale) { return i18n("%1 pt", value)} | ||||
111 | enabled: excludeCheckBox.checked | ||||
112 | } | ||||
113 | | ||||
114 | QtControls.Label { | ||||
115 | Layout.fillWidth: true | ||||
116 | horizontalAlignment: Text.AlignHCenter | ||||
117 | text: i18n("to") | ||||
118 | } | ||||
119 | | ||||
120 | QtControls.SpinBox { | ||||
121 | id: excludeToSpinBox | ||||
122 | stepSize: 1 | ||||
123 | onValueChanged: kcm.fontAASettings.excludeTo = value | ||||
124 | textFromValue: function(value, locale) { return i18n("%1 pt", value)} | ||||
125 | enabled: excludeCheckBox.checked | ||||
126 | } | ||||
127 | Connections { | ||||
128 | target: kcm.fontAASettings | ||||
129 | onExcludeFromChanged: excludeFromSpinBox.value = kcm.fontAASettings.excludeFrom; | ||||
130 | onExcludeToChanged: excludeToSpinBox.value = kcm.fontAASettings.excludeTo; | ||||
131 | } | ||||
132 | } | ||||
133 | | ||||
134 | QtControls.ComboBox { | ||||
135 | id: subPixelCombo | ||||
136 | Layout.preferredWidth: formLayout.maxImplicitWidth | ||||
137 | Kirigami.FormData.label: i18n("Sub-pixel rendering type:") | ||||
138 | currentIndex: kcm.fontAASettings.subPixelCurrentIndex | ||||
139 | onCurrentIndexChanged: kcm.fontAASettings.subPixelCurrentIndex = currentIndex; | ||||
140 | model: kcm.fontAASettings.subPixelOptionsModel | ||||
141 | textRole: "display" | ||||
142 | enabled: antiAliasingComboBox.currentIndex == 0 | ||||
143 | } | ||||
144 | | ||||
145 | QtControls.ComboBox { | ||||
146 | id: hintingCombo | ||||
147 | Layout.preferredWidth: formLayout.maxImplicitWidth | ||||
148 | Kirigami.FormData.label: i18n("Hinting style:") | ||||
149 | currentIndex: kcm.fontAASettings.hintingCurrentIndex | ||||
150 | onCurrentTextChanged: kcm.fontAASettings.hintingCurrentIndex = currentIndex; | ||||
151 | model: kcm.fontAASettings.hintingOptionsModel | ||||
152 | textRole: "display" | ||||
153 | enabled: antiAliasingComboBox.currentIndex == 0 | ||||
154 | } | ||||
155 | | ||||
156 | RowLayout { | ||||
157 | QtControls.CheckBox { | ||||
158 | id: dpiCheckBox | ||||
159 | checked: dpiSpinBox.value != 96 | ||||
160 | text: i18n("Force Fonts DPI:") | ||||
161 | onCheckedChanged: { | ||||
162 | if (!dpiCheckBox.checked) { | ||||
163 | dpiSpinBox.enabled = false; | ||||
164 | kcm.fontAASettings.dpi = 0; | ||||
165 | } else { | ||||
166 | dpiSpinBox.enabled = true; | ||||
167 | } | ||||
168 | } | ||||
169 | } | ||||
170 | | ||||
171 | QtControls.SpinBox { | ||||
172 | id: dpiSpinBox | ||||
173 | stepSize: 24 | ||||
174 | enabled: dpiCheckBox.checked | ||||
175 | value: kcm.fontAASettings.dpi | ||||
176 | onValueChanged: kcm.fontAASettings.dpi = dpiSpinBox.value | ||||
177 | to: 1000 | ||||
178 | from: 96 | ||||
179 | } | ||||
180 | } | ||||
181 | } | ||||
182 | | ||||
183 | QtDialogs.FontDialog { | ||||
184 | id: fontDialog | ||||
185 | title: "Choose a font" | ||||
186 | property string currentCategory | ||||
187 | property bool adjustAllFonts: false | ||||
188 | onAccepted: { | ||||
189 | if (adjustAllFonts) { | ||||
190 | kcm.adjustAllFonts(font); | ||||
191 | } else { | ||||
192 | kcm[currentCategory] = font; | ||||
193 | } | ||||
194 | } | ||||
195 | } | ||||
196 | } | ||||
197 | |