Skip to content
Permalink
Browse files

[gui] Fix color button where initially set color is same as default, …

…but does not set background of button
  • Loading branch information
dakcarto committed Sep 16, 2013
1 parent 2d728d7 commit 773e0d49f15355de03a90b756068f863259357f0
Showing with 5 additions and 1 deletion.
  1. +4 −1 src/gui/qgscolorbutton.cpp
  2. +1 −0 src/gui/qgscolorbutton.h
@@ -45,6 +45,7 @@ QgsColorButton::QgsColorButton( QWidget *parent, QString cdt, QColorDialog::Colo
, mColorDialogOptions( cdo )
, mAcceptLiveUpdates( true )
, mTempPNG( NULL )
, mColorSet( false )
{
connect( this, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
}
@@ -134,7 +135,8 @@ void QgsColorButton::setColor( const QColor &color )
QColor oldColor = mColor;
mColor = color;

if ( oldColor != mColor )
// handle when initially set color is same as default (Qt::black); consider it a color change
if ( oldColor != mColor || ( mColor == QColor( Qt::black ) && !mColorSet ) )
{
setButtonBackground();
if ( isEnabled() )
@@ -144,6 +146,7 @@ void QgsColorButton::setColor( const QColor &color )
emit colorChanged( mColor );
}
}
mColorSet = true;
}

void QgsColorButton::setButtonBackground()
@@ -140,6 +140,7 @@ class GUI_EXPORT QgsColorButton: public QPushButton
QColorDialog::ColorDialogOptions mColorDialogOptions;
bool mAcceptLiveUpdates;
QTemporaryFile mTempPNG;
bool mColorSet; // added in QGIS 2.1

private slots:
void onButtonClicked();

0 comments on commit 773e0d4

Please sign in to comment.
You can’t perform that action at this time.