Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/fonts.cpp
Show First 20 Lines • Show All 658 Lines • ▼ Show 20 Line(s) | 647 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | |||
---|---|---|---|---|---|
659 | label->setBuddy(cbAA); | 659 | label->setBuddy(cbAA); | ||
660 | lay->addWidget(cbAA, 0, 1); | 660 | lay->addWidget(cbAA, 0, 1); | ||
661 | lay->addWidget(aaSettingsButton, 0, 2); | 661 | lay->addWidget(aaSettingsButton, 0, 2); | ||
662 | // Initialize aaSettingsButton state based on the current cbAA->currentIndex value, will be eventually updated at load() | 662 | // Initialize aaSettingsButton state based on the current cbAA->currentIndex value, will be eventually updated at load() | ||
663 | slotUseAntiAliasing(); | 663 | slotUseAntiAliasing(); | ||
664 | 664 | | |||
665 | connect(cbAA, SIGNAL(currentIndexChanged(int)), SLOT(slotUseAntiAliasing())); | 665 | connect(cbAA, SIGNAL(currentIndexChanged(int)), SLOT(slotUseAntiAliasing())); | ||
666 | #endif | 666 | #endif | ||
667 | #if HAVE_X11 | | |||
668 | checkboxForceDpi = new QCheckBox(i18n("Force fonts DPI:"), this); | 667 | checkboxForceDpi = new QCheckBox(i18n("Force fonts DPI:"), this); | ||
669 | lay->addWidget(checkboxForceDpi, 1, 0); | 668 | lay->addWidget(checkboxForceDpi, 1, 0); | ||
670 | spinboxDpi = new QSpinBox(this); | 669 | spinboxDpi = new QSpinBox(this); | ||
671 | spinboxDpi->setRange(1, 1000); | 670 | spinboxDpi->setRange(1, 1000); | ||
672 | spinboxDpi->setSingleStep(24); // The common DPI values 72, 96 and 120 are multiples of 24 | 671 | spinboxDpi->setSingleStep(24); // The common DPI values 72, 96 and 120 are multiples of 24 | ||
673 | QString whatsthis = i18n( | 672 | QString whatsthis = i18n( | ||
674 | "<p>This option forces a specific DPI value for fonts. It may be useful" | 673 | "<p>This option forces a specific DPI value for fonts. It may be useful" | ||
675 | " when the real DPI of the hardware is not detected properly and it" | 674 | " when the real DPI of the hardware is not detected properly and it" | ||
676 | " is also often misused when poor quality fonts are used that do not" | 675 | " is also often misused when poor quality fonts are used that do not" | ||
677 | " look well with DPI values other than 96 or 120 DPI.</p>" | 676 | " look well with DPI values other than 96 or 120 DPI.</p>" | ||
678 | "<p>The use of this option is generally discouraged. For selecting proper DPI" | 677 | "<p>The use of this option is generally discouraged. For selecting proper DPI" | ||
679 | " value a better option is explicitly configuring it for the whole X server if" | 678 | " value a better option is explicitly configuring it for the whole X server if" | ||
680 | " possible (e.g. DisplaySize in xorg.conf). When fonts do not render" | 679 | " possible (e.g. DisplaySize in xorg.conf). When fonts do not render" | ||
681 | " properly with real DPI value better fonts should be used or configuration" | 680 | " properly with real DPI value better fonts should be used or configuration" | ||
682 | " of font hinting should be checked.</p>"); | 681 | " of font hinting should be checked.</p>"); | ||
683 | spinboxDpi->setWhatsThis(whatsthis); | 682 | spinboxDpi->setWhatsThis(whatsthis); | ||
684 | checkboxForceDpi->setChecked(false); | 683 | checkboxForceDpi->setChecked(false); | ||
685 | spinboxDpi->setEnabled(false); | 684 | spinboxDpi->setEnabled(false); | ||
686 | connect(spinboxDpi, SIGNAL(valueChanged(int)), SLOT(changed())); | 685 | connect(spinboxDpi, SIGNAL(valueChanged(int)), SLOT(changed())); | ||
687 | connect(checkboxForceDpi, SIGNAL(toggled(bool)), SLOT(changed())); | 686 | connect(checkboxForceDpi, SIGNAL(toggled(bool)), SLOT(changed())); | ||
688 | connect(checkboxForceDpi, &QAbstractButton::toggled, spinboxDpi, &QWidget::setEnabled); | 687 | connect(checkboxForceDpi, &QAbstractButton::toggled, spinboxDpi, &QWidget::setEnabled); | ||
689 | lay->addWidget(spinboxDpi, 1, 1); | 688 | lay->addWidget(spinboxDpi, 1, 1); | ||
690 | #endif | | |||
691 | layout->addStretch(1); | 689 | layout->addStretch(1); | ||
692 | 690 | | |||
693 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 691 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
694 | aaSettings = new FontAASettings(this); | 692 | aaSettings = new FontAASettings(this); | ||
695 | #endif | 693 | #endif | ||
696 | 694 | | |||
697 | } | 695 | } | ||
698 | 696 | | |||
Show All 19 Lines | 715 | for (int i = 0; i < (int) fontUseList.count(); i++) { | |||
718 | fontUseList.at(i)->setDefault(); | 716 | fontUseList.at(i)->setDefault(); | ||
719 | } | 717 | } | ||
720 | 718 | | |||
721 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 719 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
722 | useAA = AASystem; | 720 | useAA = AASystem; | ||
723 | cbAA->setCurrentIndex(useAA); | 721 | cbAA->setCurrentIndex(useAA); | ||
724 | aaSettings->defaults(); | 722 | aaSettings->defaults(); | ||
725 | #endif | 723 | #endif | ||
726 | #if HAVE_X11 | | |||
727 | checkboxForceDpi->setChecked(false); | 724 | checkboxForceDpi->setChecked(false); | ||
728 | spinboxDpi->setValue(96); | 725 | spinboxDpi->setValue(96); | ||
729 | #endif | | |||
730 | emit changed(true); | 726 | emit changed(true); | ||
731 | } | 727 | } | ||
732 | 728 | | |||
733 | void KFonts::load() | 729 | void KFonts::load() | ||
734 | { | 730 | { | ||
735 | QList<FontUseItem *>::Iterator it(fontUseList.begin()), | 731 | QList<FontUseItem *>::Iterator it(fontUseList.begin()), | ||
736 | end(fontUseList.end()); | 732 | end(fontUseList.end()); | ||
737 | 733 | | |||
738 | for (; it != end; ++it) { | 734 | for (; it != end; ++it) { | ||
739 | (*it)->readFont(); | 735 | (*it)->readFont(); | ||
740 | } | 736 | } | ||
741 | 737 | | |||
742 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 738 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
743 | useAA_original = useAA = aaSettings->load() ? AAEnabled : AADisabled; | 739 | useAA_original = useAA = aaSettings->load() ? AAEnabled : AADisabled; | ||
744 | cbAA->setCurrentIndex(useAA); | 740 | cbAA->setCurrentIndex(useAA); | ||
745 | #endif | 741 | #endif | ||
746 | 742 | | |||
747 | KConfig _cfgfonts("kcmfonts"); | 743 | KConfig _cfgfonts("kcmfonts"); | ||
748 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | 744 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | ||
749 | #if HAVE_X11 | | |||
750 | int dpicfg = cfgfonts.readEntry("forceFontDPI", 0); | 745 | int dpicfg = cfgfonts.readEntry("forceFontDPI", 0); | ||
751 | if (dpicfg <= 0) { | 746 | if (dpicfg <= 0) { | ||
752 | checkboxForceDpi->setChecked(false); | 747 | checkboxForceDpi->setChecked(false); | ||
753 | spinboxDpi->setValue(96); | 748 | spinboxDpi->setValue(96); | ||
754 | dpi_original = 0; | 749 | dpi_original = 0; | ||
755 | } else { | 750 | } else { | ||
756 | checkboxForceDpi->setChecked(true); | 751 | checkboxForceDpi->setChecked(true); | ||
757 | spinboxDpi->setValue(dpicfg); | 752 | spinboxDpi->setValue(dpicfg); | ||
758 | dpi_original = dpicfg; | 753 | dpi_original = dpicfg; | ||
759 | }; | 754 | }; | ||
760 | #endif | | |||
761 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 755 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
762 | if (cfgfonts.readEntry("dontChangeAASettings", true)) { | 756 | if (cfgfonts.readEntry("dontChangeAASettings", true)) { | ||
763 | useAA_original = useAA = AASystem; | 757 | useAA_original = useAA = AASystem; | ||
764 | cbAA->setCurrentIndex(useAA); | 758 | cbAA->setCurrentIndex(useAA); | ||
765 | } | 759 | } | ||
766 | #endif | 760 | #endif | ||
767 | 761 | | |||
768 | emit changed(false); | 762 | emit changed(false); | ||
769 | } | 763 | } | ||
770 | 764 | | |||
771 | void KFonts::save() | 765 | void KFonts::save() | ||
772 | { | 766 | { | ||
773 | QList<FontUseItem *>::Iterator it(fontUseList.begin()), | 767 | QList<FontUseItem *>::Iterator it(fontUseList.begin()), | ||
774 | end(fontUseList.end()); | 768 | end(fontUseList.end()); | ||
775 | 769 | | |||
776 | for (; it != end; ++it) { | 770 | for (; it != end; ++it) { | ||
777 | (*it)->writeFont(); | 771 | (*it)->writeFont(); | ||
778 | } | 772 | } | ||
779 | 773 | | |||
780 | KSharedConfig::openConfig()->sync(); | 774 | KSharedConfig::openConfig()->sync(); | ||
781 | 775 | | |||
782 | KConfig _cfgfonts("kcmfonts"); | 776 | KConfig _cfgfonts("kcmfonts"); | ||
783 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | 777 | KConfigGroup cfgfonts(&_cfgfonts, "General"); | ||
784 | #if HAVE_X11 | | |||
785 | int dpi = (checkboxForceDpi->isChecked() ? spinboxDpi->value() : 0); | 778 | int dpi = (checkboxForceDpi->isChecked() ? spinboxDpi->value() : 0); | ||
786 | cfgfonts.writeEntry("forceFontDPI", dpi); | 779 | cfgfonts.writeEntry("forceFontDPI", dpi); | ||
787 | #endif | | |||
788 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | 780 | #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) | ||
789 | cfgfonts.writeEntry("dontChangeAASettings", cbAA->currentIndex() == AASystem); | 781 | cfgfonts.writeEntry("dontChangeAASettings", cbAA->currentIndex() == AASystem); | ||
790 | #endif | 782 | #endif | ||
791 | cfgfonts.sync(); | 783 | cfgfonts.sync(); | ||
792 | #if HAVE_X11 | 784 | #if HAVE_X11 | ||
793 | // if the setting is reset in the module, remove the dpi value, | 785 | // if the setting is reset in the module, remove the dpi value, | ||
794 | // otherwise don't explicitly remove it and leave any possible system-wide value | 786 | // otherwise don't explicitly remove it and leave any possible system-wide value | ||
795 | if (dpi == 0 && dpi_original != 0) { | 787 | if (dpi == 0 && dpi_original != 0) { | ||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |