Skip to content
Permalink
Browse files

Add possibility to select outline / fill transparency for composer sh…

…apes in color dialog. Make item fill/outline transparent white for composer shapes by default

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12237 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Nov 24, 2009
1 parent b1d5445 commit 5ef62a9a5f62704a0a21ee0699a041a9b654276c
@@ -124,7 +124,7 @@ void QgsComposerShapeWidget::on_mOutlineColorButton_clicked()
return;
}
QColor existingColor = mComposerShape->outlineColor();
QColor newColor = QColorDialog::getColor( existingColor, 0 );
QColor newColor = QColorDialog::getColor( existingColor, 0, tr( "Select outline color" ), QColorDialog::ShowAlphaChannel );
if ( newColor.isValid() )
{
mComposerShape->setOutlineColor( newColor );
@@ -169,7 +169,7 @@ void QgsComposerShapeWidget::on_mFillColorButton_clicked()
return;
}
QColor existingColor = mComposerShape->fillColor();
QColor newColor = QColorDialog::getColor( existingColor, 0 );
QColor newColor = QColorDialog::getColor( existingColor, 0, tr( "Select fill color" ), QColorDialog::ShowAlphaChannel );
if ( newColor.isValid() )
{
mComposerShape->setFillColor( newColor );
@@ -20,13 +20,13 @@

QgsComposerShape::QgsComposerShape( QgsComposition* composition ): QgsComposerItem( composition ), mShape( Ellipse )
{
initBrushAndPen();
initGraphicsSettings();
}

QgsComposerShape::QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition ), mShape( Ellipse )
{
setSceneRect( QRectF( x, y, width, height ) );
initBrushAndPen();
initGraphicsSettings();
}

QgsComposerShape::~QgsComposerShape()
@@ -93,11 +93,13 @@ bool QgsComposerShape::writeXML( QDomElement& elem, QDomDocument & doc ) const
outlineColorElem.setAttribute( "red", mPen.color().red() );
outlineColorElem.setAttribute( "green", mPen.color().green() );
outlineColorElem.setAttribute( "blue", mPen.color().blue() );
outlineColorElem.setAttribute( "alpha", mPen.color().alpha() );
composerShapeElem.appendChild( outlineColorElem );
QDomElement fillColorElem = doc.createElement( "FillColor" );
fillColorElem.setAttribute( "red", mBrush.color().red() );
fillColorElem.setAttribute( "green", mBrush.color().green() );
fillColorElem.setAttribute( "blue", mBrush.color().blue() );
fillColorElem.setAttribute( "alpha", mBrush.color().alpha() );
composerShapeElem.appendChild( fillColorElem );
elem.appendChild( composerShapeElem );
return _writeXML( composerShapeElem, doc );
@@ -127,7 +129,8 @@ bool QgsComposerShape::readXML( const QDomElement& itemElem, const QDomDocument&
int penRed = outlineColorElem.attribute( "red", "0" ).toInt();
int penGreen = outlineColorElem.attribute( "green", "0" ).toInt();
int penBlue = outlineColorElem.attribute( "blue", "0" ).toInt();
mPen.setColor( QColor( penRed, penGreen, penBlue ) );
int penAlpha = outlineColorElem.attribute( "alpha", "255" ).toInt();
mPen.setColor( QColor( penRed, penGreen, penBlue, penAlpha ) );
}

//fill color
@@ -138,7 +141,8 @@ bool QgsComposerShape::readXML( const QDomElement& itemElem, const QDomDocument&
int brushRed = fillColorElem.attribute( "red", "0" ).toInt();
int brushGreen = fillColorElem.attribute( "green", "0" ).toInt();
int brushBlue = fillColorElem.attribute( "blue", "0" ).toInt();
mBrush.setColor( QColor( brushRed, brushGreen, brushBlue ) );
int brushAlpha = fillColorElem.attribute( "alpha", "255" ).toInt();
mBrush.setColor( QColor( brushRed, brushGreen, brushBlue, brushAlpha ) );
}


@@ -199,11 +203,15 @@ void QgsComposerShape::setTransparentFill( bool transparent )
}
}

void QgsComposerShape::initBrushAndPen()
void QgsComposerShape::initGraphicsSettings()
{
mPen.setColor( QColor( 0, 0, 0 ) );
mPen.setWidthF( 1 );
mPen.setJoinStyle( Qt::RoundJoin );
mBrush.setColor( QColor( 0, 0, 0 ) );
mBrush.setStyle( Qt::NoBrush );

//set composer item brush and pen to transparent white by default
setPen( QPen( QColor( 255, 255, 255, 0 ) ) );
setBrush( QBrush( QColor( 255, 255, 255, 0 ) ) );
}
@@ -70,8 +70,9 @@ class CORE_EXPORT QgsComposerShape: public QgsComposerItem
QPen mPen;
/**Shape fill*/
QBrush mBrush;

/**Apply default graphics settings*/
void initBrushAndPen();
void initGraphicsSettings();

/**Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point*/
QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;

0 comments on commit 5ef62a9

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