summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-01 20:58:30 (UTC)
committer sandman <sandman>2002-10-01 20:58:30 (UTC)
commit2906826d9ebc268bc233f97956ee1dc5b338c69b (patch) (unidiff)
treed6af20025d6ac5e9220a3f1458d1985df8a6cc93
parent88bef2791f8e4c99e0e9d34ddfe518b5baa2df72 (diff)
downloadopie-2906826d9ebc268bc233f97956ee1dc5b338c69b.zip
opie-2906826d9ebc268bc233f97956ee1dc5b338c69b.tar.gz
opie-2906826d9ebc268bc233f97956ee1dc5b338c69b.tar.bz2
OFontSelector has now an optional builtin preview widget
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofontselector.cpp51
-rw-r--r--libopie/ofontselector.h5
2 files changed, 47 insertions, 9 deletions
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp
index e1090b5..b905474 100644
--- a/libopie/ofontselector.cpp
+++ b/libopie/ofontselector.cpp
@@ -30,22 +30,24 @@
30#include <qlistbox.h> 30#include <qlistbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qmultilineedit.h>
34 35
35#include <qpe/fontdatabase.h> 36#include <qpe/fontdatabase.h>
36 37
37#include "ofontselector.h" 38#include "ofontselector.h"
38 39
39class OFontSelectorPrivate { 40class OFontSelectorPrivate {
40public: 41public:
41 QListBox * m_font_family_list; 42 QListBox * m_font_family_list;
42 QComboBox * m_font_style_list; 43 QComboBox * m_font_style_list;
43 QComboBox * m_font_size_list; 44 QComboBox * m_font_size_list;
45 QMultiLineEdit *m_preview;
44 46
45 bool m_pointbug; 47 bool m_pointbug;
46 48
47 FontDatabase m_fdb; 49 FontDatabase m_fdb;
48}; 50};
49 51
50 52
51class FontListItem : public QListBoxText { 53class FontListItem : public QListBoxText {
@@ -100,9 +102,9 @@ static int qt_version ( )
100 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 102 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
101} 103}
102 104
103 105
104OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 106OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
105{ 107{
106 d = new OFontSelectorPrivate ( ); 108 d = new OFontSelectorPrivate ( );
107 109
108 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 ); 110 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 );
@@ -128,8 +130,21 @@ OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) :
128 gridLayout->addWidget( d-> m_font_size_list, 3, 1 ); 130 gridLayout->addWidget( d-> m_font_size_list, 3, 1 );
129 131
130 d-> m_pointbug = ( qt_version ( ) <= 233 ); 132 d-> m_pointbug = ( qt_version ( ) <= 233 );
131 133
134 if ( withpreview ) {
135 d-> m_preview = new QMultiLineEdit ( this, "Preview" );
136 d-> m_preview-> setAlignment ( AlignCenter );
137 d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth );
138 d-> m_preview-> setMargin ( 3 );
139 d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
140 gridLayout-> addRowSpacing ( 5, 4 );
141 gridLayout-> addMultiCellWidget ( d-> m_preview, 6, 6, 0, 1 );
142 gridLayout-> setRowStretch ( 6, 5 );
143 }
144 else
145 d-> m_preview = 0;
146
132 loadFonts ( d-> m_font_family_list ); 147 loadFonts ( d-> m_font_family_list );
133} 148}
134 149
135OFontSelector::~OFontSelector ( ) 150OFontSelector::~OFontSelector ( )
@@ -303,9 +318,14 @@ void OFontSelector::fontSizeClicked ( int /*index*/ )
303} 318}
304 319
305void OFontSelector::changeFont ( ) 320void OFontSelector::changeFont ( )
306{ 321{
307 emit fontSelected ( selectedFont ( )); 322 QFont f = selectedFont ( );
323
324 if ( d-> m_preview )
325 d-> m_preview-> setFont ( f );
326
327 emit fontSelected ( f );
308} 328}
309 329
310 330
311QFont OFontSelector::selectedFont ( ) 331QFont OFontSelector::selectedFont ( )
@@ -324,4 +344,19 @@ QFont OFontSelector::selectedFont ( )
324 } 344 }
325 else 345 else
326 return QFont ( ); 346 return QFont ( );
327} 347}
348
349
350void OFontSelector::resizeEvent ( QResizeEvent *re )
351{
352 if ( d-> m_preview ) {
353 d-> m_preview-> setMinimumHeight ( 1 );
354 d-> m_preview-> setMaximumHeight ( 32767 );
355 }
356
357 QWidget::resizeEvent ( re );
358
359 if ( d-> m_preview )
360 d-> m_preview-> setFixedHeight ( d-> m_preview-> height ( ));
361
362}
diff --git a/libopie/ofontselector.h b/libopie/ofontselector.h
index a9c8a72..10d16f0 100644
--- a/libopie/ofontselector.h
+++ b/libopie/ofontselector.h
@@ -39,9 +39,9 @@ class OFontSelector : public QWidget
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41 41
42public: 42public:
43 OFontSelector ( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 43 OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
44 virtual ~OFontSelector ( ); 44 virtual ~OFontSelector ( );
45 45
46 bool selectedFont ( QString &family, QString &style, int &size ); 46 bool selectedFont ( QString &family, QString &style, int &size );
47 bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); 47 bool selectedFont ( QString &family, QString &style, int &size, QString &charset );
@@ -63,8 +63,11 @@ protected slots:
63 virtual void fontFamilyClicked ( int ); 63 virtual void fontFamilyClicked ( int );
64 virtual void fontStyleClicked ( int ); 64 virtual void fontStyleClicked ( int );
65 virtual void fontSizeClicked ( int ); 65 virtual void fontSizeClicked ( int );
66 66
67protected:
68 virtual void resizeEvent ( QResizeEvent *re );
69
67private: 70private:
68 void loadFonts ( QListBox * ); 71 void loadFonts ( QListBox * );
69 72
70 void changeFont ( ); 73 void changeFont ( );