From 36a4f75e1f4e5a3858749779ea26a3fe3154d1f0 Mon Sep 17 00:00:00 2001 From: zecke Date: Sun, 12 Sep 2004 16:07:13 +0000 Subject: Do not limit the Image to 16x16 but use width() and height() + magic numbers to make the Image fit the button --- (limited to 'libqtaux') diff --git a/libqtaux/ocolorbutton.cpp b/libqtaux/ocolorbutton.cpp index 9e41d93..925df7f 100644 --- a/libqtaux/ocolorbutton.cpp +++ b/libqtaux/ocolorbutton.cpp @@ -61,11 +61,11 @@ OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *n // setPopupDelay ( 0 ); connect ( d-> m_menu, SIGNAL( colorSelected(const QColor&)), this, SLOT( updateColor(const QColor&))); - updateColor ( color ); QSize s = sizeHint ( ) + QSize ( 12, 0 ); setMinimumSize ( s ); setMaximumSize ( s. width ( ) * 2, s. height ( )); + d->m_color = color; } /** @@ -100,7 +100,7 @@ void OColorButton::updateColor ( const QColor &c ) { d-> m_color = c; - QImage img ( 16, 16, 32 ); + QImage img ( width()-14, height()-6, 32 ); img. fill ( 0 ); int r, g, b; @@ -145,3 +145,11 @@ void OColorButton::updateColor ( const QColor &c ) emit colorSelected ( c ); } + +/** + * @internal + */ +void OColorButton::resizeEvent( QResizeEvent *ev ) { + QPushButton::resizeEvent( ev ); + updateColor(d->m_color); +} diff --git a/libqtaux/ocolorbutton.h b/libqtaux/ocolorbutton.h index ca68f1f..10b77d5 100644 --- a/libqtaux/ocolorbutton.h +++ b/libqtaux/ocolorbutton.h @@ -54,6 +54,9 @@ public: virtual ~OColorButton ( ); QColor color ( ) const; + +protected: + void resizeEvent( QResizeEvent* ); signals: /** -- cgit v0.9.0.2