Skip to content
Permalink
Browse files

Add an edit button for shapeburst and gradient color ramps

  • Loading branch information
nyalldawson committed Aug 25, 2014
1 parent 8224a16 commit 1f6dd8e5a7297229deef09653435cf87053b6d1b
@@ -134,6 +134,7 @@ class QgsGradientFillSymbolLayerV2Widget : QgsSymbolLayerV2Widget
void setColor( const QColor& color );
void setColor2( const QColor& color );
void applyColorRamp();
void on_mButtonEditRamp_clicked();
void setGradientType( int index );
void setCoordinateMode( int index );
void setGradientSpread( int index );
@@ -170,6 +171,7 @@ class QgsShapeburstFillSymbolLayerV2Widget : QgsSymbolLayerV2Widget
void on_mDistanceUnitWidget_changed( );
void on_mRadioUseWholeShape_toggled( bool value );
void applyColorRamp();
void on_mButtonEditRamp_clicked();
void offsetChanged();
void on_mOffsetUnitWidget_changed( );
void on_mDataDefinedPropertiesButton_clicked();
@@ -26,6 +26,8 @@
#include "qgssymbolv2selectordialog.h"
#include "qgssvgcache.h"
#include "qgssymbollayerv2utils.h"
#include "qgsvectorcolorrampv2.h"
#include "qgsvectorgradientcolorrampv2dialog.h"

#include "qgsstylev2.h" //for symbol selector dialog

@@ -959,6 +961,29 @@ void QgsGradientFillSymbolLayerV2Widget::applyColorRamp()
emit changed();
}

void QgsGradientFillSymbolLayerV2Widget::on_mButtonEditRamp_clicked()
{
if ( mLayer->colorRamp()->type() == "gradient" )
{
QgsVectorColorRampV2* ramp = mLayer->colorRamp()->clone();
QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );

if ( dlg.exec() && gradRamp )
{
mLayer->setColorRamp( gradRamp );
cboGradientColorRamp->blockSignals( true );
cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
cboGradientColorRamp->blockSignals( false );
emit changed();
}
else
{
delete ramp;
}
}
}

void QgsGradientFillSymbolLayerV2Widget::setGradientType( int index )
{
switch ( index )
@@ -1325,6 +1350,29 @@ void QgsShapeburstFillSymbolLayerV2Widget::applyColorRamp()
emit changed();
}

void QgsShapeburstFillSymbolLayerV2Widget::on_mButtonEditRamp_clicked()
{
if ( mLayer->colorRamp()->type() == "gradient" )
{
QgsVectorColorRampV2* ramp = mLayer->colorRamp()->clone();
QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );

if ( dlg.exec() && gradRamp )
{
mLayer->setColorRamp( gradRamp );
cboGradientColorRamp->blockSignals( true );
cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
cboGradientColorRamp->blockSignals( false );
emit changed();
}
else
{
delete ramp;
}
}
}

void QgsShapeburstFillSymbolLayerV2Widget::offsetChanged()
{
if ( mLayer )
@@ -182,6 +182,7 @@ class GUI_EXPORT QgsGradientFillSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
void setColor( const QColor& color );
void setColor2( const QColor& color );
void applyColorRamp();
void on_mButtonEditRamp_clicked();
void setGradientType( int index );
void setCoordinateMode( int index );
void setGradientSpread( int index );
@@ -224,6 +225,7 @@ class GUI_EXPORT QgsShapeburstFillSymbolLayerV2Widget : public QgsSymbolLayerV2W
void on_mDistanceUnitWidget_changed( );
void on_mRadioUseWholeShape_toggled( bool value );
void applyColorRamp();
void on_mButtonEditRamp_clicked();
void offsetChanged();
void on_mOffsetUnitWidget_changed( );
void on_mDataDefinedPropertiesButton_clicked();
@@ -14,21 +14,12 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<property name="horizontalSpacing">
<number>28</number>
</property>
<property name="margin">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radioTwoColor">
<property name="text">
@@ -102,7 +93,24 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QgsColorRampComboBox" name="cboGradientColorRamp"/>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QgsColorRampComboBox" name="cboGradientColorRamp"/>
</item>
<item>
<widget class="QPushButton" name="mButtonEditRamp">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
@@ -408,7 +416,7 @@
</widget>
</item>
<item>
<widget class="QgsUnitSelectionWidget" name="mOffsetUnitWidget"/>
<widget class="QgsUnitSelectionWidget" name="mOffsetUnitWidget" native="true"/>
</item>
</layout>
</item>
@@ -448,7 +456,7 @@
</customwidget>
<customwidget>
<class>QgsUnitSelectionWidget</class>
<extends>QComboBox</extends>
<extends>QWidget</extends>
<header>qgsunitselectionwidget.h</header>
<container>1</container>
</customwidget>
@@ -90,7 +90,24 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QgsColorRampComboBox" name="cboGradientColorRamp"/>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QgsColorRampComboBox" name="cboGradientColorRamp"/>
</item>
<item>
<widget class="QPushButton" name="mButtonEditRamp">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

0 comments on commit 1f6dd8e

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