summaryrefslogtreecommitdiffstats
path: root/kcontrol
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2021-10-04 17:04:23 +0900
committerMichele Calgaro <[email protected]>2021-10-07 10:30:28 +0900
commite8d86645043847265b61825c9a1f20a6b93cc924 (patch)
tree36d0de030110787276cc4273758e671268104145 /kcontrol
parent6d39ea6ae8fffaa9419131d1b70f4d78f55bea44 (diff)
downloadtdebase-e8d86645043847265b61825c9a1f20a6b93cc924.tar.gz
tdebase-e8d86645043847265b61825c9a1f20a6b93cc924.zip
Added support for variable font DPI (range 64-512) in user session.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'kcontrol')
-rw-r--r--kcontrol/fonts/fonts.cpp64
-rw-r--r--kcontrol/fonts/fonts.h6
-rw-r--r--kcontrol/krdb/krdb.cpp17
3 files changed, 61 insertions, 26 deletions
diff --git a/kcontrol/fonts/fonts.cpp b/kcontrol/fonts/fonts.cpp
index 4d1083365..7239b62ac 100644
--- a/kcontrol/fonts/fonts.cpp
+++ b/kcontrol/fonts/fonts.cpp
@@ -637,23 +637,20 @@ TDEFonts::TDEFonts(TQWidget *parent, const char *name, const TQStringList &)
lay->addWidget( label, 1, 0 );
comboForceDpi = new TQComboBox( this );
label->setBuddy( comboForceDpi );
- comboForceDpi->insertItem( i18n( "Disabled" )); // change DPISetti ng type if order changes
- comboForceDpi->insertItem( i18n( "96 DPI" ));
- comboForceDpi->insertItem( i18n( "120 DPI" ));
+ comboForceDpi->insertItem( i18n( "Disabled" ));
+ comboForceDpi->insertItem( i18n( "Enabled" ));
TQString 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"
" is also often misused when poor quality fonts are used that do not"
- " look well with DPI values other than 96 or 120 DPI.</p>"
- "<p>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 or adding <i>-dpi value</i> to"
- " ServerLocalArgs= in $TDEDIR/share/config/tdm/tdmrc). When fonts do not render"
- " properly with real DPI value better fonts should be used or configuration"
- " of font hinting should be checked.</p>" );
+ " look well with DPI values other than 96 or 120 DPI.</p>");
TQWhatsThis::add(comboForceDpi, whatsthis);
- connect( comboForceDpi, TQT_SIGNAL( activated( int )), TQT_SLOT( changed()));
+ connect(comboForceDpi, TQT_SIGNAL(activated(int)), TQT_SLOT(slotUseFontDPI()));
+ sbDpiValue = new KIntSpinBox(64, 512, 1, 96, 10, this);
+ TQWhatsThis::add(sbDpiValue, whatsthis);
+ connect(sbDpiValue, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(changed()));
lay->addWidget( comboForceDpi, 1, 1 );
+ lay->addWidget( sbDpiValue, 1, 2 );
layout->addStretch(1);
@@ -695,10 +692,22 @@ void TDEFonts::load( bool useDefaults )
TDEConfig cfgfonts("kcmfonts", true);
cfgfonts.setGroup("General");
- int dpicfg = cfgfonts.readNumEntry( "forceFontDPI", 0 );
- DPISetting dpi = dpicfg == 120 ? DPI120 : dpicfg == 96 ? DPI96 : DPINone;
- comboForceDpi->setCurrentItem( dpi );
- dpi_original = dpi;
+ int dpicfg = cfgfonts.readNumEntry("forceFontDPI", 0);
+ // "forceFontDPIEnable" must be read after "forceFontDPI" to make sure it is
+ // correctly initialized on the first run when upgrading to the new format,
+ // without the user even noticying it. The first time "forceFontDPIEnable"
+ // will not exist and its correct value will be deduced by the existing value
+ // of "forceFontDPI", which contains the value prior to the update.
+ bool dpiEnable = cfgfonts.readBoolEntry("forceFontDPIEnable", dpicfg > 0);
+ dpi_original = dpiEnable ? DPIValue : DPINone;
+ dpi_value_original = dpicfg;
+ if (dpi_value_original < 64 || dpi_value_original > 512)
+ {
+ dpi_value_original = 96;
+ }
+ comboForceDpi->setCurrentItem(dpi_original);
+ sbDpiValue->setValue(dpi_value_original);
+ sbDpiValue->setEnabled(dpi_original != DPINone);
if( cfgfonts.readBoolEntry( "dontChangeAASettings", true )) {
useAA_original = useAA = AASystem;
cbAA->setCurrentItem( useAA );
@@ -717,14 +726,16 @@ void TDEFonts::save()
TDEConfig cfgfonts("kcmfonts");
cfgfonts.setGroup("General");
- DPISetting dpi = static_cast< DPISetting >( comboForceDpi->currentItem());
- const int dpi2value[] = { 0, 96, 120 };
- cfgfonts.writeEntry( "forceFontDPI", dpi2value[ dpi ] );
+ DPISetting dpi = (DPISetting)comboForceDpi->currentItem();
+ int dpival = sbDpiValue->value();
+ cfgfonts.writeEntry( "forceFontDPIEnable", dpi != DPINone );
+ cfgfonts.writeEntry( "forceFontDPI", dpival );
cfgfonts.writeEntry( "dontChangeAASettings", cbAA->currentItem() == AASystem );
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 == DPINone)
+ {
KProcIO proc;
proc << "xrdb" << "-quiet" << "-remove" << "-nocpp";
proc.writeStdin( TQCString( "Xft.dpi" ), true );
@@ -755,11 +766,11 @@ void TDEFonts::save()
if( cbAA->currentItem() != AASystem )
aaSave = aaSettings->save( useAA == AAEnabled );
- if( aaSave || (useAA != useAA_original) || dpi != dpi_original) {
+ if( aaSave || (useAA != useAA_original) || dpival != dpi_value_original || dpi != dpi_original)
+ {
KMessageBox::information(this,
- i18n(
- "<p>Some changes such as anti-aliasing will only affect newly started applications.</p>"
- ), i18n("Font Settings Changed"), "FontSettingsChanged", false);
+ i18n( "<p>Some changes such as anti-aliasing will only affect newly started applications.</p>"),
+ i18n("Font Settings Changed"), "FontSettingsChanged", false);
useAA_original = useAA;
dpi_original = dpi;
}
@@ -791,6 +802,13 @@ void TDEFonts::slotUseAntiAliasing()
emit changed(true);
}
+void TDEFonts::slotUseFontDPI()
+{
+ DPISetting dpi = (DPISetting)(comboForceDpi->currentItem());
+ sbDpiValue->setEnabled(dpi != DPINone);
+ emit changed(true);
+}
+
void TDEFonts::slotCfgAa()
{
if(aaSettings->exec())
diff --git a/kcontrol/fonts/fonts.h b/kcontrol/fonts/fonts.h
index 65a1266cb..3d1e9643a 100644
--- a/kcontrol/fonts/fonts.h
+++ b/kcontrol/fonts/fonts.h
@@ -20,6 +20,7 @@
class TQCheckBox;
class TQComboBox;
class KDoubleNumInput;
+class KIntSpinBox;
class FontAASettings;
class FontUseItem : public TDEFontRequester
@@ -107,15 +108,18 @@ protected slots:
void slotApplyFontDiff();
void slotUseAntiAliasing();
void slotCfgAa();
+ void slotUseFontDPI();
private:
enum AASetting { AAEnabled, AASystem, AADisabled };
- enum DPISetting { DPINone, DPI96, DPI120 };
+ enum DPISetting { DPINone, DPIValue };
AASetting useAA, useAA_original;
DPISetting dpi_original;
+ int dpi_value_original;
TQComboBox *cbAA;
TQComboBox* comboForceDpi;
TQPushButton *aaSettingsButton;
+ KIntSpinBox *sbDpiValue;
TQPtrList <FontUseItem> fontUseList;
FontAASettings *aaSettings;
};
diff --git a/kcontrol/krdb/krdb.cpp b/kcontrol/krdb/krdb.cpp
index 8c30c3286..25db21f3c 100644
--- a/kcontrol/krdb/krdb.cpp
+++ b/kcontrol/krdb/krdb.cpp
@@ -547,8 +547,21 @@ void runRdb( uint flags )
TDEConfig cfgfonts("kcmfonts", true);
cfgfonts.setGroup("General");
- if( cfgfonts.readNumEntry( "forceFontDPI", 0 ) != 0 )
- contents += "Xft.dpi: " + cfgfonts.readEntry( "forceFontDPI" ) + '\n';
+ int dpicfg = cfgfonts.readNumEntry("forceFontDPI", 0);
+ // "forceFontDPIEnable" must be read after "forceFontDPI" to make sure it is
+ // correctly initialized on the first run when upgrading to the new format,
+ // without the user even noticying it. The first time "forceFontDPIEnable"
+ // will not exist and its correct value will be deduced by the existing value
+ // of "forceFontDPI", which contains the value prior to the update.
+ bool dpiEnable = cfgfonts.readBoolEntry("forceFontDPIEnable", dpicfg > 0);
+ if (dpicfg < 64 || dpicfg > 512)
+ {
+ dpicfg = 96;
+ }
+ if (dpiEnable)
+ {
+ contents += "Xft.dpi: " + TQString::number(dpicfg) + '\n';
+ }
}
if (contents.length() > 0)