author | zecke <zecke> | 2004-09-12 16:07:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-12 16:07:13 (UTC) |
commit | 36a4f75e1f4e5a3858749779ea26a3fe3154d1f0 (patch) (unidiff) | |
tree | 18a61aedb81a9823cbf212cc82662c66101133f7 | |
parent | 12730b959f92a9d601d81bf28ab87fb265effe55 (diff) | |
download | opie-36a4f75e1f4e5a3858749779ea26a3fe3154d1f0.zip opie-36a4f75e1f4e5a3858749779ea26a3fe3154d1f0.tar.gz opie-36a4f75e1f4e5a3858749779ea26a3fe3154d1f0.tar.bz2 |
Do not limit the Image to 16x16 but use width() and height()
+ magic numbers to make the Image fit the button
-rw-r--r-- | libqtaux/ocolorbutton.cpp | 12 | ||||
-rw-r--r-- | libqtaux/ocolorbutton.h | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/libqtaux/ocolorbutton.cpp b/libqtaux/ocolorbutton.cpp index 9e41d93..925df7f 100644 --- a/libqtaux/ocolorbutton.cpp +++ b/libqtaux/ocolorbutton.cpp | |||
@@ -56,21 +56,21 @@ OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *n | |||
56 | { | 56 | { |
57 | d = new OColorButtonPrivate; | 57 | d = new OColorButtonPrivate; |
58 | 58 | ||
59 | d-> m_menu = new OColorPopupMenu ( color, 0, 0 ); | 59 | d-> m_menu = new OColorPopupMenu ( color, 0, 0 ); |
60 | setPopup ( d-> m_menu ); | 60 | setPopup ( d-> m_menu ); |
61 | //setPopupDelay ( 0 ); | 61 | //setPopupDelay ( 0 ); |
62 | connect ( d-> m_menu, SIGNAL( colorSelected(const QColor&)), this, SLOT( updateColor(const QColor&))); | 62 | connect ( d-> m_menu, SIGNAL( colorSelected(const QColor&)), this, SLOT( updateColor(const QColor&))); |
63 | 63 | ||
64 | updateColor ( color ); | ||
65 | 64 | ||
66 | QSize s = sizeHint ( ) + QSize ( 12, 0 ); | 65 | QSize s = sizeHint ( ) + QSize ( 12, 0 ); |
67 | setMinimumSize ( s ); | 66 | setMinimumSize ( s ); |
68 | setMaximumSize ( s. width ( ) * 2, s. height ( )); | 67 | setMaximumSize ( s. width ( ) * 2, s. height ( )); |
68 | d->m_color = color; | ||
69 | } | 69 | } |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * This destructs the object | 72 | * This destructs the object |
73 | */ | 73 | */ |
74 | OColorButton::~OColorButton ( ) | 74 | OColorButton::~OColorButton ( ) |
75 | { | 75 | { |
76 | delete d; | 76 | delete d; |
@@ -95,17 +95,17 @@ void OColorButton::setColor ( const QColor &c ) | |||
95 | 95 | ||
96 | /** | 96 | /** |
97 | * @internal | 97 | * @internal |
98 | */ | 98 | */ |
99 | void OColorButton::updateColor ( const QColor &c ) | 99 | void OColorButton::updateColor ( const QColor &c ) |
100 | { | 100 | { |
101 | d-> m_color = c; | 101 | d-> m_color = c; |
102 | 102 | ||
103 | QImage img ( 16, 16, 32 ); | 103 | QImage img ( width()-14, height()-6, 32 ); |
104 | img. fill ( 0 ); | 104 | img. fill ( 0 ); |
105 | 105 | ||
106 | int r, g, b; | 106 | int r, g, b; |
107 | c. rgb ( &r, &g, &b ); | 107 | c. rgb ( &r, &g, &b ); |
108 | 108 | ||
109 | int w = img. width ( ); | 109 | int w = img. width ( ); |
110 | int h = img. height ( ); | 110 | int h = img. height ( ); |
111 | 111 | ||
@@ -140,8 +140,16 @@ void OColorButton::updateColor ( const QColor &c ) | |||
140 | 140 | ||
141 | QPixmap pix; | 141 | QPixmap pix; |
142 | pix. convertFromImage ( img ); | 142 | pix. convertFromImage ( img ); |
143 | setPixmap ( pix ); | 143 | setPixmap ( pix ); |
144 | 144 | ||
145 | emit colorSelected ( c ); | 145 | emit colorSelected ( c ); |
146 | } | 146 | } |
147 | 147 | ||
148 | |||
149 | /** | ||
150 | * @internal | ||
151 | */ | ||
152 | void OColorButton::resizeEvent( QResizeEvent *ev ) { | ||
153 | QPushButton::resizeEvent( ev ); | ||
154 | updateColor(d->m_color); | ||
155 | } | ||
diff --git a/libqtaux/ocolorbutton.h b/libqtaux/ocolorbutton.h index ca68f1f..10b77d5 100644 --- a/libqtaux/ocolorbutton.h +++ b/libqtaux/ocolorbutton.h | |||
@@ -49,16 +49,19 @@ namespace Opie | |||
49 | class OColorButton : public QPushButton | 49 | class OColorButton : public QPushButton |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 ); | 53 | OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 ); |
54 | virtual ~OColorButton ( ); | 54 | virtual ~OColorButton ( ); |
55 | 55 | ||
56 | QColor color ( ) const; | 56 | QColor color ( ) const; |
57 | |||
58 | protected: | ||
59 | void resizeEvent( QResizeEvent* ); | ||
57 | 60 | ||
58 | signals: | 61 | signals: |
59 | /** | 62 | /** |
60 | * emitted when a color gets selected | 63 | * emitted when a color gets selected |
61 | */ | 64 | */ |
62 | void colorSelected ( const QColor & ); | 65 | void colorSelected ( const QColor & ); |
63 | 66 | ||
64 | public slots: | 67 | public slots: |