-rw-r--r-- | libopie/ofontselector.cpp | 39 | ||||
-rw-r--r-- | libopie/ofontselector.h | 5 |
2 files changed, 41 insertions, 3 deletions
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp index e1090b5..b905474 100644 --- a/libopie/ofontselector.cpp +++ b/libopie/ofontselector.cpp | |||
@@ -31,6 +31,7 @@ | |||
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 | ||
@@ -41,6 +42,7 @@ 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 | ||
@@ -101,7 +103,7 @@ static int qt_version ( ) | |||
101 | } | 103 | } |
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 ( ); |
107 | 109 | ||
@@ -129,6 +131,19 @@ OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : | |||
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 | ||
@@ -304,7 +319,12 @@ void OFontSelector::fontSizeClicked ( int /*index*/ ) | |||
304 | 319 | ||
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 | ||
310 | 330 | ||
@@ -325,3 +345,18 @@ QFont OFontSelector::selectedFont ( ) | |||
325 | else | 345 | else |
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 | |||
@@ -40,7 +40,7 @@ class OFontSelector : public QWidget | |||
40 | Q_OBJECT | 40 | Q_OBJECT |
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 | ||
46 | bool selectedFont ( QString &family, QString &style, int &size ); | 46 | bool selectedFont ( QString &family, QString &style, int &size ); |
@@ -64,6 +64,9 @@ protected slots: | |||
64 | virtual void fontStyleClicked ( int ); | 64 | virtual void fontStyleClicked ( int ); |
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 * ); |
69 | 72 | ||