-rw-r--r-- | libopie/ocolorbutton.cpp | 5 | ||||
-rw-r--r-- | libopie/ofontselector.cpp | 5 | ||||
-rw-r--r-- | libopie/ofontselector.h | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/libopie/ocolorbutton.cpp b/libopie/ocolorbutton.cpp index 96e5612..4734c0c 100644 --- a/libopie/ocolorbutton.cpp +++ b/libopie/ocolorbutton.cpp | |||
@@ -30,49 +30,52 @@ | |||
30 | #include <opie/ocolorbutton.h> | 30 | #include <opie/ocolorbutton.h> |
31 | #include <qcolor.h> | 31 | #include <qcolor.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qimage.h> | 33 | #include <qimage.h> |
34 | 34 | ||
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | 36 | ||
37 | class OColorButtonPrivate { | 37 | class OColorButtonPrivate { |
38 | public: | 38 | public: |
39 | QPopupMenu *m_menu; | 39 | QPopupMenu *m_menu; |
40 | QColor m_color; | 40 | QColor m_color; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | OColorButton::OColorButton ( QWidget *parent, const char *name ) | 43 | OColorButton::OColorButton ( QWidget *parent, const char *name ) |
44 | : QPushButton ( parent, name ) | 44 | : QPushButton ( parent, name ) |
45 | { | 45 | { |
46 | d = new OColorButtonPrivate; | 46 | d = new OColorButtonPrivate; |
47 | 47 | ||
48 | d-> m_menu = new ColorPopupMenu ( black, 0, 0 ); | 48 | d-> m_menu = new ColorPopupMenu ( black, 0, 0 ); |
49 | setPopup ( d-> m_menu ); | 49 | setPopup ( d-> m_menu ); |
50 | //setPopupDelay ( 0 ); | 50 | //setPopupDelay ( 0 ); |
51 | connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & ))); | 51 | connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & ))); |
52 | 52 | ||
53 | updateColor ( black ); | 53 | updateColor ( black ); |
54 | setMinimumSize ( sizeHint ( ) + QSize ( 8, 0 )); | 54 | |
55 | QSize s = sizeHint ( ) + QSize ( 12, 0 ); | ||
56 | setMinimumSize ( s ); | ||
57 | setMaximumSize ( s. width ( ) * 2, s. height ( )); | ||
55 | } | 58 | } |
56 | 59 | ||
57 | OColorButton::~OColorButton ( ) | 60 | OColorButton::~OColorButton ( ) |
58 | { | 61 | { |
59 | delete d; | 62 | delete d; |
60 | } | 63 | } |
61 | 64 | ||
62 | QColor OColorButton::color ( ) const | 65 | QColor OColorButton::color ( ) const |
63 | { | 66 | { |
64 | return d-> m_color; | 67 | return d-> m_color; |
65 | } | 68 | } |
66 | 69 | ||
67 | void OColorButton::setColor ( const QColor &c ) | 70 | void OColorButton::setColor ( const QColor &c ) |
68 | { | 71 | { |
69 | updateColor ( c ); | 72 | updateColor ( c ); |
70 | } | 73 | } |
71 | 74 | ||
72 | void OColorButton::updateColor ( const QColor &c ) | 75 | void OColorButton::updateColor ( const QColor &c ) |
73 | { | 76 | { |
74 | d-> m_color = c; | 77 | d-> m_color = c; |
75 | 78 | ||
76 | QImage img ( 16, 16, 32 ); | 79 | QImage img ( 16, 16, 32 ); |
77 | img. fill ( 0 ); | 80 | img. fill ( 0 ); |
78 | 81 | ||
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp index d32aeb4..39440af 100644 --- a/libopie/ofontselector.cpp +++ b/libopie/ofontselector.cpp | |||
@@ -91,48 +91,53 @@ OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : | |||
91 | connect( m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); | 91 | connect( m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); |
92 | 92 | ||
93 | QLabel *label = new QLabel( tr( "Style" ), this ); | 93 | QLabel *label = new QLabel( tr( "Style" ), this ); |
94 | gridLayout->addWidget( label, 0, 1 ); | 94 | gridLayout->addWidget( label, 0, 1 ); |
95 | 95 | ||
96 | m_font_style_list = new QComboBox( this, "StyleListBox" ); | 96 | m_font_style_list = new QComboBox( this, "StyleListBox" ); |
97 | connect( m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); | 97 | connect( m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); |
98 | gridLayout->addWidget( m_font_style_list, 1, 1 ); | 98 | gridLayout->addWidget( m_font_style_list, 1, 1 ); |
99 | 99 | ||
100 | label = new QLabel( tr( "Size" ), this ); | 100 | label = new QLabel( tr( "Size" ), this ); |
101 | gridLayout->addWidget( label, 2, 1 ); | 101 | gridLayout->addWidget( label, 2, 1 ); |
102 | 102 | ||
103 | m_font_size_list = new QComboBox( this, "SizeListBox" ); | 103 | m_font_size_list = new QComboBox( this, "SizeListBox" ); |
104 | connect( m_font_size_list, SIGNAL( activated( int ) ), | 104 | connect( m_font_size_list, SIGNAL( activated( int ) ), |
105 | this, SLOT( fontSizeClicked( int ) ) ); | 105 | this, SLOT( fontSizeClicked( int ) ) ); |
106 | gridLayout->addWidget( m_font_size_list, 3, 1 ); | 106 | gridLayout->addWidget( m_font_size_list, 3, 1 ); |
107 | 107 | ||
108 | loadFonts ( m_font_family_list ); | 108 | loadFonts ( m_font_family_list ); |
109 | } | 109 | } |
110 | 110 | ||
111 | OFontSelector::~OFontSelector ( ) | 111 | OFontSelector::~OFontSelector ( ) |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | bool OFontSelector::setSelectedFont ( const QFont &f ) | ||
116 | { | ||
117 | return setSelectedFont ( f. family ( ), m_fdb. styleString ( f ), f. pointSize ( ), QFont::encodingName ( f. charSet ( ))); | ||
118 | } | ||
119 | |||
115 | bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & /*charset*/ ) | 120 | bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & /*charset*/ ) |
116 | { | 121 | { |
117 | QString sizeStr = QString::number ( sizeVal ); | 122 | QString sizeStr = QString::number ( sizeVal ); |
118 | 123 | ||
119 | QListBoxItem *family = m_font_family_list-> findItem ( familyStr ); | 124 | QListBoxItem *family = m_font_family_list-> findItem ( familyStr ); |
120 | if ( !family ) | 125 | if ( !family ) |
121 | family = m_font_family_list-> findItem ( "Helvetica" ); | 126 | family = m_font_family_list-> findItem ( "Helvetica" ); |
122 | if ( !family ) | 127 | if ( !family ) |
123 | family = m_font_family_list-> firstItem ( ); | 128 | family = m_font_family_list-> firstItem ( ); |
124 | m_font_family_list-> setCurrentItem ( family ); | 129 | m_font_family_list-> setCurrentItem ( family ); |
125 | fontFamilyClicked ( m_font_family_list-> index ( family )); | 130 | fontFamilyClicked ( m_font_family_list-> index ( family )); |
126 | 131 | ||
127 | int style = findItemCB ( m_font_style_list, styleStr ); | 132 | int style = findItemCB ( m_font_style_list, styleStr ); |
128 | if ( style < 0 ) | 133 | if ( style < 0 ) |
129 | style = findItemCB ( m_font_style_list, "Regular" ); | 134 | style = findItemCB ( m_font_style_list, "Regular" ); |
130 | if ( style < 0 && m_font_style_list-> count ( ) > 0 ) | 135 | if ( style < 0 && m_font_style_list-> count ( ) > 0 ) |
131 | style = 0; | 136 | style = 0; |
132 | m_font_style_list-> setCurrentItem ( style ); | 137 | m_font_style_list-> setCurrentItem ( style ); |
133 | fontStyleClicked ( style ); | 138 | fontStyleClicked ( style ); |
134 | 139 | ||
135 | int size = findItemCB ( m_font_size_list, sizeStr ); | 140 | int size = findItemCB ( m_font_size_list, sizeStr ); |
136 | if ( size < 0 ) | 141 | if ( size < 0 ) |
137 | size = findItemCB ( m_font_size_list, "10" ); | 142 | size = findItemCB ( m_font_size_list, "10" ); |
138 | if ( size < 0 && m_font_size_list-> count ( ) > 0 ) | 143 | if ( size < 0 && m_font_size_list-> count ( ) > 0 ) |
diff --git a/libopie/ofontselector.h b/libopie/ofontselector.h index 2011e43..b3aa862 100644 --- a/libopie/ofontselector.h +++ b/libopie/ofontselector.h | |||
@@ -28,48 +28,49 @@ | |||
28 | 28 | ||
29 | #ifndef __OPIE_FONTSELECTOR_H__ | 29 | #ifndef __OPIE_FONTSELECTOR_H__ |
30 | #define __OPIE_FONTSELECTOR_H__ | 30 | #define __OPIE_FONTSELECTOR_H__ |
31 | 31 | ||
32 | #include <qwidget.h> | 32 | #include <qwidget.h> |
33 | #include <qpe/fontdatabase.h> | 33 | #include <qpe/fontdatabase.h> |
34 | 34 | ||
35 | class QComboBox; | 35 | class QComboBox; |
36 | class QListBox; | 36 | class QListBox; |
37 | class QFont; | 37 | class QFont; |
38 | 38 | ||
39 | class OFontSelector : public QWidget | 39 | class OFontSelector : public QWidget |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | OFontSelector ( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 44 | OFontSelector ( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
45 | virtual ~OFontSelector ( ); | 45 | virtual ~OFontSelector ( ); |
46 | 46 | ||
47 | bool selectedFont ( QString &family, QString &style, int &size ); | 47 | bool selectedFont ( QString &family, QString &style, int &size ); |
48 | bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); | 48 | bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); |
49 | 49 | ||
50 | QFont selectedFont ( ); | 50 | QFont selectedFont ( ); |
51 | 51 | ||
52 | bool setSelectedFont ( const QFont & ); | ||
52 | bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); | 53 | bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); |
53 | 54 | ||
54 | QString fontFamily ( ) const; | 55 | QString fontFamily ( ) const; |
55 | QString fontStyle ( ) const; | 56 | QString fontStyle ( ) const; |
56 | int fontSize ( ) const; | 57 | int fontSize ( ) const; |
57 | QString fontCharSet ( ) const; | 58 | QString fontCharSet ( ) const; |
58 | 59 | ||
59 | signals: | 60 | signals: |
60 | void fontSelected ( const QFont & ); | 61 | void fontSelected ( const QFont & ); |
61 | 62 | ||
62 | protected slots: | 63 | protected slots: |
63 | virtual void fontFamilyClicked ( int ); | 64 | virtual void fontFamilyClicked ( int ); |
64 | virtual void fontStyleClicked ( int ); | 65 | virtual void fontStyleClicked ( int ); |
65 | virtual void fontSizeClicked ( int ); | 66 | virtual void fontSizeClicked ( int ); |
66 | 67 | ||
67 | private: | 68 | private: |
68 | void loadFonts ( QListBox * ); | 69 | void loadFonts ( QListBox * ); |
69 | 70 | ||
70 | void changeFont ( ); | 71 | void changeFont ( ); |
71 | 72 | ||
72 | private: | 73 | private: |
73 | QListBox * m_font_family_list; | 74 | QListBox * m_font_family_list; |
74 | QComboBox * m_font_style_list; | 75 | QComboBox * m_font_style_list; |
75 | QComboBox * m_font_size_list; | 76 | QComboBox * m_font_size_list; |