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

List:       kde-core-devel
Subject:    Proposed kfontdialog patch
From:       David Jarvie <software () astrojar ! org ! uk>
Date:       2001-09-04 2:35:13
[Download RAW message or body]

Hi,

I would like to propose a small patch to kfontdialog. The purpose is to 
enable the user to set the colour of the sample text more flexibly than at 
present. It would allow both the text and background colour to be set, and 
also the colour when the widget loses focus. It is backwards compatible with 
the current version.

I have implemented the revised version in KAlarm (which is in CVS as part of 
kdepim), and would like to be able to use the (revised) standard version 
instead.

The patch simply adds extra default parameters to color() and setColor().

Cheers,

David Jarvie.

-- 
David Jarvie  <software@astrojar.org.uk>
["patch-kfontdialog" (text/x-c++)]

diff -uBb kdelibs/kdeui/kfontdialog.h kfontdialog.h
---  kfontdialog.h  Aug  2 21:27:50 2001
+++  kfontdialog.h.new  Sep  4 03:22:49 2001
@@ -27,6 +27,7 @@
 #define _K_FONT_DIALOG_H_
 
 #include <qlineedit.h>
+#include <qpalette.h>
 #include <kdialogbase.h>
 
 class QComboBox;
@@ -116,12 +117,12 @@
   /**
    * Set the color to use in the preview
    */
-  void setColor( const QColor & col );
+  void setColor( const QColor & col, QPalette::ColorGroup = QPalette::Active, \
QColorGroup::ColorRole = QColorGroup::Text );  
   /**
    * @return The color currently used in the preview (default: black)
    */
-  QColor color() const;
+  QColor color( QPalette::ColorGroup = QPalette::Active, QColorGroup::ColorRole = \
QColorGroup::Text ) const;  
   /**
    * Set the currently selected charset in the chooser.
diff -uBb kdelibs/kdeui/kfontdialog.cpp kfontdialog.cpp
---  kfontdialog.cpp  Aug  2 21:27:50 2001
+++  kfontdialog.cpp.new  Sep  4 03:26:51 2001
@@ -82,9 +82,11 @@
 class KFontChooser::KFontChooserPrivate
 {
 public:
-    KFontChooserPrivate() { m_color = Qt::black; }
+    KFontChooserPrivate()
+        { m_palette.setColor(QPalette::Active, QColorGroup::Text, Qt::black);
+          m_palette.setColor(QPalette::Active, QColorGroup::Base, Qt::white); }
     QLabel *charsetLabel;
-    QColor m_color;
+    QPalette m_palette;
 };
 
 KFontChooser::KFontChooser(QWidget *parent, const char *name,
@@ -241,17 +243,17 @@
   delete d;
 }
 
-void KFontChooser::setColor( const QColor & col )
+void KFontChooser::setColor( const QColor & col, QPalette::ColorGroup group, \
QColorGroup::ColorRole role )  {
-  d->m_color = col;
+  d->m_palette.setColor(group, role, col);
   QPalette pal = sampleEdit->palette();
-  pal.setColor( QPalette::Active, QColorGroup::Text, col );
+  pal.setColor(group, role, col);
   sampleEdit->setPalette( pal );
 }
 
-QColor KFontChooser::color() const
+QColor KFontChooser::color( QPalette::ColorGroup group, QColorGroup::ColorRole role ) const
 {
-  return d->m_color;
+  return d->m_palette.color(group, role);
 }
 
 QSize KFontChooser::sizeHint( void ) const



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

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