diff --git a/kcms/fonts/CMakeLists.txt b/kcms/fonts/CMakeLists.txt index d73636edf..72e9757a2 100644 --- a/kcms/fonts/CMakeLists.txt +++ b/kcms/fonts/CMakeLists.txt @@ -1,39 +1,45 @@ # KI18N Translation Domain for this library add_definitions(-DTRANSLATION_DOMAIN=\"kcmfonts\") if(FONTCONFIG_FOUND) include_directories(${FONTCONFIG_INCLUDE_DIR}) endif() include_directories(${FREETYPE_INCLUDE_DIRS}) ########### next target ############### set(kcm_fonts_PART_SRCS ../krdb/krdb.cpp fonts.cpp) if(X11_FOUND) set(kcm_fonts_PART_SRCS ${kcm_fonts_PART_SRCS} ${libkxftconfig_SRCS}) endif() set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml) qt5_add_dbus_interface(kcm_fonts_PART_SRCS ${klauncher_xml} klauncher_iface) add_library(kcm_fonts MODULE ${kcm_fonts_PART_SRCS}) target_link_libraries(kcm_fonts Qt5::DBus Qt5::Xml KF5::KCMUtils KF5::I18n KF5::KDELibs4Support ${FREETYPE_LIBRARIES}) if(X11_FOUND) - target_link_libraries(kcm_fonts Qt5::X11Extras) + target_link_libraries(kcm_fonts + Qt5::X11Extras + KF5::I18n + KF5::Plasma + KF5::PlasmaQuick + KF5::Declarative + KF5::QuickAddons) if(FONTCONFIG_FOUND) target_link_libraries(kcm_fonts ${FONTCONFIG_LIBRARIES}) endif() target_link_libraries(kcm_fonts ${X11_LIBRARIES}) endif() -install(TARGETS kcm_fonts DESTINATION ${PLUGIN_INSTALL_DIR} ) - +kcoreaddons_desktop_to_json(kcm_fonts "kcm_fonts.desktop") ########### install files ############### - -install( FILES fonts.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +install(TARGETS kcm_fonts DESTINATION ${PLUGIN_INSTALL_DIR}/kcms) +install(FILES kcm_fonts.desktop DESTINATION ${SERVICES_INSTALL_DIR}) +kpackage_install_package(package kcm_fonts kcms) diff --git a/kcms/fonts/fonts.cpp b/kcms/fonts/fonts.cpp index 543e20655..401328b8c 100644 --- a/kcms/fonts/fonts.cpp +++ b/kcms/fonts/fonts.cpp @@ -1,892 +1,463 @@ /* Copyright 1997 Mark Donohoe Copyright 1999 Lars Knoll Copyright 2000 Rik Hemsley Ported to kcontrol2 by Geert Jansen. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include #include "fonts.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//Added by qt3to4: -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include + #include +#include #include -#include -#include #include +#include #include #include -#include +#include #include "../krdb/krdb.h" -#ifdef HAVE_FREETYPE -#include -#ifdef FT_LCD_FILTER_H -#include FT_FREETYPE_H -#include FT_LCD_FILTER_H -#endif -#endif - -#if HAVE_X11 -#include -#endif - -#if HAVE_X11 -// X11 headers -#undef Bool -#undef Unsorted -#undef None -#endif - -static const char *const aa_rgb_xpm[] = { - "12 12 3 1", - "a c #0000ff", - "# c #00ff00", - ". c #ff0000", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa" -}; -static const char *const aa_bgr_xpm[] = { - "12 12 3 1", - ". c #0000ff", - "# c #00ff00", - "a c #ff0000", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa", - "....####aaaa" -}; -static const char *const aa_vrgb_xpm[] = { - "12 12 3 1", - "a c #0000ff", - "# c #00ff00", - ". c #ff0000", - "............", - "............", - "............", - "............", - "############", - "############", - "############", - "############", - "aaaaaaaaaaaa", - "aaaaaaaaaaaa", - "aaaaaaaaaaaa", - "aaaaaaaaaaaa" -}; -static const char *const aa_vbgr_xpm[] = { - "12 12 3 1", - ". c #0000ff", - "# c #00ff00", - "a c #ff0000", - "............", - "............", - "............", - "............", - "############", - "############", - "############", - "############", - "aaaaaaaaaaaa", - "aaaaaaaaaaaa", - "aaaaaaaaaaaa", - "aaaaaaaaaaaa" -}; - -static const char *const *const aaPixmaps[] = { 0, 0, aa_rgb_xpm, aa_bgr_xpm, aa_vrgb_xpm, aa_vbgr_xpm }; - /**** DLL Interface ****/ -K_PLUGIN_FACTORY(FontFactory, registerPlugin();) - -/**** FontUseItem ****/ - -FontUseItem::FontUseItem( - QWidget *parent, - const QString &name, - const QString &grp, - const QString &key, - const QString &rc, - const QFont &default_fnt, - bool f -) - : KFontRequester(parent, f), - _rcfile(rc), - _rcgroup(grp), - _rckey(key), - _default(default_fnt) -{ - KAcceleratorManager::setNoAccel(this); - setTitle(name); - readFont(); -} - -void FontUseItem::setDefault() -{ - setFont(_default, isFixedOnly()); -} - -void FontUseItem::readFont() -{ - const KConfig *config = KSharedConfig::openConfig(_rcfile).data(); - const KConfigGroup group(config, _rcgroup); - QFont tmpFnt(_default); - setFont(group.readEntry(_rckey, tmpFnt), isFixedOnly()); -} - -void FontUseItem::writeFont() -{ - KConfig *config = KSharedConfig::openConfig(_rcfile).data(); - if (_rcfile.isEmpty()) { - KConfigGroup(config, _rcgroup).writeEntry(_rckey, font(), KConfig::Normal | KConfig::Global); - } else { - KConfigGroup(config, _rcgroup).writeEntry(_rckey, font()); - config->sync(); - } -} - -void FontUseItem::applyFontDiff(const QFont &fnt, int fontDiffFlags) -{ - QFont _font(font()); - - if (fontDiffFlags & KFontChooser::FontDiffSize) { - _font.setPointSizeF(fnt.pointSizeF()); - } - if (fontDiffFlags & KFontChooser::FontDiffFamily) { - if (!isFixedOnly() || QFontInfo(fnt).fixedPitch()) { - _font.setFamily(fnt.family()); - } - } - if (fontDiffFlags & KFontChooser::FontDiffStyle) { - _font.setWeight(fnt.weight()); - _font.setStyle(fnt.style()); - _font.setUnderline(fnt.underline()); -#if QT_VERSION >= 0x040800 - _font.setStyleName(fnt.styleName()); -#endif - } - - setFont(_font, isFixedOnly()); -} +K_PLUGIN_FACTORY_WITH_JSON(KFontsFactory, "kcm_fonts.json", registerPlugin();) /**** FontAASettings ****/ #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) -FontAASettings::FontAASettings(QWidget *parent) - : QDialog(parent), - changesMade(false) +FontAASettings::FontAASettings(QObject *parent) + : QObject(parent) + , m_subPixelOptionsModel(new QStandardItemModel(this)) + , m_hintingOptionsModel(new QStandardItemModel(this)) + , m_subPixel(QString("System default")) + , m_hinting(QString("System default")) { - setObjectName("FontAASettings"); - setModal(true); - setWindowTitle(i18n("Configure Anti-Alias Settings")); - - QVBoxLayout *mainLayout = new QVBoxLayout(this); - - QFormLayout *layout = new QFormLayout(); - layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); - - excludeRange = new QCheckBox(i18n("E&xclude range:"), this); - QHBoxLayout *rangeLayout = new QHBoxLayout(); - - excludeFrom = new QDoubleSpinBox(this); - excludeFrom->setRange(0.0, 72.0); - excludeFrom->setValue(8.0); - excludeFrom->setSingleStep(1.0); - excludeFrom->setDecimals(1); - excludeFrom->setSuffix(i18nc("abbreviation for unit of points", " pt")); - rangeLayout->addWidget(excludeFrom); - - excludeToLabel = new QLabel(i18n(" to "), this); - rangeLayout->addWidget(excludeToLabel); - - excludeTo = new QDoubleSpinBox(this); - excludeTo->setRange(0.0, 72.0); - excludeTo->setValue(15.0); - excludeTo->setSingleStep(1.0); - excludeTo->setDecimals(1); - excludeTo->setSuffix(i18nc("abbreviation for unit of points", " pt")); - rangeLayout->addWidget(excludeTo); - - layout->addRow(excludeRange, rangeLayout); - - QString subPixelWhatsThis = i18n("

If you have a TFT or LCD screen you" - " can further improve the quality of displayed fonts by selecting" - " this option.
Sub-pixel rendering is also known as ClearType(tm).
" - " In order for sub-pixel rendering to" - " work correctly you need to know how the sub-pixels of your display" - " are aligned.

" - "

On TFT or LCD displays a single pixel is actually composed of" - " three sub-pixels, red, green and blue. Most displays" - " have a linear ordering of RGB sub-pixel, some have BGR.
" - " This feature does not work with CRT monitors.

"); - - subPixelLabel = new QLabel(i18n("Sub-pixel rendering type:"), this); - subPixelLabel->setWhatsThis(subPixelWhatsThis); - - subPixelType = new QComboBox(this); - layout->addRow(subPixelLabel, subPixelType); - - subPixelType->setEditable(false); - subPixelType->setWhatsThis(subPixelWhatsThis); - for (int t = KXftConfig::SubPixel::NotSet; t <= KXftConfig::SubPixel::Vbgr; ++t) { - subPixelType->addItem(QPixmap(aaPixmaps[t]), i18n(KXftConfig::description((KXftConfig::SubPixel::Type)t).toUtf8())); + QStandardItem *item = new QStandardItem(i18n(KXftConfig::description((KXftConfig::SubPixel::Type)t).toUtf8())); + m_subPixelOptionsModel->appendRow(item); } - QLabel *hintingLabel = new QLabel(i18n("Hinting style:"), this); - hintingStyle = new QComboBox(this); - hintingStyle->setEditable(false); - layout->addRow(hintingLabel, hintingStyle); for (int s = KXftConfig::Hint::NotSet; s <= KXftConfig::Hint::Full; ++s) { - hintingStyle->addItem(i18n(KXftConfig::description((KXftConfig::Hint::Style)s).toUtf8())); + QStandardItem * item = new QStandardItem(i18n(KXftConfig::description((KXftConfig::Hint::Style)s).toUtf8())); + m_hintingOptionsModel->appendRow(item); } - - QString hintingText(i18n("Hinting is a process used to enhance the quality of fonts at small sizes.")); - hintingStyle->setWhatsThis(hintingText); - hintingLabel->setWhatsThis(hintingText); - load(); - enableWidgets(); - - QHBoxLayout *outerLayout = new QHBoxLayout(); - outerLayout->addLayout(layout); - outerLayout->addStretch(1); - - mainLayout->addLayout(outerLayout); - mainLayout->addStretch(1); - mainLayout->addSpacing(style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); - - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this); - buttonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::CTRL|Qt::Key_Return); - connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - mainLayout->addWidget(buttonBox); - - connect(excludeRange, &QAbstractButton::toggled, this, &FontAASettings::changed); - connect(excludeFrom, static_cast(&QDoubleSpinBox::valueChanged), - this, &FontAASettings::changed); - connect(excludeTo, static_cast(&QDoubleSpinBox::valueChanged), - this, &FontAASettings::changed); - connect(subPixelType, static_cast(&QComboBox::activated), - this, &FontAASettings::changed); - connect(hintingStyle, static_cast(&QComboBox::activated), - this, &FontAASettings::changed); } -bool FontAASettings::load() +void FontAASettings::load() { double from, to; KXftConfig xft; if (xft.getExcludeRange(from, to)) { - excludeRange->setChecked(true); + m_excludeFrom = from; + m_excludeTo = to; } else { - excludeRange->setChecked(false); - from = 8.0; - to = 15.0; + m_excludeFrom = 8; + m_excludeTo = 15; } - excludeFrom->setValue(from); - excludeTo->setValue(to); - KXftConfig::SubPixel::Type spType; xft.getSubPixelType(spType); - int idx = getIndex(spType); - - subPixelType->setCurrentIndex(idx); + m_subPixel = KXftConfig::description(spType); KXftConfig::Hint::Style hStyle; if (!xft.getHintStyle(hStyle) || KXftConfig::Hint::NotSet == hStyle) { + KConfig kglobals("kdeglobals", KConfig::NoGlobals); + hStyle = KXftConfig::Hint::NotSet; xft.setHintStyle(hStyle); + KConfigGroup(&kglobals, "General").writeEntry("XftHintStyle", KXftConfig::toStr(hStyle)); + kglobals.sync(); runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); + } else { + m_hinting = KXftConfig::description(hStyle); } - hintingStyle->setCurrentIndex(getIndex(hStyle)); - - enableWidgets(); + KConfig _cfgfonts("kcmfonts"); + KConfigGroup cfgfonts(&_cfgfonts, "General"); + setDpi(cfgfonts.readEntry("forceFontDPI", 0)); - return xft.aliasingEnabled(); + if (cfgfonts.readEntry("dontChangeAASettings", true)) { + setAntiAliasing(1); //AASystem + } else if (xft.aliasingEnabled()) { + setAntiAliasing(0); //AAEnabled + } else { + setAntiAliasing(2); //AADisabled + } } bool FontAASettings::save(KXftConfig::AntiAliasing::State aaState) { KXftConfig xft; KConfig kglobals("kdeglobals", KConfig::NoGlobals); KConfigGroup grp(&kglobals, "General"); xft.setAntiAliasing(aaState); - - if (excludeRange->isChecked()) { - xft.setExcludeRange(excludeFrom->value(), excludeTo->value()); - } else { - xft.setExcludeRange(0, 0); - } + xft.setExcludeRange(m_excludeFrom, m_excludeTo); KXftConfig::SubPixel::Type spType(getSubPixelType()); xft.setSubPixelType(spType); - if (KXftConfig::SubPixel::NotSet == spType) { - grp.revertToDefault("XftSubPixel"); - } else { - grp.writeEntry("XftSubPixel", KXftConfig::toStr(spType)); - } - + grp.writeEntry("XftSubPixel", KXftConfig::toStr(spType)); if (KXftConfig::AntiAliasing::NotSet == aaState) { grp.revertToDefault("XftAntialias"); } else { grp.writeEntry("XftAntialias", aaState == KXftConfig::AntiAliasing::Enabled); } bool mod = false; KXftConfig::Hint::Style hStyle(getHintStyle()); xft.setHintStyle(hStyle); QString hs(KXftConfig::toStr(hStyle)); + if (hs != grp.readEntry("XftHintStyle")) { if (KXftConfig::Hint::NotSet == hStyle) { grp.revertToDefault("XftHintStyle"); } else { grp.writeEntry("XftHintStyle", hs); } } mod = true; kglobals.sync(); if (!mod) { mod = xft.changed(); } xft.apply(); + KConfig _cfgfonts("kcmfonts"); + KConfigGroup cfgfonts(&_cfgfonts, "General"); + cfgfonts.writeEntry("forceFontDPI", m_dpi); + cfgfonts.sync(); + return mod; } void FontAASettings::defaults() { - excludeRange->setChecked(false); - excludeFrom->setValue(8.0); - excludeTo->setValue(15.0); - subPixelType->setCurrentIndex(getIndex(KXftConfig::SubPixel::NotSet)); - hintingStyle->setCurrentIndex(getIndex(KXftConfig::Hint::NotSet)); - enableWidgets(); + setExcludeTo(15); + setExcludeFrom(8); + setAntiAliasing(1); + setDpi(96); + setSubPixel(KXftConfig::description(KXftConfig::SubPixel::NotSet)); + setHinting(KXftConfig::description(KXftConfig::Hint::NotSet)); } -int FontAASettings::getIndex(KXftConfig::SubPixel::Type spType) +int FontAASettings::getIndexSubPixel(KXftConfig::SubPixel::Type spType) const { int pos = -1; int index; - for (index = 0; index < subPixelType->count(); ++index) - if (subPixelType->itemText(index) == i18n(KXftConfig::description(spType).toUtf8())) { + for (index = 0; index < m_subPixelOptionsModel->rowCount(); ++index) { + QStandardItem *item = m_subPixelOptionsModel->item(index); + if (item->text() == i18n(KXftConfig::description(spType).toUtf8())) { pos = index; break; } + } return pos; } KXftConfig::SubPixel::Type FontAASettings::getSubPixelType() { int t; - for (t = KXftConfig::SubPixel::NotSet; t <= KXftConfig::SubPixel::Vbgr; ++t) - if (subPixelType->currentText() == i18n(KXftConfig::description((KXftConfig::SubPixel::Type)t).toUtf8())) { + for (t = KXftConfig::SubPixel::NotSet; t <= KXftConfig::SubPixel::Vbgr; ++t){ + if (m_subPixel == i18n(KXftConfig::description((KXftConfig::SubPixel::Type)t).toUtf8())) { return (KXftConfig::SubPixel::Type)t; } - + } return KXftConfig::SubPixel::NotSet; } -int FontAASettings::getIndex(KXftConfig::Hint::Style hStyle) +int FontAASettings::getIndexHint(KXftConfig::Hint::Style hStyle) const { int pos = -1; int index; - for (index = 0; index < hintingStyle->count(); ++index) - if (hintingStyle->itemText(index) == i18n(KXftConfig::description(hStyle).toUtf8())) { + for (index = 0; index < m_hintingOptionsModel->rowCount(); ++index) { + QStandardItem *item = m_hintingOptionsModel->item(index); + if (item->text() == i18n(KXftConfig::description(hStyle).toUtf8())) { pos = index; break; } + } return pos; } KXftConfig::Hint::Style FontAASettings::getHintStyle() { int s; - for (s = KXftConfig::Hint::NotSet; s <= KXftConfig::Hint::Full; ++s) - if (hintingStyle->currentText() == i18n(KXftConfig::description((KXftConfig::Hint::Style)s).toUtf8())) { + for (s = KXftConfig::Hint::NotSet; s <= KXftConfig::Hint::Full; ++s){ + if (m_hinting == i18n(KXftConfig::description((KXftConfig::Hint::Style)s).toUtf8())) { return (KXftConfig::Hint::Style)s; } + } return KXftConfig::Hint::Medium; } -void FontAASettings::enableWidgets() +#endif + +void FontAASettings::setSubPixel(const QString &subPixel) { - excludeFrom->setEnabled(excludeRange->isChecked()); - excludeTo->setEnabled(excludeRange->isChecked()); - excludeToLabel->setEnabled(excludeRange->isChecked()); -#ifdef FT_LCD_FILTER_H - static int ft_has_subpixel = -1; - if (ft_has_subpixel == -1) { - FT_Library ftLibrary; - if (FT_Init_FreeType(&ftLibrary) == 0) { - ft_has_subpixel = (FT_Library_SetLcdFilter(ftLibrary, FT_LCD_FILTER_DEFAULT) - == FT_Err_Unimplemented_Feature) ? 0 : 1; - FT_Done_FreeType(ftLibrary); - } + + if (m_subPixel == subPixel) { + return; } - subPixelType->setEnabled(ft_has_subpixel); -#endif + + m_subPixel = subPixel; + emit subPixelChanged(); } -#endif -void FontAASettings::changed() +QString FontAASettings::subPixel() const { -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - changesMade = true; - enableWidgets(); -#endif + return m_subPixel; } -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) -int FontAASettings::exec() +void FontAASettings::setHinting(const QString &hinting) { - const int i = QDialog::exec(); - - if (!i) { - load(); // Reset settings... + if (m_hinting == hinting) { + return; } - return i && changesMade; + m_hinting = hinting; + emit hintingChanged(); } -#endif -/**** KFonts ****/ - -KFonts::KFonts(QWidget *parent, const QVariantList &args) - : KCModule(parent, args) +QString FontAASettings::hinting() const { - QStringList nameGroupKeyRc; - - nameGroupKeyRc - << i18nc("font usage", "General") << "General" << "font" << "" - << i18nc("font usage", "Fixed width") << "General" << "fixed" << "" - << i18nc("font usage", "Small") << "General" << "smallestReadableFont" << "" - << i18nc("font usage", "Toolbar") << "General" << "toolBarFont" << "" - << i18nc("font usage", "Menu") << "General" << "menuFont" << "" - << i18nc("font usage", "Window title") << "WM" << "activeFont" << ""; + return m_hinting; +} - QList defaultFontList; +void FontAASettings::setExcludeTo(const int &excludeTo) +{ + if (m_excludeTo == excludeTo) { + return; + } - // NOTE: keep in sync with plasma-integration/src/platformtheme/kfontsettingsdata.cpp + m_excludeTo = excludeTo; + emit excludeToChanged(); +} -#ifdef Q_OS_MACOS - QFont f0("Lucida Grande", 13); // general/menu/desktop - QFont f1("Monaco", 10); - QFont f2("Lucida Grande", 11); // toolbar -#elif defined(Q_WS_MAEMO_5) || defined(MEEGO_EDITION_HARMATTAN) - QFont f0("Sans Serif", 16); // general/menu/desktop - QFont f1("Monospace", 16; - QFont f2("Sans Serif", 16); // toolbar -#else - QFont f0("Noto Sans", 10); // general/menu/desktop - QFont f1("Hack", 9); // fixed font - QFont f2("Noto Sans", 10); // toolbar -#endif -#ifdef Q_OS_MACOS - QFont f3("Lucida Grande", 14); // window title - QFont f5("Lucida Grande", 9); // smallestReadableFont -#else - QFont f3("Noto Sans", 10); // window title - QFont f5("Noto Sans", 8); // smallestReadableFont -#endif +int FontAASettings::excludeTo() const +{ + return m_excludeTo; +} - defaultFontList << f0 << f1 << f5 << f2 << f0 << f3; - - QList fixedList; - - fixedList - << false - << true - << false - << false - << false - << false; - - QStringList quickHelpList; - - quickHelpList - << i18n("Used for normal text (e.g. button labels, list items).") - << i18n("A non-proportional font (i.e. typewriter font).") - << i18n("Smallest font that is still readable well.") - << i18n("Used to display text beside toolbar icons.") - << i18n("Used by menu bars and popup menus.") - << i18n("Used by the window titlebar."); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - - QGridLayout *fontUseLayout = new QGridLayout(); - layout->addLayout(fontUseLayout); - fontUseLayout->setColumnStretch(0, 0); - fontUseLayout->setColumnStretch(1, 1); - fontUseLayout->setColumnStretch(2, 0); - - QList::ConstIterator defaultFontIt(defaultFontList.begin()); - QList::ConstIterator fixedListIt(fixedList.begin()); - QStringList::ConstIterator quickHelpIt(quickHelpList.begin()); - QStringList::ConstIterator it(nameGroupKeyRc.begin()); - - unsigned int count = 0; - - while (it != nameGroupKeyRc.constEnd()) { - QString name = *it; it++; - QString group = *it; it++; - QString key = *it; it++; - QString file = *it; it++; - - FontUseItem *i = - new FontUseItem( - this, - name, - group, - key, - file, - *defaultFontIt++, - *fixedListIt++ - ); - - fontUseList.append(i); - connect(i, &KFontRequester::fontSelected, this, &KFonts::fontSelected); - - QLabel *fontUse = new QLabel(i18nc("Font role", "%1: ", name), this); - fontUse->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - fontUse->setWhatsThis(*quickHelpIt++); - - fontUse->setBuddy(i); - - fontUseLayout->addWidget(fontUse, count, 0); - fontUseLayout->addWidget(i, count, 1); - - ++count; +void FontAASettings::setExcludeFrom(const int &excludeTo) +{ + if (m_excludeFrom == excludeTo) { + return; } - QHBoxLayout *hblay = new QHBoxLayout(); - layout->addLayout(hblay); - hblay->addStretch(); - QPushButton *fontAdjustButton = new QPushButton(i18n("Ad&just All Fonts..."), this); - fontAdjustButton->setWhatsThis(i18n("Click to change all fonts")); - hblay->addWidget(fontAdjustButton); - connect(fontAdjustButton, &QAbstractButton::clicked, this, &KFonts::slotApplyFontDiff); - - layout->addSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); + m_excludeFrom = excludeTo; + emit excludeToChanged(); +} - QGridLayout *lay = new QGridLayout(); - layout->addLayout(lay); - lay->setColumnStretch(3, 10); -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - QLabel *label = 0L; - label = new QLabel(i18n("Use a&nti-aliasing:"), this); - label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - lay->addWidget(label, 0, 0); - cbAA = new QComboBox(this); - cbAA->insertItem(AAEnabled, i18nc("Use anti-aliasing", "Enabled")); // change AASetting type if order changes - cbAA->insertItem(AASystem, i18nc("Use anti-aliasing", "System Settings")); - cbAA->insertItem(AADisabled, i18nc("Use anti-aliasing", "Disabled")); - cbAA->setWhatsThis(i18n("Select this option to smooth the edges of curves in fonts.")); - aaSettingsButton = new QPushButton(i18n("Configure..."), this); - connect(aaSettingsButton, &QAbstractButton::clicked, this, &KFonts::slotCfgAa); - label->setBuddy(cbAA); - lay->addWidget(cbAA, 0, 1); - lay->addWidget(aaSettingsButton, 0, 2); - // Initialize aaSettingsButton state based on the current cbAA->currentIndex value, will be eventually updated at load() - slotUseAntiAliasing(); - - connect(cbAA, SIGNAL(currentIndexChanged(int)), SLOT(slotUseAntiAliasing())); -#endif - checkboxForceDpi = new QCheckBox(i18n("Force fonts DPI:"), this); - lay->addWidget(checkboxForceDpi, 1, 0); - spinboxDpi = new QSpinBox(this); - spinboxDpi->setRange(1, 1000); - spinboxDpi->setSingleStep(24); // The common DPI values 72, 96 and 120 are multiples of 24 - QString whatsthis = i18n( - "

This option forces a specific DPI value for fonts. It may be useful" - " when the real DPI of the hardware is not detected properly and it" - " is also often misused when poor quality fonts are used that do not" - " look well with DPI values other than 96 or 120 DPI.

" - "

The use of this option is generally discouraged. For selecting proper DPI" - " value a better option is explicitly configuring it for the whole X server if" - " possible (e.g. DisplaySize in xorg.conf). When fonts do not render" - " properly with real DPI value better fonts should be used or configuration" - " of font hinting should be checked.

"); - spinboxDpi->setWhatsThis(whatsthis); -#if !defined(HAVE_X11) || !HAVE_X11 - QString nothere = i18n("This property has no effect on this platform"); - spinboxDpi->setToolTip(nothere); - checkboxForceDpi->setToolTip(nothere); -#endif - checkboxForceDpi->setChecked(false); - spinboxDpi->setEnabled(false); - connect(spinboxDpi, SIGNAL(valueChanged(int)), SLOT(changed())); - connect(checkboxForceDpi, SIGNAL(toggled(bool)), SLOT(changed())); - connect(checkboxForceDpi, &QAbstractButton::toggled, spinboxDpi, &QWidget::setEnabled); - lay->addWidget(spinboxDpi, 1, 1); - layout->addStretch(1); +int FontAASettings::excludeFrom() const +{ + return m_excludeFrom; +} -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - aaSettings = new FontAASettings(this); -#endif +void FontAASettings::setAntiAliasing(const int &antiAliasing) +{ + if (m_antiAliasing == antiAliasing) { + return; + } + m_antiAliasing = antiAliasing; + emit aliasingChanged(); } -KFonts::~KFonts() +int FontAASettings::antiAliasing() const { - QList::Iterator it(fontUseList.begin()), - end(fontUseList.end()); + return m_antiAliasing; +} - for (; it != end; ++it) { - delete(*it); +void FontAASettings::setDpi(const int &dpi) +{ + if (m_dpi == dpi) { + return; } - fontUseList.clear(); + + m_dpi = dpi; + emit dpiChanged(); } -void KFonts::fontSelected() +int FontAASettings::dpi() const { - emit changed(true); + return m_dpi; } -void KFonts::defaults() +int FontAASettings::subPixelCurrentIndex() { - for (int i = 0; i < (int) fontUseList.count(); i++) { - fontUseList.at(i)->setDefault(); - } + return getSubPixelType(); +} -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - useAA = AASystem; - cbAA->setCurrentIndex(useAA); - aaSettings->defaults(); -#endif - checkboxForceDpi->setChecked(false); - spinboxDpi->setValue(96); - emit changed(true); +int FontAASettings::hintingCurrentIndex() +{ + return getHintStyle(); } -void KFonts::load() + +/**** KFonts ****/ + +KFonts::KFonts(QObject *parent, const QVariantList &args) + : KQuickAddons::ConfigModule(parent, args) + , m_fontsModel(new QStandardItemModel(this)) + , m_fontAASettings(new FontAASettings(this)) { - QList::Iterator it(fontUseList.begin()), - end(fontUseList.end()); + qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); + KAboutData* about = new KAboutData("kcm_fonts", i18n("Configure Fonts"), + "0.1", QString(), KAboutLicense::LGPL); + about->addAuthor(i18n("Antonis Tsiapaliokas"), QString(), "antonis.tsiapaliokas@kde.org"); + setAboutData(about); + qmlRegisterType(); + setButtons(Apply | Default); + + QHash roles = m_fontsModel->roleNames(); + roles[CategoryRole] = "categoryName"; + roles[StatusRole] = "statusName"; + roles[FontRole] = "font"; + m_fontsModel->setItemRoleNames(roles); +} - for (; it != end; ++it) { - (*it)->readFont(); - } +KFonts::~KFonts() +{ +} -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - useAA_original = useAA = aaSettings->load() ? AAEnabled : AADisabled; - cbAA->setCurrentIndex(useAA); +void KFonts::defaults() +{ + QList defaultFonts; +#ifdef Q_OS_MAC + defaultFonts << QFont("Lucida Grande", 13) // general/menu/desktop + << QFont("Monaco", 10) + << QFont("Lucida Grande", 11); // toolbar +#elif defined(Q_WS_MAEMO_5) || defined(MEEGO_EDITION_HARMATTAN) + defaultFonts << QFont("Sans Serif", 16) // general/menu/desktop + << QFont("Monospace", 16) + << QFont("Sans Serif", 16); // toolbar +#else + defaultFonts << QFont("Oxygen-Sans", 10) // general/menu/desktop + <setChecked(false); - spinboxDpi->setValue(96); - dpi_original = 0; - } else { - checkboxForceDpi->setChecked(true); - spinboxDpi->setValue(dpicfg); - dpi_original = dpicfg; - }; -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - if (cfgfonts.readEntry("dontChangeAASettings", true)) { - useAA_original = useAA = AASystem; - cbAA->setCurrentIndex(useAA); + m_fontAASettings->defaults(); +} + +void KFonts::load() +{ + QList fonts; + fonts << FontsType { "General:", "General", "font" } + << FontsType { "Fixed width:", "General", "fixed" } + << FontsType { "Small:", "General", "smallestReadableFont" } + << FontsType { "Toolbar:", "General", "toolBarFont" } + << FontsType { "Menu:", "General", "menuFont" } + << FontsType { "Window Title:", "WM", "activeFont" }; + + KSharedConfig::Ptr config = KSharedConfig::openConfig("kdeglobals"); + for (auto it : fonts) { + + KConfigGroup cg(config, it.category); + QStandardItem *item = new QStandardItem(it.name); + item->setData(it.category, CategoryRole); + item->setData(it.status, StatusRole); + + QFont font; + font.fromString(cg.readEntry(it.status)); + item->setData(font, FontRole); + + m_fontsModel->appendRow(item); } -#endif - emit changed(false); + m_fontAASettings->load(); } void KFonts::save() { - QList::Iterator it(fontUseList.begin()), - end(fontUseList.end()); + KSharedConfig::Ptr config = KSharedConfig::openConfig("kdeglobals"); + for (int i = 0; i < m_fontsModel->rowCount(); i++) { + QStandardItem *item = m_fontsModel->item(i); - for (; it != end; ++it) { - (*it)->writeFont(); + KConfigGroup cg(config, item->data(CategoryRole).toString()); + cg.writeEntry(item->data(StatusRole).toString(), item->data(FontRole).toString()); + cg.sync(); } - KSharedConfig::openConfig()->sync(); - KConfig _cfgfonts("kcmfonts"); KConfigGroup cfgfonts(&_cfgfonts, "General"); - int dpi = (checkboxForceDpi->isChecked() ? spinboxDpi->value() : 0); - if (KWindowSystem::isPlatformWayland()) { - cfgfonts.writeEntry("forceFontDPIWayland", dpi); - } else { - cfgfonts.writeEntry("forceFontDPI", dpi); - } -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - cfgfonts.writeEntry("dontChangeAASettings", cbAA->currentIndex() == AASystem); -#endif - cfgfonts.sync(); -#if HAVE_X11 - // if the setting is reset in the module, remove the dpi value, - // otherwise don't explicitly remove it and leave any possible system-wide value - if (dpi == 0 && dpi_original != 0 && !KWindowSystem::isPlatformWayland()) { - QProcess proc; - proc.setProcessChannelMode(QProcess::ForwardedChannels); - proc.start("xrdb", QStringList() << "-quiet" << "-remove" << "-nocpp"); - if (proc.waitForStarted()) { - proc.write(QByteArray("Xft.dpi\n")); - proc.closeWriteChannel(); - proc.waitForFinished(); - } - } -#endif - - KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged); - QApplication::processEvents(); // Process font change ourselves - - // Don't overwrite global settings unless explicitly asked for - e.g. the system - // fontconfig setup may be much more complex than this module can provide. - // TODO: With AASystem the changes already made by this module should be reverted somehow. -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - bool aaSave = false; - if (cbAA->currentIndex() == AAEnabled ) { - aaSave = aaSettings->save(KXftConfig::AntiAliasing::Enabled); - } else if (cbAA->currentIndex() == AADisabled) { - aaSave = aaSettings->save(KXftConfig::AntiAliasing::Disabled); + AASetting aaSetting = (AASetting)m_fontAASettings->antiAliasing(); + cfgfonts.writeEntry("dontChangeAASettings", aaSetting == AASystem); + if (aaSetting == AAEnabled) { + m_fontAASettings->save(KXftConfig::AntiAliasing::Enabled); + } else if (aaSetting == AADisabled) { + m_fontAASettings->save(KXftConfig::AntiAliasing::Disabled); } else { - // If AASystem is selected, this removes all fontconfig settings made by - // this module. - aaSettings->defaults(); - aaSave = aaSettings->save(KXftConfig::AntiAliasing::NotSet); + m_fontAASettings->save(KXftConfig::AntiAliasing::NotSet); } - if (aaSave || (useAA != useAA_original) || dpi != dpi_original) { - KMessageBox::information(this, - i18n( - "

Some changes such as anti-aliasing or DPI will only affect newly started applications.

" - ), i18n("Font Settings Changed"), "FontSettingsChanged"); - useAA_original = useAA; - dpi_original = dpi; - } -#else -#if HAVE_X11 - if (dpi != dpi_original) { - KMessageBox::information(this, - i18n( - "

Some changes such as DPI will only affect newly started applications.

" - ), i18n("Font Settings Changed"), "FontSettingsChanged"); - dpi_original = dpi; - } -#endif -#endif runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); - - emit changed(false); + KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged); + emit fontsHaveChanged(); + setNeedsSave(false); } -void KFonts::slotApplyFontDiff() +void KFonts::updateFont(int currentIndex, QFont font) { - QFont font = QFont(fontUseList.first()->font()); - KFontChooser::FontDiffFlags fontDiffFlags = 0; - int ret = KFontDialog::getFontDiff(font, fontDiffFlags, KFontChooser::NoDisplayFlags, this); + QStandardItem *item = m_fontsModel->item(currentIndex); + item->setData(font, FontRole); - if (ret == KDialog::Accepted && fontDiffFlags) { - for (int i = 0; i < (int) fontUseList.count(); i++) { - fontUseList.at(i)->applyFontDiff(font, fontDiffFlags); - } - emit changed(true); - } + setNeedsSave(true); } -void KFonts::slotUseAntiAliasing() -{ -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - useAA = static_cast< AASetting >(cbAA->currentIndex()); - aaSettingsButton->setEnabled(useAA == AAEnabled); - emit changed(true); -#endif -} -void KFonts::slotCfgAa() +void KFonts::adjustAllFonts(QFont font) { -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - if (aaSettings->exec()) { - emit changed(true); + for (int i = 0; i < m_fontsModel->rowCount(); i++) { + updateFont(i, font); } -#endif } #include "fonts.moc" diff --git a/kcms/fonts/fonts.h b/kcms/fonts/fonts.h index 2bff41291..ac83a3293 100644 --- a/kcms/fonts/fonts.h +++ b/kcms/fonts/fonts.h @@ -1,152 +1,160 @@ /* Copyright 1997 Mark Donohoe Copyright 1999 Lars Knoll Copyright 2000 Rik Hemsley Ported to kcontrol2 by Geert Jansen. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FONTS_H #define FONTS_H -#include -#include -#include #include +#include +#include -#include -#include +#include #include "kxftconfig.h" -class QCheckBox; -class QComboBox; -class QDoubleSpinBox; -class QSpinBox; -class FontAASettings; - -class FontUseItem : public KFontRequester +class FontAASettings : public QObject { Q_OBJECT -public: - FontUseItem(QWidget *parent, const QString &name, const QString &grp, - const QString &key, const QString &rc, const QFont &default_fnt, - bool fixed = false); - - void readFont(); - void writeFont(); - void setDefault(); - void applyFontDiff(const QFont &fnt, int fontDiffFlags); - - const QString &rcFile() - { - return _rcfile; - } - const QString &rcGroup() - { - return _rcgroup; - } - const QString &rcKey() - { - return _rckey; - } - -private: - QString _rcfile; - QString _rcgroup; - QString _rckey; - QFont _default; -}; - -class FontAASettings : public QDialog -{ - Q_OBJECT + Q_PROPERTY(QAbstractItemModel *subPixelOptionsModel READ subPixelOptionsModel CONSTANT) + Q_PROPERTY(QAbstractItemModel *hintingOptionsModel READ hintingOptionsModel CONSTANT) + Q_PROPERTY(QString subPixel READ subPixel WRITE setSubPixel NOTIFY subPixelChanged) + Q_PROPERTY(QString hinting READ hinting WRITE setHinting NOTIFY hintingChanged) + Q_PROPERTY(int excludeTo READ excludeTo WRITE setExcludeTo NOTIFY excludeToChanged) + Q_PROPERTY(int excludeFrom READ excludeFrom WRITE setExcludeFrom NOTIFY excludeFromChanged) + Q_PROPERTY(int antiAliasing READ antiAliasing WRITE setAntiAliasing NOTIFY aliasingChanged) + Q_PROPERTY(int dpi READ dpi WRITE setDpi NOTIFY dpiChanged) public: #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) - FontAASettings(QWidget *parent); + FontAASettings(QObject *parent); bool save(KXftConfig::AntiAliasing::State aaState); - bool load(); + void load(); void defaults(); - int getIndex(KXftConfig::SubPixel::Type spType); + int getIndexSubPixel(KXftConfig::SubPixel::Type spType) const; KXftConfig::SubPixel::Type getSubPixelType(); - int getIndex(KXftConfig::Hint::Style hStyle); + int getIndexHint(KXftConfig::Hint::Style hStyle) const; KXftConfig::Hint::Style getHintStyle(); void setAntiAliasingState(KXftConfig::AntiAliasing::State aaState); - void enableWidgets(); - int exec() Q_DECL_OVERRIDE; -#endif + QAbstractItemModel* subPixelOptionsModel() { return m_subPixelOptionsModel; } + QAbstractItemModel* hintingOptionsModel() { return m_hintingOptionsModel; } + + void setSubPixel(const QString &subPixel); + QString subPixel() const; + + void setHinting(const QString &hinting); + QString hinting() const; + + void setExcludeTo(const int &excludeTo); + int excludeTo() const; -protected Q_SLOTS: + void setExcludeFrom(const int &excludeTo); + int excludeFrom() const; - void changed(); + void setAntiAliasing(const int& antiAliasing); + int antiAliasing() const; + + void setDpi(const int &dpi); + int dpi() const; + + Q_INVOKABLE int subPixelCurrentIndex(); + Q_INVOKABLE int hintingCurrentIndex(); + +#endif + +Q_SIGNALS: + void subPixelChanged(); + void hintingChanged(); + void excludeToChanged(); + void excludeFromChanged(); + void antiAliasingChanged(); + void aliasingChanged(); + void dpiChanged(); #if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) private: - - QCheckBox *excludeRange; - QDoubleSpinBox *excludeFrom; - QDoubleSpinBox *excludeTo; - QComboBox *subPixelType; - QComboBox *hintingStyle; - QLabel *subPixelLabel; - QLabel *excludeToLabel; - bool changesMade; + QString m_subPixel; + QString m_hinting; + int m_excludeTo; + int m_excludeFrom; + int m_antiAliasing; + int m_dpi; + QStandardItemModel *m_subPixelOptionsModel; + QStandardItemModel *m_hintingOptionsModel; #endif }; /** * The Desktop/fonts tab in kcontrol. */ -class KFonts : public KCModule + + +struct FontsType { + QString name; + QString category; + QString status; + QFont font; + QString fontName; +}; + +class KFonts : public KQuickAddons::ConfigModule { Q_OBJECT + Q_PROPERTY(QAbstractItemModel *fontsModel READ fontsModel CONSTANT) + Q_PROPERTY(QObject *fontAASettings READ fontAASettings CONSTANT) public: - KFonts(QWidget *parent, const QVariantList &); + + enum Roles { + CategoryRole = Qt::UserRole + 1, + StatusRole, + FontRole + }; + + KFonts(QObject *parent, const QVariantList &); ~KFonts(); - void load() Q_DECL_OVERRIDE; - void save() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE; -protected Q_SLOTS: - void fontSelected(); - void slotApplyFontDiff(); - void slotUseAntiAliasing(); - void slotCfgAa(); + QStandardItemModel* fontsModel() { return m_fontsModel; } + QObject* fontAASettings() { return m_fontAASettings; } + +public Q_SLOTS: + void load(); + void save(); + void defaults(); + Q_INVOKABLE void updateFont(int currentIndex, QFont font); + Q_INVOKABLE void adjustAllFonts(QFont); + +Q_SIGNALS: + void fontsHaveChanged(); private: -#if defined(HAVE_FONTCONFIG) && defined (HAVE_X11) enum AASetting { AAEnabled, AASystem, AADisabled }; - AASetting useAA, useAA_original; - QComboBox *cbAA; - QPushButton *aaSettingsButton; - FontAASettings *aaSettings; -#endif - int dpi_original; - QCheckBox *checkboxForceDpi; - QSpinBox *spinboxDpi; - QList fontUseList; + QStandardItemModel *m_fontsModel; + FontAASettings *m_fontAASettings; }; #endif diff --git a/kcms/fonts/fonts.desktop b/kcms/fonts/kcm_fonts.desktop similarity index 93% rename from kcms/fonts/fonts.desktop rename to kcms/fonts/kcm_fonts.desktop index f9a0d56f6..5b486eddf 100644 --- a/kcms/fonts/fonts.desktop +++ b/kcms/fonts/kcm_fonts.desktop @@ -1,199 +1,190 @@ [Desktop Entry] Exec=kcmshell5 fonts Icon=preferences-desktop-font Type=Service X-KDE-ServiceTypes=KCModule X-DocPath=kcontrol/fonts/index.html X-KDE-Library=kcm_fonts X-KDE-ParentApp=kcontrol X-KDE-System-Settings-Parent-Category=font X-KDE-Weight=50 Name=Fonts Name[af]=Skriftipes Name[ar]=الخطوط Name[be]=Шрыфты Name[be@latin]=Šryfty Name[bg]=Шрифтове Name[bn]=ফন্ট Name[bn_IN]=ফন্ট Name[br]=Fontoù Name[bs]=Fontovi Name[ca]=Tipus de lletra Name[ca@valencia]=Tipus de lletra Name[cs]=Písma Name[csb]=Fòntë Name[cy]=Ffontiau Name[da]=Skrifttyper Name[de]=Schriftarten Name[el]=Γραμματοσειρές Name[en_GB]=Fonts Name[eo]=Tiparoj Name[es]=Tipos de letra Name[et]=Fondid Name[eu]=Letra-tipoak Name[fa]=قلمها Name[fi]=Fontit Name[fr]=Polices de caractères Name[fy]=Lettertypen Name[ga]=Clónna Name[gl]=Tipos de letra Name[gu]=ફોન્ટ્સ Name[he]=גופנים Name[hi]=फ़ॉन्ट्स Name[hne]=फोंट Name[hr]=Fontovi Name[hsb]=Pisma Name[hu]=Betűtípusok Name[ia]=Fontes Name[id]=Fonta Name[is]=Letur Name[it]=Caratteri Name[ja]=フォント Name[ka]=ფონტები Name[kk]=Қаріптер Name[km]=ពុម្ព​អក្សរ Name[kn]=ಅಕ್ಷರಶೈಲಿಗಳು Name[ko]=글꼴 Name[ku]=Curenivîs Name[lt]=Šriftai Name[lv]=Fonti Name[mai]=फान्ट Name[mk]=Фонтови Name[ml]=അക്ഷരസഞ്ചയങ്ങള്‍ Name[mr]=फॉन्ट Name[ms]=Fon Name[nb]=Skrifttyper Name[nds]=Schriftoorden Name[ne]=फन्ट Name[nl]=Lettertypen Name[nn]=Skrifter Name[oc]=Poliças Name[or]=ଅକ୍ଷର ରୂପ Name[pa]=ਫੋਂਟ Name[pl]=Czcionki Name[pt]=Tipos de Letra Name[pt_BR]=Fontes Name[ro]=Fonturi Name[ru]=Шрифты Name[se]=Fonttat Name[si]=අකුරු Name[sk]=Písma Name[sl]=Pisave Name[sr]=Фонтови Name[sr@ijekavian]=Фонтови Name[sr@ijekavianlatin]=Fontovi Name[sr@latin]=Fontovi Name[sv]=Teckensnitt Name[ta]=எழுத்துருக்கள் Name[te]=ఫాంట్‍స్ Name[tg]=Ҳарфҳо Name[th]=แบบอักษรต่างๆ Name[tr]=Yazı Tipleri Name[ug]=خەت نۇسخىلىرى Name[uk]=Шрифти Name[uz]=Shriftlar Name[uz@cyrillic]=Шрифтлар Name[vi]=Phông chữ Name[wa]=Fontes Name[xh]=Uhlobo lwamagama Name[x-test]=xxFontsxx Name[zh_CN]=字体 Name[zh_TW]=字型 Comment=Fonts Comment[ar]=الخطوط Comment[bs]=Fontovi Comment[ca]=Tipus de lletra -Comment[ca@valencia]=Tipus de lletra Comment[cs]=Písma Comment[da]=Skrifttyper Comment[de]=Schriftarten Comment[el]=Γραμματοσειρές Comment[en_GB]=Fonts -Comment[eo]=Tiparoj Comment[es]=Tipos de letra -Comment[et]=Fondid -Comment[eu]=Letra-tipoak Comment[fi]=Fontit Comment[fr]=Polices de caractères Comment[gl]=Tipos de letra -Comment[he]=גופנים Comment[hu]=Betűtípusok Comment[id]=Fonta -Comment[is]=Letur Comment[it]=Caratteri -Comment[ja]=フォント Comment[ko]=글꼴 Comment[lt]=Šriftai Comment[mr]=फॉन्ट Comment[nb]=Skrifttype Comment[nds]=Schriftoorden Comment[nl]=Lettertypen -Comment[nn]=Skrifter Comment[pa]=ਫੋਂਟ Comment[pl]=Czcionki Comment[pt]=Tipos de Letra Comment[pt_BR]=Fontes Comment[ru]=Шрифты Comment[sk]=Písma Comment[sl]=Pisave Comment[sr]=Фонтови Comment[sr@ijekavian]=Фонтови Comment[sr@ijekavianlatin]=Fontovi Comment[sr@latin]=Fontovi Comment[sv]=Teckensnitt Comment[tr]=Yazı Tipleri Comment[uk]=Шрифти Comment[x-test]=xxFontsxx Comment[zh_CN]=字体 Comment[zh_TW]=字型 X-KDE-Keywords=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[ar]=خطوط,حجم الخط,أنماط,طقم محارف,طقوم محارف,لوحة,لوحة تحكّم,أسطح المكتب,مدير ملفات,أشرطة أدوات,قائمة,عنوان نافذة,عنوان,نقطة/بوصة,DPI,إزالة التسنّن,خطوط سطح المكتب,خطوط شريط الأدوات,محرف,خطوط عامة X-KDE-Keywords[bs]=slova,veličina slova,stil,znakovi,postaviti znakove,ploča,kontrolna ploča,pozadina,upravitelj datoteka,alatne trake,meni,naslov prozora,naslov,DPI,niskopropusni,slova pozadine,slova na alatnoj traci,obilježja,opći fontovi -X-KDE-Keywords[ca]=tipus de lletres,mida de tipus de lletra,estils,joc de caràcters,jocs de caràcters,plafó,plafó de control,escriptoris,Gestor de fitxers,Barres d'eines,Menú,Títol de la finestra,Títol,DPI,antialiàsing,tipus de lletra d'escriptori,tipus de lletra de barra d'eines,caràcter,tipus de lletra general -X-KDE-Keywords[ca@valencia]=tipus de lletres,mida de tipus de lletra,estils,joc de caràcters,jocs de caràcters,plafó,plafó de control,escriptoris,Gestor de fitxers,Barres d'eines,Menú,Títol de la finestra,Títol,DPI,antialiàsing,tipus de lletra d'escriptori,tipus de lletra de barra d'eines,caràcter,tipus de lletra general +X-KDE-Keywords[ca]=tipus de lletres,mida de tipus de lletra,estils,joc de caràcters,jocs de caràcters,plafó,plafó de control,escriptoris,Gestor de fitxers,Barres d'eines,Menú,Títol de finestra,Títol,DPI,antialiàsing,tipus de lletra d'escriptori,tipus de lletra de barra d'eines,caràcter,tipus de lletra general +X-KDE-Keywords[ca@valencia]=tipus de lletres,mida de tipus de lletra,estils,joc de caràcters,jocs de caràcters,plafó,plafó de control,escriptoris,Gestor de fitxers,Barres d'eines,Menú,Títol de finestra,Títol,DPI,antialiàsing,tipus de lletra d'escriptori,tipus de lletra de barra d'eines,caràcter,tipus de lletra general X-KDE-Keywords[da]=skrifttyper,skriftstørrelse,stile,tegnsæt,panel,kontrolpanel,skriveborde,filhåndtering,værktøjslinjer,menu,vinduestitel,titel,DPI,anti-aliasing,værktøjslinjer,tegn X-KDE-Keywords[de]=Schriftarten,Schriftgrößen,Stile,Zeichensätze,Kontrollleiste,Stile,Dateiverwaltung,Arbeitsflächen,Werkzeugleisten,Menüs,Fenstertitel,Titel,DPI,Antialiasing,Arbeitsflächenschriften,Werkzeugleistenschriften,Zeichen,Allgemeine Schriftarten X-KDE-Keywords[el]=γραμματοσειρές,μέγεθος γραμματοσειράς,στιλ,σύνολα χαρακτήρων,πίνακας,πίνακας ελέγχου,επιφάνειες εργασίας,διαχειριστής αρχείων,γραμμές εργαλείων,μενού,τίτλος παραθύρου,τίτλος,DPI,εξομάλυνση,γραμματοσειρές επιφάνειας εργασίας,γραμματοσειρές γραμμής εργαλείων,χαρακτήρας,γενικές γραμματοσειρές X-KDE-Keywords[en_GB]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[es]=tipos de letra,tamaño del tipo de letra,estilos,juegos de caracteres,panel,panel de control panel,escritorios,Gestor de archivos,Barras de herramientas,Menú,Título de la ventana,Título,DPI,suavizado de texto,tipos de letra del escritorio,tipos de letra de las barras de herramientas,carácter,tipos de letra generales X-KDE-Keywords[et]=fondid,fondi suurus,kodeering,kooditabel,paneel,juhtpaneel,töölauad,failihaldur,tööriistaribad,menüü,aken,tiitel,nimetus,nimi,DPI,antialias,töölaua fondid,tööriistariba fondid,märk,märgid,sümbolid,üldised fondid X-KDE-Keywords[eu]=letra-tipoak,letra-tamaina,estiloak,karaktere-jokoak,panela,kontrol-panela,mahaigain,fitxategi-kudeatzaile,tresna-barra,menu,leihoaren titulu,titulu,DPI,antialiasing,mahaigaineko letra-tripo,tresna-barrako letra-tipo,karaktere,letra-tipo orokor X-KDE-Keywords[fi]=kirjasimet,fontit,kirjasinkoko,fonttikoko,tyylit,merkistöt,paneeli,ohjauskeskus,työpöydät,Tiedostonhallinta,Työkalurivit,Työkalupalkit,Valikko,Ikkunan otsikko,Otsikko,DPI,antialiasointi,työpöytäkirjasimet,työpöytäfontit,työkalurivikirjasimet, työkalurivien kirjasimet, työkalurivifontit, työkalurivien fontit,merkki,yleiskirjasimet,yleiset kirjasimet,yleisfontit,yleiset fontit X-KDE-Keywords[fr]=polices, taille de police, styles, tables de caractères, jeux de caractères, tableau de bord, bureaux, Gestionnaire de Fichiers, Barre d'outils, Menu, Titre de fenêtre, Titre, DPI, anti crénelage, polices du bureau, police de barre d'outils, caractère, polices générales X-KDE-Keywords[ga]=clónna,clófhoirne,clómhéid,stíleanna,tacair charachtar,painéal,painéal rialaithe,deasca,Bainisteoir Comhad,Barraí Uirlisí,Roghchlár,Teideal Fuinneoige,Teideal,PSO,frithailiasáil,clónna deisce,clófhoirne deisce,clónna barra uirlisí,carachtar,clónna ginearálta,clófhoirne ginearálta -X-KDE-Keywords[gl]=tipo de letra,letra,tamaño de letra,tamaño da letra,codificacións de caracteres,conxuntos de caracteres,panel,control,panel de control,escritorios,xestor de ficheiros,barras de ferramentas,menú,título de xanela,título,DPI,PPP,antialiasing,suavizado,tipos de letra do escritorio,tipos de letra das barras de ferramentas,carácter,tipos de letra xerais +X-KDE-Keywords[gl]=tipo de letra, letra, tamaño da letra, carácter, caracteres, conxunto de caracteres, glifo, panel, control, panel de control, antialiasing, suavizado X-KDE-Keywords[hu]=betűkészletek,betűméret,stílusok,karakterkészletek,karakterkészletek,panel,beállítópanel,asztalok,Fájlkezelő,Eszköztárak,Menü,Ablakcím,Cím,DPI,élsimítás,asztal betűkészletek,eszköztár betűkészletek,karakter,általános betűkészletek X-KDE-Keywords[ia]=fonts,grandor de font,stilos,insimules de characteres,insimules de characteres,pannello,pannello de controlo,scriptorios,Gerente de File,Barra de instrumentos,menu,Titulo de Fenestra,Titulo,DPI,anti-aliasing,fonts de scriptorio, fonts de barra de titulo, character,fonts general X-KDE-Keywords[id]=fonta,ukuran fonta,gaya,charset,set karakter,panel,panel kontrol,desktop,ManajerBerkas,Batang Alat,Menu,Judul Jendela,Judul,DPI,anti-alias,fonta desktop,fonta batang alat,karakter,fonta umum X-KDE-Keywords[it]=caratteri,dimensione dei caratteri,stili,codifiche,insiemi di caratteri,pannello,pannello di controllo,desktop,gestore dei file,barre degli strumenti,menu,titolo della finestra,titolo,DPI,anti-aliasing,caratteri del desktop,caratteri della barra degli strumenti,carattere,caratteri generali X-KDE-Keywords[kk]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[km]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts X-KDE-Keywords[ko]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,글꼴,스타일,창 제목,글자 X-KDE-Keywords[mr]=फॉन्ट्स, फॉन्ट साईज, कॅरेक्टर, कॅरेक्टर सेटस, पँनल, कन्ट्रोल पँनल, डेस्कटॉप्स, फाईल मेनेजर, टूलबार्स, मेन्यू, चौकट टाईटल, टाईटल, डी पी आय , अन्टी अलायझिंग, डेस्कटॉप फॉन्टस, टूलबार फॉन्टस, कॅरेक्टर, जनरल फॉन्ट्स X-KDE-Keywords[nb]=skrifter,skriftstørrelse,stiler,tegnsett,panel,kontrollpanel,skrivebord,filbehandler,Verktøylinje,Meny,Vindiustittel,tittel,DPI,kantutjevning,skrivebordsskrifter,verktøylinjeskrifter,generelle skrifter X-KDE-Keywords[nds]=Schriftoorden,Schrift,Stilen,Tekensetten,Paneel,Stüerpaneel,Schriefdisch,Dateipleger,Warktüüchbalkens,Menü,Finstertitel,Titel,DPI,Kantstreken,anti-aliasing,Schriefdisch,Teken X-KDE-Keywords[nl]=lettertypes,lettertype,tekengrootte,stijlen,tekensets,paneel,besturingspaneel,bureaubladen,bestandsbeheerder,werkbalken,menu,venstertitel,titel,DPI,anti-aliasing,lettertypen van bureaublad,lettertypen van werkbalk,teken,algemene lettertypes -X-KDE-Keywords[nn]=skrifter,skriftstorleik,stilar,teiknsett,teiknkodingar,panel,kontrollpanel,skrivebord,filhandsamar,verktøylinje,meny,vindaugstittel,tittel,DPI,PPT,kantutjamning,skrivebordsskrifter,verktøylinjeskrifter,generelle skriftar X-KDE-Keywords[pl]=czcionki,rozmiar czcionki,style,zestaw znaków,panel,panel sterowania,pulpity,Menadżer plików,Paski narzędzi,Menu,Tytuł okna,Tytuł,DPI,wygładzanie,czcionki pulpitu,czcionki pasków narzędzi,znak,czcionki ogólne X-KDE-Keywords[pt]=tipos de letra,tamanho de letra,estilos,codificações,codificações de caracteres,painel,painel de controlo,ecrãs,gestor de ficheiros,barras de ferramentas,menu,título da janela,título,PPP,suavização,tipos de letra do ecrã,tipos de letra da barra de ferramentas,carácter,tipos de letra gerais X-KDE-Keywords[pt_BR]=fontes,tamanho da fonte,estilos,codificações,codificações de caracteres,painel,painel de controle,áreas de trabalho,gerenciador de arquivos,barras de ferramentas,Menu,Título da janela,Título,PPP,anti-aliasing,fontes da área de trabalho,fontes da barra de ferramentas,caractere,fontes gerais X-KDE-Keywords[ru]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,шрифты,размер шрифтов,стили,кодировки,панель,панель управления,рабочие столы,диспетчер файлов,панель инструментов,меню,заголовок окна,заголовок,сглаживание,шрифты рабочего стола,шрифты панели инструментов,символы,общие шрифты X-KDE-Keywords[sk]=písmo,veľkosť písma,štýly,znakové sady,sady znakov,panel,ovládací panel,plochy,Správca súborov,Panely nástrojov,Ponuka,Titulok okna,Titulok,DPI,anti-aliasing,písma plochy,písma nástrojových panelov,znak,všeobecné písma X-KDE-Keywords[sl]=pisave,velikost pisav,slogi,nabori znakov,znakovni nabori,pult,nadzorna plošča,namizja,upravljalnik datotek,datotečni upravljalnik,orodjarne,orodne vrstice,meni,naslov okna,naslovna vrstica,naslov,ločljivost,točk na palec,glajenje robov,namizne pisave,pisave namizja,pisave orodjarne, pisave orodne vrstice,znak,splošne pisave X-KDE-Keywords[sr]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,фонт,величина фонта,стил,кодирање,панел,контролни панел,површ,менаџер фајлова,траке алатки,мени,наслов прозора,тпи,омекшавање,фонт површи,фонт траке алатки,знакови,општи фонт X-KDE-Keywords[sr@ijekavian]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,фонт,величина фонта,стил,кодирање,панел,контролни панел,површ,менаџер фајлова,траке алатки,мени,наслов прозора,тпи,омекшавање,фонт површи,фонт траке алатки,знакови,општи фонт X-KDE-Keywords[sr@ijekavianlatin]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,font,veličina fonta,stil,kodiranje,panel,kontrolni panel,površ,menadžer fajlova,trake alatki,meni,naslov prozora,tpi,omekšavanje,font površi,font trake alatki,znakovi,opšti font X-KDE-Keywords[sr@latin]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,font,veličina fonta,stil,kodiranje,panel,kontrolni panel,površ,menadžer fajlova,trake alatki,meni,naslov prozora,tpi,omekšavanje,font površi,font trake alatki,znakovi,opšti font X-KDE-Keywords[sv]=teckensnitt,teckenstorlek,stil,teckenuppsättningar,panel,kontrollpanel,skrivbord,Filhanterare,Verktygsrader,Meny,Fönsternamn,Namn,Punkter/tum,kantutjämning,skrivbordsteckensnitt,verktygsradsteckensnitt,tecken,allmänna teckensnitt -X-KDE-Keywords[tr]=yazı tipi,yazı tipi boyutu,karakterler,karakter setleri,panel,denetim paneli,masaüstleri,Dosya Yöneticisi,Araç Çubukları,Menü,Pencere Başlığı,Başlık,DPI,yumuşatma,anti-aliasing,masaüstü yazı tipleri,araç çubuğu yazı tipleri,karakter,genel yazı tipleri,biçemler +X-KDE-Keywords[tr]=yazı tipi,yazı tipi boyutu,karakterler,karakter setleri,panel,denetim paneli,masaüstleri,Dosya Yöneticisi,Araç Çubukları,Menü,Pencere Başlığı,Başlık,DPI,yumuşatma,anti-aliasing,masaüstü yazı tipleri,araç çubuğu yazı tipleri,karakter,genel yazı tipleri X-KDE-Keywords[uk]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,шрифт,шрифти,розмір,розмір шрифту,стиль,стилі,гарнітура,гарнітури,кодування,набір,символ,символи,набір символів,панель,панель керування,стільниця,стільниці,файл,керування,керування файлами,менеджер,панель інструментів,меню,заголовок,заголовок вікна,роздільність,згладжування,шрифти стільниці,шрифти панелі,символ,загальні шрифти X-KDE-Keywords[x-test]=xxfontsxx,xxfont sizexx,xxstylesxx,xxcharsetsxx,xxcharacter setsxx,xxpanelxx,xxcontrol panelxx,xxdesktopsxx,xxFileManagerxx,xxToolbarsxx,xxMenuxx,xxWindow Titlexx,xxTitlexx,xxDPIxx,xxanti-aliasingxx,xxdesktop fontsxx,xxtoolbar fontsxx,xxcharacterxx,xxgeneral fontsxx X-KDE-Keywords[zh_CN]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts,字体字体大小,样式,字符集,面板,控制面板,桌面,文件管理器,工具栏,菜单,窗口标题,标题,反锯齿,桌面字体,工具栏字体,字符,常规字体 X-KDE-Keywords[zh_TW]=fonts,font size,styles,charsets,character sets,panel,control panel,desktops,FileManager,Toolbars,Menu,Window Title,Title,DPI,anti-aliasing,desktop fonts,toolbar fonts,character,general fonts Categories=Qt;KDE;X-KDE-settings-looknfeel; diff --git a/kcms/fonts/kxftconfig.h b/kcms/fonts/kxftconfig.h index f83c27482..8e79595c0 100644 --- a/kcms/fonts/kxftconfig.h +++ b/kcms/fonts/kxftconfig.h @@ -1,195 +1,195 @@ #ifndef __KXFTCONFIG_H__ #define __KXFTCONFIG_H__ /* Copyright (c) 2002 Craig Drummond This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #ifdef HAVE_FONTCONFIG #include #include class KXftConfig { public: struct Item { Item(QDomNode &n) : node(n), toBeRemoved(false) {} Item() : toBeRemoved(false) {} virtual void reset() { node.clear(); toBeRemoved = false; } bool added() { return node.isNull(); } QDomNode node; virtual ~Item() {} bool toBeRemoved; }; struct SubPixel : public Item { enum Type { NotSet, None, Rgb, Bgr, Vrgb, Vbgr }; SubPixel(Type t, QDomNode &n) : Item(n), type(t) {} SubPixel(Type t = NotSet) : type(t) {} - void reset() Q_DECL_OVERRIDE + void reset() { Item::reset(); type = NotSet; } Type type; }; struct Exclude : public Item { Exclude(double f, double t, QDomNode &n) : Item(n), from(f), to(t) {} Exclude(double f = 0, double t = 0) : from(f), to(t) {} - void reset() Q_DECL_OVERRIDE + void reset() { Item::reset(); from = to = 0; } double from, to; }; struct Hint : public Item { enum Style { NotSet, None, Slight, Medium, Full }; Hint(Style s, QDomNode &n) : Item(n), style(s) {} Hint(Style s = NotSet) : style(s) {} - void reset() Q_DECL_OVERRIDE + void reset() { Item::reset(); style = NotSet; } Style style; }; struct Hinting : public Item { Hinting(bool s, QDomNode &n) : Item(n), set(s) {} Hinting(bool s = true) : set(s) {} - void reset() Q_DECL_OVERRIDE + void reset() { Item::reset(); set = true; } bool set; }; struct AntiAliasing : public Item { enum State { NotSet, Enabled, Disabled }; AntiAliasing(State s, QDomNode &n) : Item(n), state(s) {} AntiAliasing(State s = NotSet) : state(s) {} - void reset() Q_DECL_OVERRIDE + void reset() { Item::reset(); state = NotSet; } enum State state; }; public: explicit KXftConfig(); virtual ~KXftConfig(); bool reset(); bool apply(); bool getSubPixelType(SubPixel::Type &type); void setSubPixelType(SubPixel::Type type); // SubPixel::None => turn off sub-pixel rendering bool getExcludeRange(double &from, double &to); void setExcludeRange(double from, double to); // from:0, to:0 => turn off exclude range bool getHintStyle(Hint::Style &style); void setHintStyle(Hint::Style style); void setAntiAliasing(AntiAliasing::State state); AntiAliasing::State getAntiAliasing() const; bool changed() { return m_madeChanges; } static QString description(SubPixel::Type t); static const char *toStr(SubPixel::Type t); static QString description(Hint::Style s); static const char *toStr(Hint::Style s); bool aliasingEnabled(); private: void readContents(); void applySubPixelType(); void applyHintStyle(); void applyAntiAliasing(); void setHinting(bool set); void applyHinting(); void applyExcludeRange(bool pixel); private: SubPixel m_subPixel; Exclude m_excludeRange, m_excludePixelRange; Hint m_hint; Hinting m_hinting; AntiAliasing m_antiAliasing; QDomDocument m_doc; QString m_file; bool m_madeChanges; time_t m_time; }; #endif #endif diff --git a/kcms/fonts/package/contents/ui/main.qml b/kcms/fonts/package/contents/ui/main.qml new file mode 100644 index 000000000..a63bbed6f --- /dev/null +++ b/kcms/fonts/package/contents/ui/main.qml @@ -0,0 +1,307 @@ +/* + Copyright (c) 2015 Antonis Tsiapaliokas + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.0 as QtControls +import QtQuick.Dialogs 1.2 as QtDialogs +import org.kde.kquickcontrolsaddons 2.0 +import QtQuick.Controls.Private 1.0 +//We need units from it +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.kcm 1.0 + +ColumnLayout { + id: root + implicitWidth: units.gridUnit * 50 + implicitHeight: units.gridUnit * 50 + + ConfigModule.quickHelp: i18n("Fonts") + + SystemPalette {id: syspal} + + QtControls.ScrollView { + id: scrollView + Layout.fillWidth: true + Layout.preferredHeight: view.contentItem.childrenRect.height + anchors.top: parent.top + + ListView { + id: view + model: kcm.fontsModel + anchors.fill: parent + spacing: 10 + + delegate: RowLayout { + id: row + width: parent.width + + QtControls.Label { + id: fontCategory + text: model.display + Layout.minimumWidth: units.gridUnit * 5 + horizontalAlignment: Text.AlignRight + } + + //FIXME + //QtControls.TextField is buggy with some fonts and it loses + //its border. So we are using a Label inside to a Rectangle + //in order to overide that issue. + Rectangle { + id: fakeBorder + Layout.minimumHeight: units.gridUnit * 2 + border.color: syspal.mid + color: syspal.window + Layout.fillWidth: true + anchors { + top: parent.top + bottom: parent.bottom + left: fontCategory.right + right: fontButton.left + rightMargin: 5 + leftMargin: 10 + } + + } + QtControls.Label { + text: model.font.family + " " + model.font.pointSize + font: model.font + anchors { + left: fakeBorder.left + leftMargin: 5 + horizontalCenter: fakeBorder.horizontalCenter + } + } + + QtControls.Button { + id: fontButton + text: i18n("Choose...") + implicitHeight: fakeBorder.height + anchors.right: parent.right + onClicked: { + fontDialog.adjustAllFonts = false; + fontDialog.currentIndex = index; + fontDialog.currentFont = model.font; + fontDialog.open() + } + } + } + } + } + + QtControls.Button { + id: adjustAllFontsButton + text: i18n("Adjust All Fonts...") + + anchors { + top: scrollView.bottom + topMargin: 20 + right: parent.right + } + + onClicked: { + fontDialog.adjustAllFonts = true; + fontDialog.open() + } + } + + + GridLayout { + id: aaSettingsRow + columns: 3 + Layout.alignment : Qt.AlignLeft + anchors.top: adjustAllFontsButton.bottom + Layout.maximumWidth: 300 + + QtControls.Label { + text: i18n("Use anti-aliasing:") + font.pixelSize: 14 + anchors { + right: antiAliasingComboBox.left + rightMargin: 20 + } + } + + QtControls.ComboBox { + id: antiAliasingComboBox + //The ComboBox width doesn't scale based on the length or the + //currentText. + implicitWidth: parent.width / 1.9 + + model: [i18n("Enabled"), i18n("System Settings"), i18n("Disabled")] + + currentIndex: kcm.fontAASettings.antiAliasing + onCurrentIndexChanged: kcm.fontAASettings.antiAliasing = antiAliasingComboBox.currentIndex + } + + QtControls.Button { + text: i18n("Configure...") + enabled: antiAliasingComboBox.currentIndex == 0 + + onClicked: { + advancedDialog.open() + } + } + + QtControls.CheckBox { + id: dpiCheckBox + checked: dpiSpinBox.value != 96 + text: i18n("Force Fonts DPI:") + onCheckedChanged: { + if (!dpiCheckBox.checked) { + dpiSpinBox.enabled = false; + kcm.fontAASettings.dpi = 0; + } else { + dpiSpinBox.enabled = true; + } + } + } + + QtControls.SpinBox { + id: dpiSpinBox + stepSize: 24 + enabled: dpiCheckBox.checked + value: kcm.fontAASettings.dpi + onValueChanged: kcm.fontAASettings.dpi = dpiSpinBox.value + implicitWidth: antiAliasingComboBox.width + maximumValue: 1000 + minimumValue: 96 + } + } + + QtDialogs.Dialog { + id: advancedDialog + title: i18n("Configure Anti-Alias Settings") + standardButtons: QtDialogs.StandardButton.Ok | QtDialogs.StandardButton.Cancel + width: units.gridUnit * 17 + + onAccepted: { + kcm.fontAASettings.subPixel = subPixelComboBox.currentText; + kcm.fontAASettings.hinting = hintingComboBox.currentText; + kcm.fontAASettings.excludeTo = excludeCheckBox.checked ? excludeToSpinBox.value : 0; + kcm.fontAASettings.excludeFrom = excludeCheckBox.checked ? excludeFromSpinBox.value : 0; + } + + onVisibleChanged: { + //our dialog has open + if (advancedDialog.visible) { + subPixelComboBox.currentIndex = kcm.fontAASettings.subPixelCurrentIndex(); + hintingComboBox.currentIndex = kcm.fontAASettings.hintingCurrentIndex(); + excludeToSpinBox.value = kcm.fontAASettings.excludeTo; + excludeFromSpinBox.value = kcm.fontAASettings.excludeFrom; + } + } + + ColumnLayout { + RowLayout { + QtControls.CheckBox { + id: excludeCheckBox + checked: excludeToSpinBox.value != 0 && excludeFromSpinBox.value != 0 + text: i18n("Exclude Range") + Layout.fillWidth: true + } + + QtControls.SpinBox { + id: excludeFromSpinBox + stepSize: 1 + suffix: " pt" + enabled: excludeCheckBox.checked + } + + QtControls.Label { + text: i18n("to") + } + + QtControls.SpinBox { + id: excludeToSpinBox + stepSize: 1 + suffix: " pt" + enabled: excludeCheckBox.checked + } + } + + RowLayout { + QtControls.Label{ + text: i18n("Sub-pixel rendering type:") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + + QtControls.ComboBox { + id: subPixelComboBox + currentIndex: kcm.fontAASettings.subPixelCurrentIndex() + model: kcm.fontAASettings.subPixelOptionsModel + textRole: "display" + } + } + + RowLayout { + QtControls.Label { + text: i18n("Hinting style:") + Layout.fillWidth: true + horizontalAlignment: Text.AlignRight + } + + QtControls.ComboBox { + id: hintingComboBox + currentIndex: kcm.fontAASettings.hintingCurrentIndex() + model: kcm.fontAASettings.hintingOptionsModel + textRole: "display" + } + } + } + } + + Connections { + target: kcm.fontAASettings + onSubPixelChanged: kcm.needsSave = true + onHintingChanged: kcm.needsSave = true + onExcludeToChanged: kcm.needsSave = true + onExcludeFromChanged: kcm.needsSave = true + //FIXME Those two signals are being emitted but the kcm.needsSave doesn't change. + //onDpiChanged: kcm.needsSave = true + //onAliasingChanged: kcm.needsSave = true; + } + + QtDialogs.FontDialog { + id: fontDialog + title: "Choose a font" + property int currentIndex + property bool adjustAllFonts: false + onAccepted: { + if (adjustAllFonts) { + kcm.adjustAllFonts(font) + } else { + kcm.updateFont(currentIndex, font) + } + } + } + + QtDialogs.MessageDialog { + id: messageDialog + title: i18n("Settings Have Changed") + text: i18n("Some changes such as anti-aliasing or DPI will only affect newly started applications.") + } + + Connections { + target: kcm + onFontsHaveChanged: messageDialog.open() + } +} + diff --git a/kcms/fonts/package/metadata.desktop b/kcms/fonts/package/metadata.desktop new file mode 100644 index 000000000..e69cfd4d0 --- /dev/null +++ b/kcms/fonts/package/metadata.desktop @@ -0,0 +1,149 @@ +[Desktop Entry] +Name=Fonts +Name[af]=Skriftipes +Name[ar]=الخطوط +Name[be]=Шрыфты +Name[be@latin]=Šryfty +Name[bg]=Шрифтове +Name[bn]=ফন্ট +Name[bn_IN]=ফন্ট +Name[br]=Fontoù +Name[bs]=Fontovi +Name[ca]=Tipus de lletra +Name[ca@valencia]=Tipus de lletra +Name[cs]=Písma +Name[csb]=Fòntë +Name[cy]=Ffontiau +Name[da]=Skrifttyper +Name[de]=Schriftarten +Name[el]=Γραμματοσειρές +Name[en_GB]=Fonts +Name[eo]=Tiparoj +Name[es]=Tipos de letra +Name[et]=Fondid +Name[eu]=Letra-tipoak +Name[fa]=قلمها +Name[fi]=Fontit +Name[fr]=Polices de caractères +Name[fy]=Lettertypen +Name[ga]=Clónna +Name[gl]=Tipos de letra +Name[gu]=ફોન્ટ્સ +Name[he]=גופנים +Name[hi]=फ़ॉन्ट्स +Name[hne]=फोंट +Name[hr]=Fontovi +Name[hsb]=Pisma +Name[hu]=Betűtípusok +Name[ia]=Fontes +Name[id]=Fonta +Name[is]=Letur +Name[it]=Caratteri +Name[ja]=フォント +Name[ka]=ფონტები +Name[kk]=Қаріптер +Name[km]=ពុម្ព​អក្សរ +Name[kn]=ಅಕ್ಷರಶೈಲಿಗಳು +Name[ko]=글꼴 +Name[ku]=Curenivîs +Name[lt]=Šriftai +Name[lv]=Fonti +Name[mai]=फान्ट +Name[mk]=Фонтови +Name[ml]=അക്ഷരസഞ്ചയങ്ങള്‍ +Name[mr]=फॉन्ट +Name[ms]=Fon +Name[nb]=Skrifttyper +Name[nds]=Schriftoorden +Name[ne]=फन्ट +Name[nl]=Lettertypen +Name[nn]=Skrifter +Name[oc]=Poliças +Name[or]=ଅକ୍ଷର ରୂପ +Name[pa]=ਫੋਂਟ +Name[pl]=Czcionki +Name[pt]=Tipos de Letra +Name[pt_BR]=Fontes +Name[ro]=Fonturi +Name[ru]=Шрифты +Name[se]=Fonttat +Name[si]=අකුරු +Name[sk]=Písma +Name[sl]=Pisave +Name[sr]=Фонтови +Name[sr@ijekavian]=Фонтови +Name[sr@ijekavianlatin]=Fontovi +Name[sr@latin]=Fontovi +Name[sv]=Teckensnitt +Name[ta]=எழுத்துருக்கள் +Name[te]=ఫాంట్‍స్ +Name[tg]=Ҳарфҳо +Name[th]=แบบอักษรต่างๆ +Name[tr]=Yazı Tipleri +Name[ug]=خەت نۇسخىلىرى +Name[uk]=Шрифти +Name[uz]=Shriftlar +Name[uz@cyrillic]=Шрифтлар +Name[vi]=Phông chữ +Name[wa]=Fontes +Name[xh]=Uhlobo lwamagama +Name[x-test]=xxFontsxx +Name[zh_CN]=字体 +Name[zh_TW]=字型 + +Comment=Fonts +Comment[ar]=الخطوط +Comment[bs]=Fontovi +Comment[ca]=Tipus de lletra +Comment[cs]=Písma +Comment[da]=Skrifttyper +Comment[de]=Schriftarten +Comment[el]=Γραμματοσειρές +Comment[en_GB]=Fonts +Comment[es]=Tipos de letra +Comment[fi]=Fontit +Comment[fr]=Polices de caractères +Comment[gl]=Tipos de letra +Comment[hu]=Betűtípusok +Comment[id]=Fonta +Comment[it]=Caratteri +Comment[ko]=글꼴 +Comment[lt]=Šriftai +Comment[mr]=फॉन्ट +Comment[nb]=Skrifttype +Comment[nds]=Schriftoorden +Comment[nl]=Lettertypen +Comment[pa]=ਫੋਂਟ +Comment[pl]=Czcionki +Comment[pt]=Tipos de Letra +Comment[pt_BR]=Fontes +Comment[ru]=Шрифты +Comment[sk]=Písma +Comment[sl]=Pisave +Comment[sr]=Фонтови +Comment[sr@ijekavian]=Фонтови +Comment[sr@ijekavianlatin]=Fontovi +Comment[sr@latin]=Fontovi +Comment[sv]=Teckensnitt +Comment[tr]=Yazı Tipleri +Comment[uk]=Шрифти +Comment[x-test]=xxFontsxx +Comment[zh_CN]=字体 +Comment[zh_TW]=字型 + +Icon=preferences-desktop-font +Encoding=UTF-8 +Keywords= +Type=Service +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Antonis Tsiapaliokas +X-KDE-PluginInfo-Email=antonis.tsiapaliokas@kde.org +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=kcm_fonts +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-KDE-ServiceTypes=Plasma/Generic +X-Plasma-API=declarativeappletscript + +X-Plasma-MainScript=ui/main.qml +X-Plasma-RemoteLocation=