Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/fonts.cpp
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | |||||
124 | } | 124 | } | ||
125 | 125 | | |||
126 | void FontAASettings::load() | 126 | void FontAASettings::load() | ||
127 | { | 127 | { | ||
128 | double from, to; | 128 | double from, to; | ||
129 | KXftConfig xft; | 129 | KXftConfig xft; | ||
130 | 130 | | |||
131 | if (xft.getExcludeRange(from, to)) { | 131 | if (xft.getExcludeRange(from, to)) { | ||
132 | m_excludeFrom = from; | 132 | m_state.excludeFrom = from; | ||
133 | m_excludeTo = to; | 133 | m_state.excludeTo = to; | ||
134 | setExclude(true); | 134 | setExclude(true); | ||
135 | } else { | 135 | } else { | ||
136 | m_excludeFrom = 8; | 136 | m_state.excludeFrom = 8; | ||
137 | m_excludeTo = 15; | 137 | m_state.excludeTo = 15; | ||
138 | setExclude(false); | 138 | setExclude(false); | ||
139 | } | 139 | } | ||
140 | m_excludeFromOriginal = m_excludeFrom; | 140 | m_originalState.exclude = m_state.exclude; | ||
141 | m_excludeToOriginal = m_excludeTo; | 141 | m_originalState.excludeFrom = m_state.excludeFrom; | ||
142 | m_originalState.excludeTo = m_state.excludeTo; | ||||
142 | excludeToChanged(); | 143 | excludeToChanged(); | ||
143 | excludeFromChanged(); | 144 | excludeFromChanged(); | ||
144 | 145 | | |||
145 | KXftConfig::SubPixel::Type spType; | 146 | KXftConfig::SubPixel::Type spType; | ||
146 | xft.getSubPixelType(spType); | 147 | xft.getSubPixelType(spType); | ||
147 | 148 | | |||
148 | setSubPixelCurrentIndex(spType); | 149 | setSubPixelCurrentIndex(spType); | ||
149 | m_subPixelCurrentIndexOriginal = spType; | 150 | m_originalState.subPixel = spType; | ||
150 | 151 | | |||
151 | KXftConfig::Hint::Style hStyle; | 152 | KXftConfig::Hint::Style hStyle; | ||
152 | 153 | | |||
153 | if (!xft.getHintStyle(hStyle) || KXftConfig::Hint::NotSet == hStyle) { | 154 | if (!xft.getHintStyle(hStyle) || KXftConfig::Hint::NotSet == hStyle) { | ||
154 | KConfig kglobals("kdeglobals", KConfig::NoGlobals); | 155 | KConfig kglobals("kdeglobals", KConfig::NoGlobals); | ||
155 | 156 | | |||
156 | hStyle = KXftConfig::Hint::NotSet; | 157 | hStyle = KXftConfig::Hint::NotSet; | ||
157 | xft.setHintStyle(hStyle); | 158 | xft.setHintStyle(hStyle); | ||
158 | KConfigGroup(&kglobals, "General").writeEntry("XftHintStyle", KXftConfig::toStr(hStyle)); | 159 | KConfigGroup(&kglobals, "General").writeEntry("XftHintStyle", KXftConfig::toStr(hStyle)); | ||
159 | kglobals.sync(); | 160 | kglobals.sync(); | ||
160 | runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); | 161 | runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); | ||
161 | } | 162 | } | ||
162 | 163 | | |||
163 | setHintingCurrentIndex(hStyle); | 164 | setHintingCurrentIndex(hStyle); | ||
164 | m_hintingCurrentIndexOriginal = hStyle; | 165 | m_originalState.hinting = hStyle; | ||
165 | 166 | | |||
166 | KConfig _cfgfonts("kcmfonts"); | 167 | KConfig _cfgfonts("kcmfonts"); | ||
167 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | 168 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | ||
168 | 169 | | |||
169 | int dpicfg; | 170 | int dpicfg; | ||
170 | if (KWindowSystem::isPlatformWayland()) { | 171 | if (KWindowSystem::isPlatformWayland()) { | ||
171 | dpicfg = cfgfonts.readEntry("forceFontDPIWayland", 0); | 172 | dpicfg = cfgfonts.readEntry("forceFontDPIWayland", 0); | ||
172 | } else { | 173 | } else { | ||
173 | dpicfg = cfgfonts.readEntry("forceFontDPI", 0); | 174 | dpicfg = cfgfonts.readEntry("forceFontDPI", 0); | ||
174 | } | 175 | } | ||
175 | 176 | | |||
176 | if (dpicfg <= 0) { | 177 | if (dpicfg <= 0) { | ||
177 | m_dpiOriginal = 0; | 178 | m_originalState.dpi = 0; | ||
178 | } else { | 179 | } else { | ||
179 | m_dpiOriginal = dpicfg; | 180 | m_originalState.dpi = dpicfg; | ||
180 | }; | 181 | }; | ||
181 | 182 | | |||
182 | setDpi(dpicfg); | 183 | setDpi(dpicfg); | ||
183 | 184 | | |||
184 | KSharedConfig::Ptr config = KSharedConfig::openConfig("kdeglobals"); | 185 | KSharedConfig::Ptr config = KSharedConfig::openConfig("kdeglobals"); | ||
185 | KConfigGroup cg(config, "General"); | 186 | KConfigGroup cg(config, "General"); | ||
186 | 187 | | |||
187 | if (cfgfonts.readEntry("dontChangeAASettings", true)) { | 188 | if (cfgfonts.readEntry("dontChangeAASettings", true)) { | ||
188 | setAntiAliasing(1); //AASystem | 189 | setAntiAliasing(true); //AASystem | ||
190 | m_state.antiAliasingHasLocalConfig = false; | ||||
189 | } else if (cg.readEntry("XftAntialias", true)) { | 191 | } else if (cg.readEntry("XftAntialias", true)) { | ||
190 | setAntiAliasing(0); //AAEnabled | 192 | setAntiAliasing(true); //AAEnabled | ||
193 | m_state.antiAliasingHasLocalConfig = xft.antiAliasingHasLocalConfig(); | ||||
191 | } else { | 194 | } else { | ||
192 | setAntiAliasing(2); //AADisabled | 195 | setAntiAliasing(false); //AADisabled | ||
196 | m_state.antiAliasingHasLocalConfig = xft.antiAliasingHasLocalConfig(); | ||||
193 | } | 197 | } | ||
194 | m_antiAliasingOriginal = m_antiAliasing; | 198 | m_originalState.antiAliasing = m_state.antiAliasing; | ||
199 | m_originalState.antiAliasingHasLocalConfig = m_state.antiAliasingHasLocalConfig; | ||||
195 | } | 200 | } | ||
196 | 201 | | |||
197 | bool FontAASettings::save(KXftConfig::AntiAliasing::State aaState) | 202 | bool FontAASettings::save(KXftConfig::AntiAliasing::State aaState) | ||
198 | { | 203 | { | ||
199 | KXftConfig xft; | 204 | KXftConfig xft; | ||
200 | KConfig kglobals("kdeglobals", KConfig::NoGlobals); | 205 | KConfig kglobals("kdeglobals", KConfig::NoGlobals); | ||
201 | KConfigGroup grp(&kglobals, "General"); | 206 | KConfigGroup grp(&kglobals, "General"); | ||
202 | 207 | | |||
203 | xft.setAntiAliasing(aaState); | 208 | xft.setAntiAliasing(aaState); | ||
204 | if (m_exclude) { | 209 | if (m_state.exclude) { | ||
205 | xft.setExcludeRange(m_excludeFrom, m_excludeTo); | 210 | xft.setExcludeRange(m_state.excludeFrom, m_state.excludeTo); | ||
206 | } else { | 211 | } else { | ||
207 | xft.setExcludeRange(0, 0); | 212 | xft.setExcludeRange(0, 0); | ||
208 | } | 213 | } | ||
209 | 214 | | |||
210 | KXftConfig::SubPixel::Type spType = (KXftConfig::SubPixel::Type)m_subPixelCurrentIndex; | 215 | KXftConfig::SubPixel::Type spType = (KXftConfig::SubPixel::Type)m_state.subPixel; | ||
211 | 216 | | |||
212 | xft.setSubPixelType(spType); | 217 | xft.setSubPixelType(spType); | ||
213 | grp.writeEntry("XftSubPixel", KXftConfig::toStr(spType)); | 218 | grp.writeEntry("XftSubPixel", KXftConfig::toStr(spType)); | ||
214 | if (aaState == KXftConfig::AntiAliasing::NotSet) { | 219 | if (aaState == KXftConfig::AntiAliasing::NotSet) { | ||
215 | grp.revertToDefault("XftAntialias"); | 220 | grp.revertToDefault("XftAntialias"); | ||
216 | } else { | 221 | } else { | ||
217 | grp.writeEntry("XftAntialias", aaState == KXftConfig::AntiAliasing::Enabled); | 222 | grp.writeEntry("XftAntialias", aaState == KXftConfig::AntiAliasing::Enabled); | ||
218 | } | 223 | } | ||
219 | 224 | | |||
220 | bool mod = false; | 225 | bool mod = false; | ||
221 | KXftConfig::Hint::Style hStyle = (KXftConfig::Hint::Style)m_hintingCurrentIndex; | 226 | KXftConfig::Hint::Style hStyle = (KXftConfig::Hint::Style)m_state.hinting; | ||
222 | 227 | | |||
223 | xft.setHintStyle(hStyle); | 228 | xft.setHintStyle(hStyle); | ||
224 | 229 | | |||
225 | QString hs(KXftConfig::toStr(hStyle)); | 230 | QString hs(KXftConfig::toStr(hStyle)); | ||
226 | 231 | | |||
227 | if (hs != grp.readEntry("XftHintStyle")) { | 232 | if (hs != grp.readEntry("XftHintStyle")) { | ||
228 | if (KXftConfig::Hint::NotSet == hStyle) { | 233 | if (KXftConfig::Hint::NotSet == hStyle) { | ||
229 | grp.revertToDefault("XftHintStyle"); | 234 | grp.revertToDefault("XftHintStyle"); | ||
Show All 9 Lines | |||||
239 | } | 244 | } | ||
240 | 245 | | |||
241 | xft.apply(); | 246 | xft.apply(); | ||
242 | 247 | | |||
243 | KConfig _cfgfonts("kcmfonts"); | 248 | KConfig _cfgfonts("kcmfonts"); | ||
244 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | 249 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | ||
245 | 250 | | |||
246 | if (KWindowSystem::isPlatformWayland()) { | 251 | if (KWindowSystem::isPlatformWayland()) { | ||
247 | cfgfonts.writeEntry("forceFontDPIWayland", m_dpi); | 252 | cfgfonts.writeEntry("forceFontDPIWayland", m_state.dpi); | ||
248 | } else { | 253 | } else { | ||
249 | cfgfonts.writeEntry("forceFontDPI", m_dpi); | 254 | cfgfonts.writeEntry("forceFontDPI", m_state.dpi); | ||
250 | } | 255 | } | ||
251 | 256 | | |||
252 | cfgfonts.sync(); | 257 | cfgfonts.sync(); | ||
253 | 258 | | |||
254 | #if HAVE_X11 | 259 | #if HAVE_X11 | ||
255 | // if the setting is reset in the module, remove the dpi value, | 260 | // if the setting is reset in the module, remove the dpi value, | ||
256 | // otherwise don't explicitly remove it and leave any possible system-wide value | 261 | // otherwise don't explicitly remove it and leave any possible system-wide value | ||
257 | if (m_dpi == 0 && m_dpiOriginal != 0 && !KWindowSystem::isPlatformWayland()) { | 262 | if (m_state.dpi == 0 && m_originalState.dpi != 0 && !KWindowSystem::isPlatformWayland()) { | ||
258 | QProcess proc; | 263 | QProcess proc; | ||
259 | proc.setProcessChannelMode(QProcess::ForwardedChannels); | 264 | proc.setProcessChannelMode(QProcess::ForwardedChannels); | ||
260 | proc.start("xrdb", QStringList() << "-quiet" << "-remove" << "-nocpp"); | 265 | proc.start("xrdb", QStringList() << "-quiet" << "-remove" << "-nocpp"); | ||
261 | if (proc.waitForStarted()) { | 266 | if (proc.waitForStarted()) { | ||
262 | proc.write(QByteArray("Xft.dpi\n")); | 267 | proc.write(QByteArray("Xft.dpi\n")); | ||
263 | proc.closeWriteChannel(); | 268 | proc.closeWriteChannel(); | ||
264 | proc.waitForFinished(); | 269 | proc.waitForFinished(); | ||
265 | } | 270 | } | ||
266 | } | 271 | } | ||
267 | #endif | 272 | #endif | ||
268 | 273 | | |||
269 | QApplication::processEvents(); // Process font change ourselves | 274 | QApplication::processEvents(); // Process font change ourselves | ||
270 | 275 | | |||
271 | // Don't overwrite global settings unless explicitly asked for - e.g. the system | 276 | // Don't overwrite global settings unless explicitly asked for - e.g. the system | ||
272 | // fontconfig setup may be much more complex than this module can provide. | 277 | // fontconfig setup may be much more complex than this module can provide. | ||
273 | // TODO: With AASystem the changes already made by this module should be reverted somehow. | 278 | // TODO: With AASystem the changes already made by this module should be reverted somehow. | ||
274 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 279 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
275 | if (mod || (m_antiAliasing != m_antiAliasingOriginal) || m_dpi != m_dpiOriginal) { | 280 | if (mod || (m_state.antiAliasing != m_originalState.antiAliasing) || m_state.dpi != m_originalState.dpi) { | ||
276 | KMessageBox::information(0, | 281 | KMessageBox::information(0, | ||
277 | i18n( | 282 | i18n( | ||
278 | "<p>Some changes such as anti-aliasing or DPI will only affect newly started applications.</p>" | 283 | "<p>Some changes such as anti-aliasing or DPI will only affect newly started applications.</p>" | ||
279 | ), i18n("Font Settings Changed"), "FontSettingsChanged"); | 284 | ), i18n("Font Settings Changed"), "FontSettingsChanged"); | ||
280 | m_antiAliasingOriginal = m_antiAliasing; | 285 | m_originalState.antiAliasing = m_state.antiAliasing; | ||
281 | m_dpiOriginal = m_dpi; | 286 | m_originalState.dpi = m_state.dpi; | ||
282 | } | 287 | } | ||
283 | #else | 288 | #else | ||
284 | #if HAVE_X11 | 289 | #if HAVE_X11 | ||
285 | if (m_dpi != m_dpiOriginal) { | 290 | if (m_state.dpi != m_originalState.dpi) { | ||
286 | KMessageBox::information(0, | 291 | KMessageBox::information(0, | ||
287 | i18n( | 292 | i18n( | ||
288 | "<p>Some changes such as DPI will only affect newly started applications.</p>" | 293 | "<p>Some changes such as DPI will only affect newly started applications.</p>" | ||
289 | ), i18n("Font Settings Changed"), "FontSettingsChanged"); | 294 | ), i18n("Font Settings Changed"), "FontSettingsChanged"); | ||
290 | m_dpiOriginal = m_dpi; | 295 | m_originalState.dpi = m_state.dpi; | ||
291 | } | 296 | } | ||
292 | #endif | 297 | #endif | ||
293 | #endif | 298 | #endif | ||
294 | 299 | | |||
295 | m_excludeToOriginal = m_excludeTo; | 300 | m_originalState.excludeTo = m_state.excludeTo; | ||
296 | m_excludeFromOriginal = m_excludeFrom; | 301 | m_originalState.excludeFrom = m_state.excludeFrom; | ||
297 | 302 | | |||
298 | m_subPixelCurrentIndexOriginal = m_subPixelCurrentIndex; | 303 | m_originalState.subPixel = m_state.subPixel; | ||
299 | m_hintingCurrentIndexOriginal = m_hintingCurrentIndex; | 304 | m_originalState.hinting = m_state.hinting; | ||
300 | 305 | | |||
301 | return mod; | 306 | return mod; | ||
302 | } | 307 | } | ||
303 | 308 | | |||
304 | void FontAASettings::defaults() | 309 | void FontAASettings::defaults() | ||
305 | { | 310 | { | ||
306 | setExcludeTo(15); | 311 | setExcludeTo(15); | ||
307 | setExcludeFrom(8); | 312 | setExcludeFrom(8); | ||
308 | setAntiAliasing(1); | 313 | setAntiAliasing(true); | ||
309 | m_antiAliasingOriginal = m_antiAliasing; | 314 | m_originalState.antiAliasing = m_state.antiAliasing; | ||
315 | m_state.antiAliasingHasLocalConfig = false; | ||||
310 | setDpi(0); | 316 | setDpi(0); | ||
311 | setSubPixelCurrentIndex(KXftConfig::SubPixel::NotSet); | 317 | setSubPixelCurrentIndex(KXftConfig::SubPixel::NotSet); | ||
312 | setHintingCurrentIndex(KXftConfig::Hint::NotSet); | 318 | setHintingCurrentIndex(KXftConfig::Hint::NotSet); | ||
313 | } | 319 | } | ||
314 | 320 | | |||
315 | #endif | 321 | #endif | ||
316 | 322 | | |||
317 | void FontAASettings::setExclude(bool exclude) | 323 | void FontAASettings::setExclude(bool exclude) | ||
318 | { | 324 | { | ||
319 | if (exclude == m_exclude) { | 325 | if (exclude == m_state.exclude) { | ||
320 | return; | 326 | return; | ||
321 | } | 327 | } | ||
322 | 328 | | |||
323 | m_exclude = exclude; | 329 | m_state.exclude = exclude; | ||
324 | emit excludeChanged(); | 330 | emit excludeChanged(); | ||
325 | } | 331 | } | ||
326 | 332 | | |||
327 | bool FontAASettings::exclude() const | 333 | bool FontAASettings::exclude() const | ||
328 | { | 334 | { | ||
329 | return m_exclude; | 335 | return m_state.exclude; | ||
330 | } | 336 | } | ||
331 | 337 | | |||
332 | void FontAASettings::setExcludeTo(const int &excludeTo) | 338 | void FontAASettings::setExcludeTo(const int &excludeTo) | ||
333 | { | 339 | { | ||
334 | if (m_excludeTo == excludeTo) { | 340 | if (m_state.excludeTo == excludeTo) { | ||
335 | return; | 341 | return; | ||
336 | } | 342 | } | ||
337 | 343 | | |||
338 | m_excludeTo = excludeTo; | 344 | m_state.excludeTo = excludeTo; | ||
339 | emit excludeToChanged(); | 345 | emit excludeToChanged(); | ||
340 | } | 346 | } | ||
341 | 347 | | |||
342 | int FontAASettings::excludeTo() const | 348 | int FontAASettings::excludeTo() const | ||
343 | { | 349 | { | ||
344 | return m_excludeTo; | 350 | return m_state.excludeTo; | ||
345 | } | 351 | } | ||
346 | 352 | | |||
347 | void FontAASettings::setExcludeFrom(const int &excludeTo) | 353 | void FontAASettings::setExcludeFrom(const int &excludeTo) | ||
348 | { | 354 | { | ||
349 | if (m_excludeFrom == excludeTo) { | 355 | if (m_state.excludeFrom == excludeTo) { | ||
350 | return; | 356 | return; | ||
351 | } | 357 | } | ||
352 | 358 | | |||
353 | m_excludeFrom = excludeTo; | 359 | m_state.excludeFrom = excludeTo; | ||
354 | emit excludeToChanged(); | 360 | emit excludeToChanged(); | ||
355 | } | 361 | } | ||
356 | 362 | | |||
357 | int FontAASettings::excludeFrom() const | 363 | int FontAASettings::excludeFrom() const | ||
358 | { | 364 | { | ||
359 | return m_excludeFrom; | 365 | return m_state.excludeFrom; | ||
360 | } | 366 | } | ||
361 | 367 | | |||
362 | void FontAASettings::setAntiAliasing(const int &antiAliasing) | 368 | void FontAASettings::setAntiAliasing(bool antiAliasing) | ||
363 | { | 369 | { | ||
364 | if (m_antiAliasing == antiAliasing) { | 370 | if (m_state.antiAliasing == antiAliasing) { | ||
365 | return; | 371 | return; | ||
366 | } | 372 | } | ||
367 | 373 | | |||
368 | m_antiAliasing = antiAliasing; | 374 | m_state.antiAliasing = antiAliasing; | ||
369 | emit aliasingChanged(); | 375 | emit aliasingChanged(); | ||
370 | } | 376 | } | ||
371 | 377 | | |||
372 | int FontAASettings::antiAliasing() const | 378 | bool FontAASettings::antiAliasing() const | ||
373 | { | 379 | { | ||
374 | return m_antiAliasing; | 380 | return m_state.antiAliasing; | ||
381 | } | ||||
382 | | ||||
383 | bool FontAASettings::antiAliasingNeedsSave() const | ||||
384 | { | ||||
385 | return m_state.antiAliasingHasLocalConfig || (m_state.antiAliasing != m_originalState.antiAliasing); | ||||
375 | } | 386 | } | ||
376 | 387 | | |||
377 | void FontAASettings::setDpi(const int &dpi) | 388 | void FontAASettings::setDpi(const int &dpi) | ||
378 | { | 389 | { | ||
379 | if (m_dpi == dpi) { | 390 | if (m_state.dpi == dpi) { | ||
380 | return; | 391 | return; | ||
381 | } | 392 | } | ||
382 | 393 | | |||
383 | m_dpi = dpi; | 394 | m_state.dpi = dpi; | ||
384 | emit dpiChanged(); | 395 | emit dpiChanged(); | ||
385 | } | 396 | } | ||
386 | 397 | | |||
387 | int FontAASettings::dpi() const | 398 | int FontAASettings::dpi() const | ||
388 | { | 399 | { | ||
389 | return m_dpi; | 400 | return m_state.dpi; | ||
390 | } | 401 | } | ||
391 | 402 | | |||
392 | void FontAASettings::setSubPixelCurrentIndex(int idx) | 403 | void FontAASettings::setSubPixelCurrentIndex(int idx) | ||
393 | { | 404 | { | ||
394 | if (m_subPixelCurrentIndex == idx) { | 405 | if (m_state.subPixel == idx) { | ||
395 | return; | 406 | return; | ||
396 | } | 407 | } | ||
397 | 408 | | |||
398 | m_subPixelCurrentIndex = idx; | 409 | m_state.subPixel = idx; | ||
399 | emit subPixelCurrentIndexChanged(); | 410 | emit subPixelCurrentIndexChanged(); | ||
400 | } | 411 | } | ||
401 | 412 | | |||
402 | int FontAASettings::subPixelCurrentIndex() | 413 | int FontAASettings::subPixelCurrentIndex() | ||
403 | { | 414 | { | ||
404 | return m_subPixelCurrentIndex; | 415 | return m_state.subPixel; | ||
405 | } | 416 | } | ||
406 | 417 | | |||
407 | void FontAASettings::setHintingCurrentIndex(int idx) | 418 | void FontAASettings::setHintingCurrentIndex(int idx) | ||
408 | { | 419 | { | ||
409 | if (m_hintingCurrentIndex == idx) { | 420 | if (m_state.hinting == idx) { | ||
410 | return; | 421 | return; | ||
411 | } | 422 | } | ||
412 | 423 | | |||
413 | m_hintingCurrentIndex = idx; | 424 | m_state.hinting = idx; | ||
414 | emit hintingCurrentIndexChanged(); | 425 | emit hintingCurrentIndexChanged(); | ||
415 | } | 426 | } | ||
416 | 427 | | |||
417 | int FontAASettings::hintingCurrentIndex() | 428 | int FontAASettings::hintingCurrentIndex() | ||
418 | { | 429 | { | ||
419 | return m_hintingCurrentIndex; | 430 | return m_state.hinting; | ||
420 | } | 431 | } | ||
421 | 432 | | |||
422 | bool FontAASettings::needsSave() const | 433 | bool FontAASettings::needsSave() const | ||
423 | { | 434 | { | ||
424 | return m_excludeTo != m_excludeToOriginal | 435 | return m_state != m_originalState; | ||
425 | || m_excludeFrom != m_excludeFromOriginal | | |||
426 | || m_antiAliasing != m_antiAliasingOriginal | | |||
427 | || m_dpi != m_dpiOriginal | | |||
428 | || m_subPixelCurrentIndex != m_subPixelCurrentIndexOriginal | | |||
429 | || m_hintingCurrentIndex != m_hintingCurrentIndexOriginal; | | |||
430 | } | 436 | } | ||
431 | 437 | | |||
432 | 438 | | |||
433 | /**** KFonts ****/ | 439 | /**** KFonts ****/ | ||
434 | 440 | | |||
435 | KFonts::KFonts(QObject *parent, const QVariantList &args) | 441 | KFonts::KFonts(QObject *parent, const QVariantList &args) | ||
436 | : KQuickAddons::ConfigModule(parent, args) | 442 | : KQuickAddons::ConfigModule(parent, args) | ||
437 | , m_fontAASettings(new FontAASettings(this)) | 443 | , m_fontAASettings(new FontAASettings(this)) | ||
438 | { | 444 | { | ||
439 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | 445 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | ||
440 | KAboutData* about = new KAboutData("kcm_fonts", i18n("Configure Fonts"), | 446 | KAboutData* about = new KAboutData("kcm_fonts", i18n("Configure Fonts"), | ||
441 | "0.1", QString(), KAboutLicense::LGPL); | 447 | "0.1", QString(), KAboutLicense::LGPL); | ||
442 | about->addAuthor(i18n("Antonis Tsiapaliokas"), QString(), "antonis.tsiapaliokas@kde.org"); | 448 | about->addAuthor(i18n("Antonis Tsiapaliokas"), QString(), "antonis.tsiapaliokas@kde.org"); | ||
443 | setAboutData(about); | 449 | setAboutData(about); | ||
444 | qmlRegisterType<QStandardItemModel>(); | 450 | qmlRegisterType<QStandardItemModel>(); | ||
445 | setButtons(Apply | Default); | 451 | setButtons(Apply | Default); | ||
446 | 452 | | |||
447 | auto updateState = [this]() { | 453 | auto updateState = [this]() { | ||
448 | setNeedsSave(m_fontAASettings->needsSave()); | 454 | setNeedsSave(m_fontAASettings->needsSave()); | ||
449 | }; | 455 | }; | ||
450 | 456 | | |||
451 | connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, updateState); | 457 | connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, updateState); | ||
452 | connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, updateState); | 458 | connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, updateState); | ||
459 | connect(m_fontAASettings, &FontAASettings::excludeChanged, this, updateState); | ||||
460 | connect(m_fontAASettings, &FontAASettings::excludeFromChanged, this, updateState); | ||||
453 | connect(m_fontAASettings, &FontAASettings::excludeToChanged, this, updateState); | 461 | connect(m_fontAASettings, &FontAASettings::excludeToChanged, this, updateState); | ||
454 | connect(m_fontAASettings, &FontAASettings::antiAliasingChanged, this, updateState); | 462 | connect(m_fontAASettings, &FontAASettings::antiAliasingChanged, this, updateState); | ||
455 | connect(m_fontAASettings, &FontAASettings::aliasingChanged, this, updateState); | 463 | connect(m_fontAASettings, &FontAASettings::aliasingChanged, this, updateState); | ||
456 | connect(m_fontAASettings, &FontAASettings::dpiChanged, this, updateState); | 464 | connect(m_fontAASettings, &FontAASettings::dpiChanged, this, updateState); | ||
457 | } | 465 | } | ||
458 | 466 | | |||
459 | KFonts::~KFonts() | 467 | KFonts::~KFonts() | ||
460 | { | 468 | { | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 525 | { | |||
534 | m_smallFontOriginal = m_smallFont; | 542 | m_smallFontOriginal = m_smallFont; | ||
535 | m_toolbarFontOriginal = m_toolbarFont; | 543 | m_toolbarFontOriginal = m_toolbarFont; | ||
536 | m_menuFontOriginal = m_menuFont; | 544 | m_menuFontOriginal = m_menuFont; | ||
537 | m_windowTitleFontOriginal = m_windowTitleFont; | 545 | m_windowTitleFontOriginal = m_windowTitleFont; | ||
538 | 546 | | |||
539 | KConfig _cfgfonts("kcmfonts"); | 547 | KConfig _cfgfonts("kcmfonts"); | ||
540 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | 548 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | ||
541 | 549 | | |||
542 | FontAASettings::AASetting aaSetting = (FontAASettings::AASetting)m_fontAASettings->antiAliasing(); | 550 | FontAASettings::AASetting aaSetting = FontAASettings::AASystem; | ||
551 | if (m_fontAASettings->antiAliasingNeedsSave()) { | ||||
552 | aaSetting = m_fontAASettings->antiAliasing() ? FontAASettings::AAEnabled : FontAASettings::AADisabled; | ||||
553 | } | ||||
543 | cfgfonts.writeEntry("dontChangeAASettings", aaSetting == FontAASettings::AASystem); | 554 | cfgfonts.writeEntry("dontChangeAASettings", aaSetting == FontAASettings::AASystem); | ||
544 | 555 | | |||
545 | if (aaSetting == FontAASettings::AAEnabled) { | 556 | if (aaSetting == FontAASettings::AAEnabled) { | ||
546 | m_fontAASettings->save(KXftConfig::AntiAliasing::Enabled); | 557 | m_fontAASettings->save(KXftConfig::AntiAliasing::Enabled); | ||
547 | } else if (aaSetting == FontAASettings::AADisabled) { | 558 | } else if (aaSetting == FontAASettings::AADisabled) { | ||
548 | m_fontAASettings->save(KXftConfig::AntiAliasing::Disabled); | 559 | m_fontAASettings->save(KXftConfig::AntiAliasing::Disabled); | ||
549 | } else { | 560 | } else { | ||
550 | m_fontAASettings->save(KXftConfig::AntiAliasing::NotSet); | 561 | m_fontAASettings->save(KXftConfig::AntiAliasing::NotSet); | ||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 711 | if (fontDiffFlags & KFontChooser::FontDiffStyle) { | |||
702 | font.setStyle(newFont.style()); | 713 | font.setStyle(newFont.style()); | ||
703 | font.setUnderline(newFont.underline()); | 714 | font.setUnderline(newFont.underline()); | ||
704 | font.setStyleName(newFont.styleName()); | 715 | font.setStyleName(newFont.styleName()); | ||
705 | } | 716 | } | ||
706 | 717 | | |||
707 | return font; | 718 | return font; | ||
708 | } | 719 | } | ||
709 | 720 | | |||
721 | bool FontAASettings::State::operator==(const State& other) const | ||||
722 | { | ||||
723 | if ( | ||||
724 | exclude != other.exclude | ||||
725 | || antiAliasing != other.antiAliasing | ||||
726 | || dpi != other.dpi | ||||
727 | || subPixel != other.subPixel | ||||
728 | || hinting != other.hinting | ||||
729 | ) { | ||||
730 | return false; | ||||
731 | } | ||||
732 | | ||||
733 | if (exclude && (excludeFrom != other.excludeFrom || excludeTo != other.excludeTo)) { | ||||
734 | return false; | ||||
735 | } | ||||
736 | | ||||
737 | return true; | ||||
738 | } | ||||
739 | | ||||
740 | bool FontAASettings::State::operator!=(const State& other) const | ||||
741 | { | ||||
742 | return !(*this == other); | ||||
743 | } | ||||
744 | | ||||
710 | #include "fonts.moc" | 745 | #include "fonts.moc" | ||
711 | 746 | |