[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-doc-english
Subject:    [kde-doc-english]
From:       Lukas Sommer <sommerluk () gmail ! com>
Date:       2011-06-11 9:42:56
Message-ID: 20110611094256.10345A60A4 () git ! kde ! org
[Download RAW message or body]

Git commit 9e1de272620da40fead11dfdb705cfc3d9a90f10 by Lukas Sommer.
Committed on 11/06/2011 at 11:34.
Pushed by sommer into branch 'master'.

Make font dpi fully configurable by the user

Adopts startkde.cmake to accept dpi values different from 96 and 120.

Adopts the UI in kcontrol to make dpi values from 1 to 1000 possible.
The spinbox uses steps of 24 dpi because the common dpi values 72,
96 and 120 are all multiples of 24. As some fonts are optimized for
these resolutions, this could make fonts look better.
FEATURE: 190489
FIXED-IN: 4.7
REVIEW: 101410
GUI:
DIGEST:

M  +28   -20   kcontrol/fonts/fonts.cpp     
M  +4    -3    kcontrol/fonts/fonts.h     
M  +2    -6    startkde.cmake     

http://commits.kde.org/kde-workspace/9e1de272620da40fead11dfdb705cfc3d9a90f10

diff --git a/kcontrol/fonts/fonts.cpp b/kcontrol/fonts/fonts.cpp
index 0cd2666..a9b5ef2 100644
--- a/kcontrol/fonts/fonts.cpp
+++ b/kcontrol/fonts/fonts.cpp
@@ -13,6 +13,7 @@
 #include <QDir>
 #include <QLabel>
 #include <QPushButton>
+#include <QSpinBox>
 #include <QtCore/QSettings>
 
 
@@ -625,14 +626,11 @@ KFonts::KFonts(QWidget *parent, const QVariantList &args)
    lay->addWidget( aaSettingsButton, 0, 2 );
    connect(cbAA, SIGNAL(activated(int)), SLOT(slotUseAntiAliasing()));
 #endif
-   label = new QLabel( i18n( "Force fonts DPI:" ), this );
-   label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
-   lay->addWidget( label, 1, 0 );
-   comboForceDpi = new QComboBox( this );
-   label->setBuddy( comboForceDpi );
-   comboForceDpi->insertItem( DPINone, i18nc("Force fonts DPI", "Disabled" )); // \
                change DPISetti ng type if order changes
-   comboForceDpi->insertItem( DPI96, i18n( "96 DPI" ));
-   comboForceDpi->insertItem( DPI120, i18n( "120 DPI" ));
+   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(
        "<p>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"
@@ -644,9 +642,13 @@ KFonts::KFonts(QWidget *parent, const QVariantList &args)
        " ServerLocalArgs= in $KDEDIR/share/config/kdm/kdmrc). When fonts do not \
                render"
        " properly with real DPI value better fonts should be used or configuration"
        " of font hinting should be checked.</p>" );
-   comboForceDpi->setWhatsThis(whatsthis);
-   connect( comboForceDpi, SIGNAL( activated( int )), SLOT( changed()));
-   lay->addWidget( comboForceDpi, 1, 1 );
+   spinboxDpi->setWhatsThis(whatsthis);
+   checkboxForceDpi->setChecked(false);
+   spinboxDpi->setEnabled(false);
+   connect( spinboxDpi, SIGNAL( valueChanged(int)), SLOT( changed()));
+   connect( checkboxForceDpi, SIGNAL( toggled(bool)), SLOT( changed()));
+   connect( checkboxForceDpi, SIGNAL( toggled(bool)), spinboxDpi, SLOT( \
setEnabled(bool))); +   lay->addWidget( spinboxDpi, 1, 1 );
 
    layout->addStretch(1);
 
@@ -681,7 +683,8 @@ void KFonts::defaults()
   cbAA->setCurrentIndex( useAA );
   aaSettings->defaults();
 #endif
-  comboForceDpi->setCurrentIndex( DPINone );
+  checkboxForceDpi->setChecked( false );
+  spinboxDpi->setValue( 96 );
   emit changed(true);
 }
 
@@ -701,9 +704,15 @@ void KFonts::load()
   KConfig _cfgfonts( "kcmfonts" );
   KConfigGroup cfgfonts(&_cfgfonts, "General");
   int dpicfg = cfgfonts.readEntry( "forceFontDPI", 0 );
-  DPISetting dpi = dpicfg == 120 ? DPI120 : dpicfg == 96 ? DPI96 : DPINone;
-  comboForceDpi->setCurrentIndex( dpi );
-  dpi_original = dpi;
+  if (dpicfg <= 0) {
+    checkboxForceDpi->setChecked(false);
+    spinboxDpi->setValue(96);
+    dpi_original = 0;
+  } else {
+    checkboxForceDpi->setChecked(true);
+    spinboxDpi->setValue(dpicfg);
+    dpi_original = dpicfg;
+  };
 #ifdef HAVE_FONTCONFIG
   if( cfgfonts.readEntry( "dontChangeAASettings", true )) {
       useAA_original = useAA = AASystem;
@@ -727,16 +736,15 @@ void KFonts::save()
 
   KConfig _cfgfonts( "kcmfonts" );
   KConfigGroup cfgfonts(&_cfgfonts, "General");
-  DPISetting dpi = static_cast< DPISetting >( comboForceDpi->currentIndex());
-  const int dpi2value[] = { 0, 96, 120 };
-  cfgfonts.writeEntry( "forceFontDPI", dpi2value[ dpi ] );
+  int dpi = ( checkboxForceDpi->isChecked() ? spinboxDpi->value() : 0 );
+  cfgfonts.writeEntry( "forceFontDPI", dpi );
 #ifdef HAVE_FONTCONFIG
   cfgfonts.writeEntry( "dontChangeAASettings", cbAA->currentIndex() == AASystem );
 #endif
   cfgfonts.sync();
   // 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 == DPINone && dpi_original != DPINone ) {
+  if( dpi == 0 && dpi_original != 0 ) {
       KProcess proc;
       proc << "xrdb" << "-quiet" << "-remove" << "-nocpp";
       proc.start();
@@ -777,7 +785,7 @@ void KFonts::save()
   if( aaSave || (useAA != useAA_original) || dpi != dpi_original) {
     KMessageBox::information(this,
       i18n(
-        "<p>Some changes such as anti-aliasing will only affect newly started \
applications.</p>" +        "<p>Some changes such as anti-aliasing or DPI will only \
affect newly started applications.</p>"  ), i18n("Font Settings Changed"), \
"FontSettingsChanged");  useAA_original = useAA;
     dpi_original = dpi;
diff --git a/kcontrol/fonts/fonts.h b/kcontrol/fonts/fonts.h
index 2c722d4..2a1b940 100644
--- a/kcontrol/fonts/fonts.h
+++ b/kcontrol/fonts/fonts.h
@@ -20,6 +20,7 @@
 
 class QCheckBox;
 class QComboBox;
+class QSpinBox;
 class KDoubleNumInput;
 class FontAASettings;
 
@@ -116,9 +117,9 @@ private:
     FontAASettings *aaSettings;
 #endif
 
-    enum DPISetting { DPINone, DPI96, DPI120 };
-    DPISetting dpi_original;
-    QComboBox* comboForceDpi;
+    int dpi_original;
+    QCheckBox *checkboxForceDpi;
+    QSpinBox* spinboxDpi;
     QList<FontUseItem *> fontUseList;
 };
 
diff --git a/startkde.cmake b/startkde.cmake
index dde9c23..afec4eb 100755
--- a/startkde.cmake
+++ b/startkde.cmake
@@ -130,13 +130,9 @@ fi
 
 . krandrstartup 2>/dev/null
 
-if test "$kcmfonts_general_forcefontdpi" -eq 120; then
+if test "$kcmfonts_general_forcefontdpi" -ne 0; then
     xrdb -quiet -merge -nocpp <<EOF
-Xft.dpi: 120
-EOF
-elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
-    xrdb -quiet -merge -nocpp <<EOF
-Xft.dpi: 96
+Xft.dpi: $kcmfonts_general_forcefontdpi
 EOF
 fi
 
_______________________________________________
kde-doc-english mailing list
kde-doc-english@kde.org
https://mail.kde.org/mailman/listinfo/kde-doc-english


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic