-rw-r--r-- | libopie/ofontselector.cpp | 51 | ||||
-rw-r--r-- | libopie/ofontselector.h | 5 |
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 | |||
@@ -32,4 +32,5 @@ | |||
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> |
@@ -38,12 +39,13 @@ | |||
38 | 39 | ||
39 | class OFontSelectorPrivate { | 40 | class OFontSelectorPrivate { |
40 | public: | 41 | public: |
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 | ||
@@ -102,5 +104,5 @@ static int qt_version ( ) | |||
102 | 104 | ||
103 | 105 | ||
104 | OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) | 106 | OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) |
105 | { | 107 | { |
106 | d = new OFontSelectorPrivate ( ); | 108 | d = new OFontSelectorPrivate ( ); |
@@ -130,4 +132,17 @@ OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : | |||
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 | } |
@@ -305,5 +320,10 @@ void OFontSelector::fontSizeClicked ( int /*index*/ ) | |||
305 | void OFontSelector::changeFont ( ) | 320 | void 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 | ||
@@ -326,2 +346,17 @@ QFont OFontSelector::selectedFont ( ) | |||
326 | return QFont ( ); | 346 | return QFont ( ); |
327 | } | 347 | } |
348 | |||
349 | |||
350 | void 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 | |||
@@ -41,5 +41,5 @@ class OFontSelector : public QWidget | |||
41 | 41 | ||
42 | public: | 42 | public: |
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 | ||
@@ -65,4 +65,7 @@ protected slots: | |||
65 | virtual void fontSizeClicked ( int ); | 65 | virtual void fontSizeClicked ( int ); |
66 | 66 | ||
67 | protected: | ||
68 | virtual void resizeEvent ( QResizeEvent *re ); | ||
69 | |||
67 | private: | 70 | private: |
68 | void loadFonts ( QListBox * ); | 71 | void loadFonts ( QListBox * ); |