Skip to content

Commit

Permalink
Use faster QColor constructor with r/g/b parameters
Browse files Browse the repository at this point in the history
The QString based constructor is slow, as the string must
be parsed to interpret the color.

Thanks to Clazy
  • Loading branch information
nyalldawson committed Aug 29, 2017
1 parent 3abd0fa commit 5247478
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
20 changes: 10 additions & 10 deletions src/core/qgscolorscheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ QgsNamedColorList QgsCustomColorScheme::fetchColors( const QString &context, con
if ( !settings.contains( QStringLiteral( "/colors/palettecolors" ) ) )
{
//no custom palette, return default colors
colorList.append( qMakePair( QColor( "#000000" ), QString() ) );
colorList.append( qMakePair( QColor( "#ffffff" ), QString() ) );
colorList.append( qMakePair( QColor( "#a6cee3" ), QString() ) );
colorList.append( qMakePair( QColor( "#1f78b4" ), QString() ) );
colorList.append( qMakePair( QColor( "#b2df8a" ), QString() ) );
colorList.append( qMakePair( QColor( "#33a02c" ), QString() ) );
colorList.append( qMakePair( QColor( "#fb9a99" ), QString() ) );
colorList.append( qMakePair( QColor( "#e31a1c" ), QString() ) );
colorList.append( qMakePair( QColor( "#fdbf6f" ), QString() ) );
colorList.append( qMakePair( QColor( "#ff7f00" ), QString() ) );
colorList.append( qMakePair( QColor( 0, 0, 0 ), QString() ) );
colorList.append( qMakePair( QColor( 255, 255, 255 ), QString() ) );
colorList.append( qMakePair( QColor( 166, 206, 227 ), QString() ) );
colorList.append( qMakePair( QColor( 31, 120, 180 ), QString() ) );
colorList.append( qMakePair( QColor( 178, 223, 138 ), QString() ) );
colorList.append( qMakePair( QColor( 51, 160, 44 ), QString() ) );
colorList.append( qMakePair( QColor( 251, 154, 153 ), QString() ) );
colorList.append( qMakePair( QColor( 227, 26, 28 ), QString() ) );
colorList.append( qMakePair( QColor( 253, 191, 111 ), QString() ) );
colorList.append( qMakePair( QColor( 255, 127, 0 ), QString() ) );

return colorList;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology/qgs25drenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ Qgs25DRenderer::Qgs25DRenderer()

// These methods must only be used after the above initialization!

setRoofColor( QColor( "#b1a97c" ) );
setWallColor( QColor( "#777777" ) );
setRoofColor( QColor( 177, 169, 124 ) );
setWallColor( QColor( 119, 119, 119 ) );

wallLayer()->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty::fromExpression( QString( WALL_SHADING_EXPRESSION ) ) );

setShadowSpread( 4 );
setShadowColor( QColor( "#111111" ) );
setShadowColor( QColor( 17, 17, 17 ) );

QgsFeatureRequest::OrderBy orderBy;
orderBy << QgsFeatureRequest::OrderByClause(
Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ bool QgsSymbolLayerUtils::fillFromSld( QDomElement &element, Qt::BrushStyle &bru
QgsDebugMsg( "Entered." );

brushStyle = Qt::SolidPattern;
color = QColor( "#808080" );
color = QColor( 128, 128, 128 );

if ( element.isNull() )
{
Expand Down Expand Up @@ -1875,7 +1875,7 @@ bool QgsSymbolLayerUtils::lineFromSld( QDomElement &element,
QgsDebugMsg( "Entered." );

penStyle = Qt::SolidLine;
color = QColor( "#000000" );
color = QColor( 0, 0, 0 );
width = 1;
if ( penJoinStyle )
*penJoinStyle = Qt::BevelJoin;
Expand Down Expand Up @@ -2224,7 +2224,7 @@ bool QgsSymbolLayerUtils::wellKnownMarkerFromSld( QDomElement &element,

name = QStringLiteral( "square" );
color = QColor();
strokeColor = QColor( "#000000" );
strokeColor = QColor( 0, 0, 0 );
strokeWidth = 1;
size = 6;

Expand Down
10 changes: 5 additions & 5 deletions src/gui/qgscodeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ void QgsCodeEditor::setSciWidget()
{
setUtf8( true );
setCaretLineVisible( true );
setCaretLineBackgroundColor( QColor( "#fcf3ed" ) );
setCaretLineBackgroundColor( QColor( 252, 243, 237 ) );

setBraceMatching( QsciScintilla::SloppyBraceMatch );
setMatchedBraceBackgroundColor( QColor( "#b7f907" ) );
setMatchedBraceBackgroundColor( QColor( 183, 249, 7 ) );
// whether margin will be shown
setMarginVisible( mMargin );
// whether margin will be shown
Expand Down Expand Up @@ -121,8 +121,8 @@ void QgsCodeEditor::setMarginVisible( bool margin )
setMarginLineNumbers( 1, true );
setMarginsFont( marginFont );
setMarginWidth( 1, QStringLiteral( "00000" ) );
setMarginsForegroundColor( QColor( "#3E3EE3" ) );
setMarginsBackgroundColor( QColor( "#f9f9f9" ) );
setMarginsForegroundColor( QColor( 62, 62, 227 ) );
setMarginsBackgroundColor( QColor( 249, 249, 249 ) );
}
else
{
Expand All @@ -138,7 +138,7 @@ void QgsCodeEditor::setFoldingVisible( bool folding )
if ( folding )
{
setFolding( QsciScintilla::PlainFoldStyle );
setFoldMarginColors( QColor( "#f4f4f4" ), QColor( "#f4f4f4" ) );
setFoldMarginColors( QColor( 244, 244, 244 ), QColor( 244, 244, 244 ) );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgscodeeditorpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void QgsCodeEditorPython::setSciLexerPython()

setEdgeMode( QsciScintilla::EdgeLine );
setEdgeColumn( 80 );
setEdgeColor( QColor( "#FF0000" ) );
setEdgeColor( QColor( 255, 0, 0 ) );

setWhitespaceVisibility( QsciScintilla::WsVisibleAfterIndent );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsexpressionbuilderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void QgsExpressionBuilderWidget::registerItem( const QString &group,
//Recent group should always be last group
newgroupNode->setData( group.startsWith( QLatin1String( "Recent (" ) ) ? 2 : 1, QgsExpressionItem::CUSTOM_SORT_ROLE );
newgroupNode->appendRow( item );
newgroupNode->setBackground( QBrush( QColor( "#eee" ) ) );
newgroupNode->setBackground( QBrush( QColor( 238, 238, 238 ) ) );
mModel->appendRow( newgroupNode );
mExpressionGroups.insert( group, newgroupNode );
}
Expand Down

0 comments on commit 5247478

Please sign in to comment.