Skip to content
Permalink
Browse files

Flip QgsDiagramSettings from transparency to opacity

  • Loading branch information
nyalldawson committed May 29, 2017
1 parent ac39320 commit 052b5d321c1abc754ff7a72f75fe1acd2c3a4a26
@@ -1009,6 +1009,8 @@ QgsDiagramSettings {#qgis_api_break_3_0_QgsDiagramSettings}

- The SizeType enum was removed. Use QgsUnitTypes.RenderUnit instead.
- readXml() and writeXml() do not take QgsVectorLayer as an argument anymore.
- transparency was removed. Use opacity instead.


QgsDial {#qgis_api_break_3_0_QgsDial}
-------
@@ -358,7 +358,12 @@ class QgsDiagramSettings
LabelPlacementMethod labelPlacementMethod;
DiagramOrientation diagramOrientation;
double barWidth;
int transparency; // 0 - 100

double opacity;
%Docstring
Opacity, from 0 (transparent) to 1.0 (opaque)
%End

bool scaleByArea;
int angleOffset;

@@ -94,6 +94,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
mDiagramPenColorButton->setContext( QStringLiteral( "symbology" ) );
mDiagramPenColorButton->setShowNoColor( true );
mDiagramPenColorButton->setNoColorString( tr( "Transparent stroke" ) );
mOpacitySpinBox->setClearValue( 100.0 );

mMaxValueSpinBox->setShowClearButton( false );

@@ -261,8 +262,8 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
mDiagramFont = settingList.at( 0 ).font;
QSizeF size = settingList.at( 0 ).size;
mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor );
mTransparencySpinBox->setValue( settingList.at( 0 ).transparency * 100.0 / 255.0 );
mTransparencySlider->setValue( mTransparencySpinBox->value() );
mOpacitySpinBox->setValue( settingList.at( 0 ).opacity * 100.0 );
mOpacitySlider->setValue( mOpacitySpinBox->value() * 10 );
mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
mDiagramSizeSpinBox->setValue( ( size.width() + size.height() ) / 2.0 );
@@ -404,8 +405,8 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
}

connect( mAddAttributeExpression, &QPushButton::clicked, this, &QgsDiagramProperties::showAddAttributeExpressionDialog );
connect( mTransparencySlider, &QSlider::valueChanged, mTransparencySpinBox, &QgsSpinBox::setValue );
connect( mTransparencySpinBox, static_cast < void ( QgsSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mTransparencySlider, &QSlider::setValue );
connect( mOpacitySlider, &QSlider::valueChanged, this, [ = ]( int value ) { mOpacitySpinBox->setValue( value / 10.0 ); } );
connect( mOpacitySpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) { mOpacitySlider->setValue( value * 10 ); } );

registerDataDefinedButton( mBackgroundColorDDBtn, QgsDiagramLayerSettings::BackgroundColor );
registerDataDefinedButton( mLineColorDDBtn, QgsDiagramLayerSettings::StrokeColor );
@@ -738,7 +739,7 @@ void QgsDiagramProperties::apply()
QgsDiagramSettings ds;
ds.enabled = ( mDiagramTypeComboBox->currentIndex() != 0 );
ds.font = mDiagramFont;
ds.transparency = mTransparencySpinBox->value() * 255.0 / 100.0;
ds.opacity = mOpacitySpinBox->value() / 100.0;

QList<QColor> categoryColors;
QList<QString> categoryAttributes;
@@ -749,7 +750,7 @@ void QgsDiagramProperties::apply()
for ( int i = 0; i < mDiagramAttributesTreeWidget->topLevelItemCount(); ++i )
{
QColor color = mDiagramAttributesTreeWidget->topLevelItem( i )->background( 1 ).color();
color.setAlpha( 255 - ds.transparency );
color.setAlphaF( ds.opacity );
categoryColors.append( color );
categoryAttributes.append( mDiagramAttributesTreeWidget->topLevelItem( i )->data( 0, RoleAttributeExpression ).toString() );
categoryLabels.append( mDiagramAttributesTreeWidget->topLevelItem( i )->text( 2 ) );
@@ -174,7 +174,15 @@ void QgsDiagramSettings::readXml( const QDomElement &elem )
backgroundColor.setAlpha( elem.attribute( QStringLiteral( "backgroundAlpha" ) ).toInt() );
size.setWidth( elem.attribute( QStringLiteral( "width" ) ).toDouble() );
size.setHeight( elem.attribute( QStringLiteral( "height" ) ).toDouble() );
transparency = elem.attribute( QStringLiteral( "transparency" ), QStringLiteral( "0" ) ).toInt();
if ( elem.hasAttribute( QStringLiteral( "transparency" ) ) )
{
opacity = 1 - elem.attribute( QStringLiteral( "transparency" ), QStringLiteral( "0" ) ).toInt() / 255.0;
}
else
{
opacity = elem.attribute( QStringLiteral( "opacity" ), QStringLiteral( "1.00" ) ).toDouble();
}

penColor.setNamedColor( elem.attribute( QStringLiteral( "penColor" ) ) );
int penAlpha = elem.attribute( QStringLiteral( "penAlpha" ), QStringLiteral( "255" ) ).toInt();
penColor.setAlpha( penAlpha );
@@ -261,7 +269,7 @@ void QgsDiagramSettings::readXml( const QDomElement &elem )
{
QDomElement attrElem = attributes.at( i ).toElement();
QColor newColor( attrElem.attribute( QStringLiteral( "color" ) ) );
newColor.setAlpha( 255 - transparency );
newColor.setAlphaF( opacity );
categoryColors.append( newColor );
categoryAttributes.append( attrElem.attribute( QStringLiteral( "field" ) ) );
categoryLabels.append( attrElem.attribute( QStringLiteral( "label" ) ) );
@@ -280,7 +288,7 @@ void QgsDiagramSettings::readXml( const QDomElement &elem )
for ( ; colorIt != colorList.constEnd(); ++colorIt )
{
QColor newColor( *colorIt );
newColor.setAlpha( 255 - transparency );
newColor.setAlphaF( opacity );
categoryColors.append( QColor( newColor ) );
}

@@ -311,7 +319,7 @@ void QgsDiagramSettings::writeXml( QDomElement &rendererElem, QDomDocument &doc
categoryElem.setAttribute( QStringLiteral( "scaleBasedVisibility" ), scaleBasedVisibility );
categoryElem.setAttribute( QStringLiteral( "minScaleDenominator" ), QString::number( minScaleDenominator ) );
categoryElem.setAttribute( QStringLiteral( "maxScaleDenominator" ), QString::number( maxScaleDenominator ) );
categoryElem.setAttribute( QStringLiteral( "transparency" ), QString::number( transparency ) );
categoryElem.setAttribute( QStringLiteral( "opacity" ), QString::number( opacity ) );

//diagram size unit type and scale
categoryElem.setAttribute( QStringLiteral( "sizeType" ), QgsUnitTypes::encodeUnit( sizeType ) );
@@ -372,7 +372,7 @@ class CORE_EXPORT QgsDiagramSettings
, labelPlacementMethod( QgsDiagramSettings::Height )
, diagramOrientation( QgsDiagramSettings::Up )
, barWidth( 5.0 )
, transparency( 0 )
, opacity( 1.0 )
, scaleByArea( true )
, angleOffset( 90 * 16 ) //top
, scaleBasedVisibility( false )
@@ -413,7 +413,10 @@ class CORE_EXPORT QgsDiagramSettings
LabelPlacementMethod labelPlacementMethod;
DiagramOrientation diagramOrientation;
double barWidth;
int transparency; // 0 - 100

//! Opacity, from 0 (transparent) to 1.0 (opaque)
double opacity;

bool scaleByArea;
int angleOffset;

@@ -267,7 +267,7 @@
<item>
<widget class="QStackedWidget" name="mDiagramStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="mDiagramPage_Attributes">
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -539,7 +539,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<width>630</width>
<height>484</height>
</rect>
</property>
@@ -595,14 +595,14 @@
</size>
</property>
<property name="text">
<string>Transparency</string>
<string>Opacity</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QSlider" name="mTransparencySlider">
<widget class="QSlider" name="mOpacitySlider">
<property name="enabled">
<bool>true</bool>
</property>
@@ -619,15 +619,24 @@
</size>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>100</number>
</property>
<property name="value">
<number>1000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QgsSpinBox" name="mTransparencySpinBox">
<widget class="QgsDoubleSpinBox" name="mOpacitySpinBox">
<property name="enabled">
<bool>true</bool>
</property>
@@ -637,11 +646,20 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="suffix">
<string> %</string>
</property>
<property name="maximum">
<number>100</number>
<property name="decimals">
<number>1</number>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
</widget>
</item>
@@ -2169,35 +2187,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFieldExpressionWidget</class>
<extends>QWidget</extends>
<header>qgsfieldexpressionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScaleRangeWidget</class>
<extends>QWidget</extends>
<header>qgsscalerangewidget.h</header>
</customwidget>
<customwidget>
<class>QgsColorButton</class>
<extends>QToolButton</extends>
<header>qgscolorbutton.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsPropertyOverrideButton</class>
<extends>QToolButton</extends>
<header>qgspropertyoverridebutton.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
@@ -2209,16 +2209,34 @@
<header>qgsspinbox.h</header>
</customwidget>
<customwidget>
<class>QgsPropertyOverrideButton</class>
<extends>QToolButton</extends>
<header>qgspropertyoverridebutton.h</header>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsUnitSelectionWidget</class>
<extends>QWidget</extends>
<header>qgsunitselectionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFieldExpressionWidget</class>
<extends>QWidget</extends>
<header>qgsfieldexpressionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScaleRangeWidget</class>
<extends>QWidget</extends>
<header>qgsscalerangewidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mDiagramTypeComboBox</tabstop>
@@ -2231,8 +2249,8 @@
<tabstop>mRemoveCategoryPushButton</tabstop>
<tabstop>mDiagramAttributesTreeWidget</tabstop>
<tabstop>scrollArea_4</tabstop>
<tabstop>mTransparencySlider</tabstop>
<tabstop>mTransparencySpinBox</tabstop>
<tabstop>mOpacitySlider</tabstop>
<tabstop>mOpacitySpinBox</tabstop>
<tabstop>mBarWidthSpinBox</tabstop>
<tabstop>mBackgroundColorButton</tabstop>
<tabstop>mDiagramPenColorButton</tabstop>

0 comments on commit 052b5d3

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