Skip to content
Permalink
Browse files

Fix api break, unit test

  • Loading branch information
nyalldawson committed May 11, 2018
1 parent 0708d84 commit 06d7725cca7643b1d6d6b18b64b1f9e178aaaebc
@@ -574,6 +574,19 @@ void QgsLayoutItemScaleBar::setFont( const QFont &font )
emit changed();
}

QColor QgsLayoutItemScaleBar::fontColor() const
{
QColor color = mSettings.textFormat().color();
color.setAlphaF( mSettings.textFormat().opacity() );
return color;
}

void QgsLayoutItemScaleBar::setFontColor( const QColor &color )
{
mSettings.textFormat().setColor( color );
mSettings.textFormat().setOpacity( color.alphaF() );
}

bool QgsLayoutItemScaleBar::writePropertiesToElement( QDomElement &composerScaleBarElem, QDomDocument &doc, const QgsReadWriteContext &rwContext ) const
{
composerScaleBarElem.setAttribute( QStringLiteral( "height" ), QString::number( mSettings.height() ) );
@@ -208,15 +208,15 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem
* \see font()
* \deprecated use textFormat() instead
*/
Q_DECL_DEPRECATED QColor fontColor() const SIP_DEPRECATED { return mSettings.textFormat().color(); }
Q_DECL_DEPRECATED QColor fontColor() const SIP_DEPRECATED;

/**
* Sets the \a color used for drawing text in the scalebar.
* \see fontColor()
* \see setFont()
* \deprecated use setTextFormat() instead
*/
Q_DECL_DEPRECATED void setFontColor( const QColor &color ) SIP_DEPRECATED { mSettings.textFormat().setColor( color ); }
Q_DECL_DEPRECATED void setFontColor( const QColor &color ) SIP_DEPRECATED;

/**
* Returns the color used for fills in the scalebar.
@@ -142,7 +142,8 @@ void TestQgsLayoutScaleBar::singleBoxAlpha()
l.addLayoutItem( scalebar );
scalebar->setLinkedMap( map );
QgsTextFormat format = QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont() );
format.setColor( QColor( 255, 0, 255, 100 ) );
format.setColor( QColor( 255, 0, 255 ) );
format.setOpacity( 100.0 / 255 );
scalebar->setTextFormat( format );
scalebar->setUnits( QgsUnitTypes::DistanceMeters );
scalebar->setUnitsPerSegment( 2000 );

0 comments on commit 06d7725

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