From kde-core-devel Wed Dec 08 16:06:00 2004 From: Ian Reinhart Geiser Date: Wed, 08 Dec 2004 16:06:00 +0000 To: kde-core-devel Subject: Patch for KFontRequester. Message-Id: <200412081106.00704.ian () geiseri ! com> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=110252196725018 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_oZytBSyTn4jDMPV" --Boundary-00=_oZytBSyTn4jDMPV Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Greetings, This is a small patch for KFontRequester. Its an awesome widget for picking fonts but the font preview sometimes gets in the way when you are doing some special fonts aka 128+ point fonts. (Yes its completely possible to get this when working on things like banners) So I added the ability to turn the preview off. Is this cool to add? AFAIK there is no break in BC, and by default the behavior is unchanged. cheers -ian reinhart geiser -- ------(Ian Reinhart Geiser)---------- Forget that once we where just dust forged in heavens fire. As we where forged we perhaps shall return someday... -VNV Nation, Further --Boundary-00=_oZytBSyTn4jDMPV Content-Type: text/x-diff; charset="us-ascii"; name="kfontrequester.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kfontrequester.patch" Index: kfontrequester.h =================================================================== RCS file: /home/kde/kdelibs/kdeui/kfontrequester.h,v retrieving revision 1.10 diff -u -u -r1.10 kfontrequester.h --- kfontrequester.h 9 Sep 2004 15:23:53 -0000 1.10 +++ kfontrequester.h 8 Dec 2004 15:51:39 -0000 @@ -48,7 +48,8 @@ Q_PROPERTY( QString title READ title WRITE setTitle ) Q_PROPERTY( QString sampleText READ sampleText WRITE setSampleText ) Q_PROPERTY( QFont font READ font WRITE setFont ) - + Q_PROPERTY( bool isFixedOnly READ isFixedOnly) + Q_PROPERTY( bool preview READ preview WRITE setPreview ) public: /** @@ -62,6 +63,17 @@ KFontRequester( QWidget *parent=0L, const char *name=0L, bool onlyFixed=false ); + ~KFontRequester(); + /** + * @return If the requester should show the label in the currently selected font. + */ + bool preview() const; + + /** + * Tells the requester if it should or should not preview the currently selected font in the preview window. + */ + void setPreview( bool prev ); + /** * @return The currently selected font in the requester. */ Index: kfontrequester.cpp =================================================================== RCS file: /home/kde/kdelibs/kdeui/kfontrequester.cpp,v retrieving revision 1.4 diff -u -u -r1.4 kfontrequester.cpp --- kfontrequester.cpp 8 Jun 2003 00:54:00 -0000 1.4 +++ kfontrequester.cpp 8 Dec 2004 15:51:39 -0000 @@ -28,10 +28,19 @@ #include #include +class KFontRequester::KFontRequesterPrivate +{ + public: + bool m_preview; +}; + KFontRequester::KFontRequester( QWidget *parent, const char *name, bool onlyFixed ) : QWidget( parent, name ), m_onlyFixed( onlyFixed ) { + d = new KFontRequesterPrivate(); + d->m_preview = true; + QHBoxLayout *layout = new QHBoxLayout( this, 0, KDialog::spacingHint() ); m_sampleLabel = new QLabel( this, "m_sampleLabel" ); @@ -82,7 +91,8 @@ void KFontRequester::displaySampleText() { - m_sampleLabel->setFont( m_selFont ); + if( d->m_preview ) + m_sampleLabel->setFont( m_selFont ); int size = m_selFont.pointSize(); if(size == -1) @@ -120,6 +130,22 @@ } } +bool KFontRequester::preview() const +{ + return d->m_preview; +} + +void KFontRequester::setPreview( bool prev ) +{ + d->m_preview = prev; +} + +KFontRequester::~KFontRequester() +{ + delete d; +} + + #include "kfontrequester.moc" /* vim: et sw=2 ts=2 --Boundary-00=_oZytBSyTn4jDMPV--