Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/fonts.cpp
Show All 25 Lines | |||||
26 | 26 | | |||
27 | 27 | | |||
28 | #include "fonts.h" | 28 | #include "fonts.h" | ||
29 | 29 | | |||
30 | #include <QQuickItem> | 30 | #include <QQuickItem> | ||
31 | #include <QWindow> | 31 | #include <QWindow> | ||
32 | #include <QQmlEngine> | 32 | #include <QQmlEngine> | ||
33 | #include <QQuickView> | 33 | #include <QQuickView> | ||
34 | #include <QDebug> | | |||
35 | #include <QFontDialog> | 34 | #include <QFontDialog> | ||
36 | #include <QApplication> | 35 | #include <QApplication> | ||
37 | #include <QFontDatabase> | 36 | #include <QFontDatabase> | ||
38 | 37 | | |||
39 | #include <KAcceleratorManager> | 38 | #include <KAcceleratorManager> | ||
40 | #include <KGlobalSettings> | 39 | #include <KGlobalSettings> | ||
41 | #include <KConfigGroup> | 40 | #include <KConfigGroup> | ||
42 | #include <KConfig> | 41 | #include <KConfig> | ||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Line(s) | 463 | { | |||
465 | return m_state.hinting - KXftConfig::Hint::None; | 464 | return m_state.hinting - KXftConfig::Hint::None; | ||
466 | } | 465 | } | ||
467 | 466 | | |||
468 | bool FontAASettings::needsSave() const | 467 | bool FontAASettings::needsSave() const | ||
469 | { | 468 | { | ||
470 | return m_state != m_originalState; | 469 | return m_state != m_originalState; | ||
471 | } | 470 | } | ||
472 | 471 | | |||
472 | bool FontAASettings::isDefaults() const | ||||
ervin: The curly brace is misplaced | |||||
473 | { | ||||
meven: You can make this static. | |||||
meven: Just a nitpick, I guess you plan to change it soon. | |||||
bport: It will be changed when we migrate this part to kconfigxt | |||||
474 | State defaultState{}; | ||||
475 | defaultState.exclude = false; | ||||
476 | defaultState.excludeTo = 15; | ||||
477 | defaultState.excludeFrom = 8; | ||||
478 | defaultState.antiAliasing = true; | ||||
479 | defaultState.dpi = 0; | ||||
Kinda defies the purpose of using kconfigxt if we end up hardcoding the state in code again? broulik: Kinda defies the purpose of using kconfigxt if we end up hardcoding the state in code again? | |||||
That part was never transitioned to KConfigXT though since it doesn't have a KConfig backend. Clearly inheriting by hand from KCoreConfigSkeleton should be next on the options to be evaluated (not in that patch though). ervin: That part was never transitioned to KConfigXT though since it doesn't have a KConfig backend. | |||||
480 | defaultState.subPixel = KXftConfig::SubPixel::Rgb; | ||||
481 | defaultState.hinting = KXftConfig::Hint::Slight; | ||||
482 | return m_state == defaultState; | ||||
483 | } | ||||
484 | | ||||
473 | bool FontAASettings::State::operator==(const State& other) const | 485 | bool FontAASettings::State::operator==(const State& other) const | ||
474 | { | 486 | { | ||
475 | if ( | 487 | if ( | ||
476 | exclude != other.exclude | 488 | exclude != other.exclude | ||
477 | || antiAliasing != other.antiAliasing | 489 | || antiAliasing != other.antiAliasing | ||
478 | || dpi != other.dpi | 490 | || dpi != other.dpi | ||
479 | || subPixel != other.subPixel | 491 | || subPixel != other.subPixel | ||
480 | || hinting != other.hinting | 492 | || hinting != other.hinting | ||
Show All 24 Lines | 516 | KAboutData* about = new KAboutData("kcm_fonts", i18n("Fonts"), | |||
505 | "0.1", QString(), KAboutLicense::LGPL); | 517 | "0.1", QString(), KAboutLicense::LGPL); | ||
506 | about->addAuthor(i18n("Antonis Tsiapaliokas"), QString(), "antonis.tsiapaliokas@kde.org"); | 518 | about->addAuthor(i18n("Antonis Tsiapaliokas"), QString(), "antonis.tsiapaliokas@kde.org"); | ||
507 | setAboutData(about); | 519 | setAboutData(about); | ||
508 | qmlRegisterType<QStandardItemModel>(); | 520 | qmlRegisterType<QStandardItemModel>(); | ||
509 | qmlRegisterType<FontsSettings>(); | 521 | qmlRegisterType<FontsSettings>(); | ||
510 | 522 | | |||
511 | setButtons(Apply | Default | Help); | 523 | setButtons(Apply | Default | Help); | ||
512 | 524 | | |||
513 | auto updateState = [this]() { | 525 | connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, &KFonts::settingsChanged); | ||
514 | setNeedsSave(m_fontAASettings->needsSave()); | 526 | connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, &KFonts::settingsChanged); | ||
515 | }; | 527 | connect(m_fontAASettings, &FontAASettings::excludeChanged, this, &KFonts::settingsChanged); | ||
516 | 528 | connect(m_fontAASettings, &FontAASettings::excludeFromChanged, this, &KFonts::settingsChanged); | |||
517 | connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, updateState); | 529 | connect(m_fontAASettings, &FontAASettings::excludeToChanged, this, &KFonts::settingsChanged); | ||
518 | connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, updateState); | 530 | connect(m_fontAASettings, &FontAASettings::antiAliasingChanged, this, &KFonts::settingsChanged); | ||
519 | connect(m_fontAASettings, &FontAASettings::excludeChanged, this, updateState); | 531 | connect(m_fontAASettings, &FontAASettings::aliasingChanged, this, &KFonts::settingsChanged); | ||
520 | connect(m_fontAASettings, &FontAASettings::excludeFromChanged, this, updateState); | 532 | connect(m_fontAASettings, &FontAASettings::dpiChanged, this, &KFonts::settingsChanged); | ||
521 | connect(m_fontAASettings, &FontAASettings::excludeToChanged, this, updateState); | | |||
522 | connect(m_fontAASettings, &FontAASettings::antiAliasingChanged, this, updateState); | | |||
523 | connect(m_fontAASettings, &FontAASettings::aliasingChanged, this, updateState); | | |||
524 | connect(m_fontAASettings, &FontAASettings::dpiChanged, this, updateState); | | |||
525 | } | 533 | } | ||
526 | 534 | | |||
527 | KFonts::~KFonts() | 535 | KFonts::~KFonts() | ||
528 | { | 536 | { | ||
529 | } | 537 | } | ||
530 | 538 | | |||
531 | FontsSettings *KFonts::fontsSettings() const | 539 | FontsSettings *KFonts::fontsSettings() const | ||
532 | { | 540 | { | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 580 | { | |||
596 | emit fontsHaveChanged(); | 604 | emit fontsHaveChanged(); | ||
597 | } | 605 | } | ||
598 | 606 | | |||
599 | bool KFonts::isSaveNeeded() const | 607 | bool KFonts::isSaveNeeded() const | ||
600 | { | 608 | { | ||
601 | return m_fontAASettings->needsSave(); | 609 | return m_fontAASettings->needsSave(); | ||
602 | } | 610 | } | ||
603 | 611 | | |||
612 | bool KFonts::isDefaults() const | ||||
613 | { | ||||
614 | return m_fontAASettings->isDefaults(); | ||||
615 | } | ||||
616 | | ||||
604 | void KFonts::adjustAllFonts() | 617 | void KFonts::adjustAllFonts() | ||
605 | { | 618 | { | ||
606 | QFont font = m_settings->font(); | 619 | QFont font = m_settings->font(); | ||
607 | KFontChooser::FontDiffFlags fontDiffFlags; | 620 | KFontChooser::FontDiffFlags fontDiffFlags; | ||
608 | int ret = KFontDialog::getFontDiff(font, fontDiffFlags, KFontChooser::NoDisplayFlags); | 621 | int ret = KFontDialog::getFontDiff(font, fontDiffFlags, KFontChooser::NoDisplayFlags); | ||
609 | 622 | | |||
610 | if (ret == KDialog::Accepted && fontDiffFlags) { | 623 | if (ret == KDialog::Accepted && fontDiffFlags) { | ||
611 | if (!m_settings->isImmutable("font")) { | 624 | if (!m_settings->isImmutable("font")) { | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
The curly brace is misplaced