Skip to content

Commit

Permalink
[symbology] migrate shapeburst color ramp widget
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Dec 3, 2016
1 parent 1560c7f commit aa4d751
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 59 deletions.
17 changes: 8 additions & 9 deletions src/gui/symbology-ng/qgssymbollayerwidget.cpp
Expand Up @@ -28,6 +28,7 @@
#include "qgssvgcache.h"
#include "qgssymbollayerutils.h"
#include "qgscolorramp.h"
#include "qgscolorrampbutton.h"
#include "qgsgradientcolorrampdialog.h"
#include "qgsdatadefined.h"
#include "qgsstyle.h" //for symbol selector dialog
Expand Down Expand Up @@ -1360,11 +1361,9 @@ QgsShapeburstFillSymbolLayerWidget::QgsShapeburstFillSymbolLayerWidget( const Qg
spinOffsetX->setClearValue( 0.0 );
spinOffsetY->setClearValue( 0.0 );

cboGradientColorRamp->populate( QgsStyle::defaultStyle() );
btnColorRamp->setShowGradientOnly( true );

connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );

connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
Expand Down Expand Up @@ -1395,7 +1394,7 @@ void QgsShapeburstFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* layer )
if ( mLayer->colorType() == QgsShapeburstFillSymbolLayer::SimpleTwoColor )
{
radioTwoColor->setChecked( true );
cboGradientColorRamp->setEnabled( false );
btnColorRamp->setEnabled( false );
}
else
{
Expand Down Expand Up @@ -1444,9 +1443,9 @@ void QgsShapeburstFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* layer )
// set source color ramp
if ( mLayer->colorRamp() )
{
cboGradientColorRamp->blockSignals( true );
cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
cboGradientColorRamp->blockSignals( false );
btnColorRamp->blockSignals( true );
btnColorRamp->setColorRamp( mLayer->colorRamp() );
btnColorRamp->blockSignals( false );
}

spinOffsetX->blockSignals( true );
Expand Down Expand Up @@ -1549,7 +1548,7 @@ void QgsShapeburstFillSymbolLayerWidget::on_mRadioUseWholeShape_toggled( bool va

void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
{
QgsColorRamp* ramp = cboGradientColorRamp->currentColorRamp();
QgsColorRamp* ramp = btnColorRamp->colorRamp();
if ( !ramp )
return;

Expand Down
44 changes: 20 additions & 24 deletions src/ui/symbollayer/widget_gradientfill.ui
Expand Up @@ -150,30 +150,26 @@
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QgsColorRampButton" name="btnColorRamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
<widget class="QgsColorRampButton" name="btnColorRamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="8" column="2" rowspan="2">
<widget class="QgsDataDefinedButton" name="mRefPoint1YDDBtn">
Expand Down
54 changes: 28 additions & 26 deletions src/ui/symbollayer/widget_shapeburstfill.ui
Expand Up @@ -29,24 +29,26 @@
</widget>
</item>
<item row="3" column="1" colspan="3">
<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>
<widget class="QgsColorRampButton" name="btnColorRamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QgsDataDefinedButton" name="mShadeWholeShapeDDBtn">
Expand Down Expand Up @@ -126,7 +128,7 @@
<item>
<widget class="QRadioButton" name="mRadioUseMaxDistance">
<property name="text">
<string>Shade to a set distance</string>
<string>Set distance</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -339,7 +341,7 @@
<item>
<widget class="QRadioButton" name="mRadioUseWholeShape">
<property name="text">
<string>Shade whole shape</string>
<string>Whole shape</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -424,16 +426,16 @@
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorRampComboBox</class>
<extends>QComboBox</extends>
<header>qgscolorrampcombobox.h</header>
<class>QgsColorRampButton</class>
<extends>QToolButton</extends>
<header>qgscolorrampbutton.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>radioTwoColor</tabstop>
<tabstop>radioColorRamp</tabstop>
<tabstop>cboGradientColorRamp</tabstop>
<tabstop>mButtonEditRamp</tabstop>
<tabstop>btnColorRamp</tabstop>
<tabstop>mRadioUseWholeShape</tabstop>
<tabstop>mRadioUseMaxDistance</tabstop>
<tabstop>mSpinMaxDistance</tabstop>
Expand Down Expand Up @@ -479,7 +481,7 @@
<connection>
<sender>radioColorRamp</sender>
<signal>toggled(bool)</signal>
<receiver>cboGradientColorRamp</receiver>
<receiver>btnColorRamp</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
Expand Down

0 comments on commit aa4d751

Please sign in to comment.