[QGIS Commit] r12237 - in trunk/qgis/src: app/composer core/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Nov 24 02:55:08 EST 2009
Author: mhugent
Date: 2009-11-24 02:55:03 -0500 (Tue, 24 Nov 2009)
New Revision: 12237
Modified:
trunk/qgis/src/app/composer/qgscomposershapewidget.cpp
trunk/qgis/src/core/composer/qgscomposershape.cpp
trunk/qgis/src/core/composer/qgscomposershape.h
Log:
Add possibility to select outline / fill transparency for composer shapes in color dialog. Make item fill/outline transparent white for composer shapes by default
Modified: trunk/qgis/src/app/composer/qgscomposershapewidget.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposershapewidget.cpp 2009-11-23 21:22:31 UTC (rev 12236)
+++ trunk/qgis/src/app/composer/qgscomposershapewidget.cpp 2009-11-24 07:55:03 UTC (rev 12237)
@@ -124,7 +124,7 @@
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 @@
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 );
Modified: trunk/qgis/src/core/composer/qgscomposershape.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposershape.cpp 2009-11-23 21:22:31 UTC (rev 12236)
+++ trunk/qgis/src/core/composer/qgscomposershape.cpp 2009-11-24 07:55:03 UTC (rev 12237)
@@ -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 @@
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 @@
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 @@
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::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 ) ) );
}
Modified: trunk/qgis/src/core/composer/qgscomposershape.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposershape.h 2009-11-23 21:22:31 UTC (rev 12236)
+++ trunk/qgis/src/core/composer/qgscomposershape.h 2009-11-24 07:55:03 UTC (rev 12237)
@@ -70,8 +70,9 @@
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;
More information about the QGIS-commit
mailing list