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

List:       kde-core-devel
Subject:    [PATCH] kfontchooser and konsole
From:       Sean Harmer <sh () theharmers ! co ! uk>
Date:       2007-10-19 10:47:38
Message-ID: 200710191147.38489.sh () theharmers ! co ! uk
[Download RAW message or body]

Hi,

After attending the Munich devdays and hearing Aaron, Till and others swear 
when accidentally changing the font family when they intended to change the 
font size in konsole for presentations, I thought I'd fix it. It does seem 
that changing the font size is the most common action when using the font 
dialog. The first patch below simply sets the focus onto the size list when 
the font dialog is constructed.

Whilst doing this I came across a TODO comment in the konsole source which 
said that it would be nice to restrict the font selection in konsole to fixed 
width fonts only. The second patch below achieves this.

The api for restricting to fixed width fonts in KFontDialog and KFontChooser 
is not very nice or intuitive though. You can request fixed width fonts inthe 
constructor, but you can then (too easily) override this with future calls to 
the setFont function which takes a bool parameter specifying if you want only 
fixed fonts or not.

However, I guess it is too late in the day to fix the API for this by adding a 
setRestrictFonts( const KFontChooser::DisplayFlags& flags ) member and 
removing the bool parameter from setFont(). If it's not too late and you 
would like me to do this, then please just ask.

I'll leave it for somebody with more experience to commit/reject these 
patches.

Kind regards,

Sean Harmer

["AdjustFontSize.patch" (text/x-diff)]

Index: kdeui/fonts/kfontchooser.cpp
===================================================================
--- kdeui/fonts/kfontchooser.cpp	(revision 726952)
+++ kdeui/fonts/kfontchooser.cpp	(working copy)
@@ -405,6 +405,9 @@
 
     KConfigGroup cg(KGlobal::config(), QLatin1String("General"));
     d->_k_showXLFDArea(cg.readEntry(QLatin1String("fontSelectorShowXLFD"), false));
+
+    // Set focus to the size list as this is the most commonly changed property
+    d->sizeListBox->setFocus();
 }
 
 KFontChooser::~KFontChooser()

["KonsoleFixedFontsOnly.patch" (text/x-diff)]

Index: apps/konsole/src/EditProfileDialog.cpp
===================================================================
--- apps/konsole/src/EditProfileDialog.cpp	(revision 726952)
+++ apps/konsole/src/EditProfileDialog.cpp	(working copy)
@@ -961,14 +961,11 @@
 }
 void EditProfileDialog::showFontDialog()
 {
-    //TODO Only permit selection of mono-spaced fonts.  
-    // the KFontDialog API does not appear to have a means to do this
-    // at present.
     QFont currentFont = _ui->fontPreviewLabel->font();
-   
-    KFontDialog* dialog = new KFontDialog(this);
-    dialog->setFont(currentFont);
 
+    KFontDialog* dialog = new KFontDialog(this, KFontChooser::FixedFontsOnly);
+    dialog->setFont(currentFont, true);
+
     connect( dialog , SIGNAL(fontSelected(const QFont&)) , this , SLOT(fontSelected(const QFont&)) );
     dialog->show(); 
 }


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

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