Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[layout][ui] Fix missing opacity setting for the label font color button
  • Loading branch information
nirvn committed May 30, 2019
1 parent 2274d56 commit b3b0f5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/layout/qgslayoutlabelwidget.cpp
Expand Up @@ -54,6 +54,7 @@ QgsLayoutLabelWidget::QgsLayoutLabelWidget( QgsLayoutItemLabel *label )

mFontColorButton->setColorDialogTitle( tr( "Select Font Color" ) );
mFontColorButton->setContext( QStringLiteral( "composer" ) );
mFontColorButton->setAllowOpacity( true );

mMarginXDoubleSpinBox->setClearValue( 0.0 );
mMarginYDoubleSpinBox->setClearValue( 0.0 );
Expand Down
6 changes: 4 additions & 2 deletions src/core/layout/qgslayoutitemlabel.cpp
Expand Up @@ -363,6 +363,7 @@ bool QgsLayoutItemLabel::writePropertiesToElement( QDomElement &layoutLabelElem,
fontColorElem.setAttribute( QStringLiteral( "red" ), mFontColor.red() );
fontColorElem.setAttribute( QStringLiteral( "green" ), mFontColor.green() );
fontColorElem.setAttribute( QStringLiteral( "blue" ), mFontColor.blue() );
fontColorElem.setAttribute( QStringLiteral( "alpha" ), mFontColor.alpha() );
layoutLabelElem.appendChild( fontColorElem );

return true;
Expand Down Expand Up @@ -408,7 +409,8 @@ bool QgsLayoutItemLabel::readPropertiesFromElement( const QDomElement &itemElem,
int red = fontColorElem.attribute( QStringLiteral( "red" ), QStringLiteral( "0" ) ).toInt();
int green = fontColorElem.attribute( QStringLiteral( "green" ), QStringLiteral( "0" ) ).toInt();
int blue = fontColorElem.attribute( QStringLiteral( "blue" ), QStringLiteral( "0" ) ).toInt();
mFontColor = QColor( red, green, blue );
int alpha = fontColorElem.attribute( QStringLiteral( "alpha" ), QStringLiteral( "255" ) ).toInt();
mFontColor = QColor( red, green, blue, alpha );
}
else
{
Expand Down Expand Up @@ -580,7 +582,7 @@ QUrl QgsLayoutItemLabel::createStylesheetUrl() const
QString stylesheet;
stylesheet += QStringLiteral( "body { margin: %1 %2;" ).arg( std::max( mMarginY * mHtmlUnitsToLayoutUnits, 0.0 ) ).arg( std::max( mMarginX * mHtmlUnitsToLayoutUnits, 0.0 ) );
stylesheet += QgsFontUtils::asCSS( mFont, 0.352778 * mHtmlUnitsToLayoutUnits );
stylesheet += QStringLiteral( "color: %1;" ).arg( mFontColor.name() );
stylesheet += QStringLiteral( "color: rgba(%1,%2,%3,%4);" ).arg( mFontColor.red() ).arg( mFontColor.green() ).arg( mFontColor.blue() ).arg( QString::number( mFontColor.alphaF(), 'f', 4 ) );
stylesheet += QStringLiteral( "text-align: %1; }" ).arg( mHAlignment == Qt::AlignLeft ? QStringLiteral( "left" ) : mHAlignment == Qt::AlignRight ? QStringLiteral( "right" ) : mHAlignment == Qt::AlignHCenter ? QStringLiteral( "center" ) : QStringLiteral( "justify" ) );

QByteArray ba;
Expand Down

0 comments on commit b3b0f5d

Please sign in to comment.