From: vsr Date: Fri, 10 Feb 2012 13:27:03 +0000 (+0000) Subject: Improve look-n-fell of color button - when disabled it should be drawn in a specific way X-Git-Tag: V6_5_0a1~57 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6a19ffb4dc59117e977ec49c89f59e094c3ba1e7;p=modules%2Fgui.git Improve look-n-fell of color button - when disabled it should be drawn in a specific way --- diff --git a/src/Qtx/QtxColorButton.cxx b/src/Qtx/QtxColorButton.cxx index c7825fc47..b73ee71de 100644 --- a/src/Qtx/QtxColorButton.cxx +++ b/src/Qtx/QtxColorButton.cxx @@ -305,11 +305,13 @@ void QtxColorButton::paintEvent( QPaintEvent* e ) pix.fill( palette().color( backgroundRole() ) ); if ( color().isValid() ) - drawColor( &pix, color() ); + drawColor( &pix, isEnabled() ? color() : palette().mid().color(), isEnabled() ? Qt::black : palette().mid().color() ); else { QPainter pixp( &pix ); + pixp.setPen( palette().color( isEnabled() ? QPalette::WindowText : QPalette::Mid ) ); pixp.drawRect( 2, 2, pix.width() - 4, pix.height() - 4 ); - pixp.fillRect( 3, 3, pix.width() - 6, pix.height() - 6, QBrush( Qt::BDiagPattern ) ); + pixp.fillRect( 3, 3, pix.width() - 6, pix.height() - 6, + QBrush( palette().color( isEnabled() ? QPalette::WindowText : QPalette::Mid ), Qt::BDiagPattern ) ); pixp.end(); } @@ -380,13 +382,13 @@ QPixmap QtxColorButton::buttonIcon( const QColor& c ) const \param c color \param m margin */ -void QtxColorButton::drawColor( QPaintDevice* pd, const QColor& c, const int m ) const +void QtxColorButton::drawColor( QPaintDevice* pd, const QColor& c, const QColor& bc, const int m ) const { if ( !pd ) return; QPainter p( pd ); - p.setPen( Qt::black ); + p.setPen( bc ); p.fillRect( m, m, pd->width() - 2 * m - 1, pd->height() - 2 * m - 1, QBrush( c ) ); p.drawRect( m, m, pd->width() - 2 * m - 1, pd->height() - 2 * m - 1 ); p.end(); diff --git a/src/Qtx/QtxColorButton.h b/src/Qtx/QtxColorButton.h index 75eb4f301..f8cb2da2b 100644 --- a/src/Qtx/QtxColorButton.h +++ b/src/Qtx/QtxColorButton.h @@ -72,7 +72,7 @@ private: void updateState(); void updateButton( QToolButton* ); QPixmap buttonIcon( const QColor& ) const; - void drawColor( QPaintDevice*, const QColor&, const int = 1 ) const; + void drawColor( QPaintDevice*, const QColor&, const QColor& = Qt::black, const int = 1 ) const; private: typedef QMap ColorMap;