summaryrefslogtreecommitdiff
path: root/libopie
authorsandman <sandman>2002-10-01 20:58:30 (UTC)
committer sandman <sandman>2002-10-01 20:58:30 (UTC)
commit2906826d9ebc268bc233f97956ee1dc5b338c69b (patch) (side-by-side diff)
treed6af20025d6ac5e9220a3f1458d1985df8a6cc93 /libopie
parent88bef2791f8e4c99e0e9d34ddfe518b5baa2df72 (diff)
downloadopie-2906826d9ebc268bc233f97956ee1dc5b338c69b.zip
opie-2906826d9ebc268bc233f97956ee1dc5b338c69b.tar.gz
opie-2906826d9ebc268bc233f97956ee1dc5b338c69b.tar.bz2
OFontSelector has now an optional builtin preview widget
Diffstat (limited to 'libopie') (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
@@ -31,20 +31,22 @@
#include <qcombobox.h>
#include <qlabel.h>
#include <qfont.h>
+#include <qmultilineedit.h>
#include <qpe/fontdatabase.h>
#include "ofontselector.h"
class OFontSelectorPrivate {
-public:
- QListBox * m_font_family_list;
- QComboBox * m_font_style_list;
- QComboBox * m_font_size_list;
+public:
+ QListBox * m_font_family_list;
+ QComboBox * m_font_style_list;
+ QComboBox * m_font_size_list;
+ QMultiLineEdit *m_preview;
- bool m_pointbug;
+ bool m_pointbug;
- FontDatabase m_fdb;
+ FontDatabase m_fdb;
};
@@ -101,7 +103,7 @@ static int qt_version ( )
}
-OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
+OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
{
d = new OFontSelectorPrivate ( );
@@ -129,6 +131,19 @@ OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) :
d-> m_pointbug = ( qt_version ( ) <= 233 );
+ if ( withpreview ) {
+ d-> m_preview = new QMultiLineEdit ( this, "Preview" );
+ d-> m_preview-> setAlignment ( AlignCenter );
+ d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth );
+ d-> m_preview-> setMargin ( 3 );
+ d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
+ gridLayout-> addRowSpacing ( 5, 4 );
+ gridLayout-> addMultiCellWidget ( d-> m_preview, 6, 6, 0, 1 );
+ gridLayout-> setRowStretch ( 6, 5 );
+ }
+ else
+ d-> m_preview = 0;
+
loadFonts ( d-> m_font_family_list );
}
@@ -304,7 +319,12 @@ void OFontSelector::fontSizeClicked ( int /*index*/ )
void OFontSelector::changeFont ( )
{
- emit fontSelected ( selectedFont ( ));
+ QFont f = selectedFont ( );
+
+ if ( d-> m_preview )
+ d-> m_preview-> setFont ( f );
+
+ emit fontSelected ( f );
}
@@ -325,3 +345,18 @@ QFont OFontSelector::selectedFont ( )
else
return QFont ( );
}
+
+
+void OFontSelector::resizeEvent ( QResizeEvent *re )
+{
+ if ( d-> m_preview ) {
+ d-> m_preview-> setMinimumHeight ( 1 );
+ d-> m_preview-> setMaximumHeight ( 32767 );
+ }
+
+ QWidget::resizeEvent ( re );
+
+ if ( d-> m_preview )
+ d-> m_preview-> setFixedHeight ( d-> m_preview-> height ( ));
+
+}
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
Q_OBJECT
public:
- OFontSelector ( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
virtual ~OFontSelector ( );
bool selectedFont ( QString &family, QString &style, int &size );
@@ -64,6 +64,9 @@ protected slots:
virtual void fontStyleClicked ( int );
virtual void fontSizeClicked ( int );
+protected:
+ virtual void resizeEvent ( QResizeEvent *re );
+
private:
void loadFonts ( QListBox * );