Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 773e0d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gui/qgscolorbutton.cpp
Expand Up @@ -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() ) );
}
Expand Down Expand Up @@ -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() )
Expand All @@ -144,6 +146,7 @@ void QgsColorButton::setColor( const QColor &color )
emit colorChanged( mColor );
}
}
mColorSet = true;
}

void QgsColorButton::setButtonBackground()
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgscolorbutton.h
Expand Up @@ -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();
Expand Down

0 comments on commit 773e0d4

Please sign in to comment.