Skip to content

Commit

Permalink
Fix parsing of #rrggbbaa colors under Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 18, 2016
1 parent 81d4d08 commit da635d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion ci/travis/linux/qt5/blacklist.txt
Expand Up @@ -16,7 +16,6 @@ qgis_painteffecttest
qgis_pointpatternfillsymboltest
qgis_simplemarkertest
qgis_svgmarkertest
qgis_symbolv2test
qgis_fieldexpressionwidget
qgis_alignrastertest
PyQgsAnalysis
Expand Down
10 changes: 6 additions & 4 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Expand Up @@ -3243,8 +3243,11 @@ QColor QgsSymbolLayerV2Utils::parseColorWithAlpha( const QString& colorStr, bool
{
QColor parsedColor;

//color in hex format "#aabbcc"
if ( QColor::isValidColor( colorStr ) )
QRegExp hexColorAlphaRx( "^\\s*#?([0-9a-fA-F]{6})([0-9a-fA-F]{2})\\s*$" );
int hexColorIndex = hexColorAlphaRx.indexIn( colorStr );

//color in hex format "#aabbcc", but not #aabbccdd
if ( hexColorIndex == -1 && QColor::isValidColor( colorStr ) )
{
//string is a valid hex color string
parsedColor.setNamedColor( colorStr );
Expand All @@ -3256,8 +3259,7 @@ QColor QgsSymbolLayerV2Utils::parseColorWithAlpha( const QString& colorStr, bool
}

//color in hex format, with alpha
QRegExp hexColorAlphaRx( "^\\s*#?([0-9a-fA-F]{6})([0-9a-fA-F]{2})\\s*$" );
if ( hexColorAlphaRx.indexIn( colorStr ) != -1 )
if ( hexColorIndex > -1 )
{
QString hexColor = hexColorAlphaRx.cap( 1 );
parsedColor.setNamedColor( QString( "#" ) + hexColor );
Expand Down

0 comments on commit da635d4

Please sign in to comment.