Skip to content

Commit aa4d751

Browse files
committed
[symbology] migrate shapeburst color ramp widget
1 parent 1560c7f commit aa4d751

File tree

3 files changed

+56
-59
lines changed

3 files changed

+56
-59
lines changed

src/gui/symbology-ng/qgssymbollayerwidget.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "qgssvgcache.h"
2929
#include "qgssymbollayerutils.h"
3030
#include "qgscolorramp.h"
31+
#include "qgscolorrampbutton.h"
3132
#include "qgsgradientcolorrampdialog.h"
3233
#include "qgsdatadefined.h"
3334
#include "qgsstyle.h" //for symbol selector dialog
@@ -1360,11 +1361,9 @@ QgsShapeburstFillSymbolLayerWidget::QgsShapeburstFillSymbolLayerWidget( const Qg
13601361
spinOffsetX->setClearValue( 0.0 );
13611362
spinOffsetY->setClearValue( 0.0 );
13621363

1363-
cboGradientColorRamp->populate( QgsStyle::defaultStyle() );
1364+
btnColorRamp->setShowGradientOnly( true );
13641365

1365-
connect( cboGradientColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
1366-
connect( cboGradientColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
1367-
connect( mButtonEditRamp, SIGNAL( clicked() ), cboGradientColorRamp, SLOT( editSourceRamp() ) );
1366+
connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );
13681367

13691368
connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
13701369
connect( btnChangeColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) );
@@ -1395,7 +1394,7 @@ void QgsShapeburstFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* layer )
13951394
if ( mLayer->colorType() == QgsShapeburstFillSymbolLayer::SimpleTwoColor )
13961395
{
13971396
radioTwoColor->setChecked( true );
1398-
cboGradientColorRamp->setEnabled( false );
1397+
btnColorRamp->setEnabled( false );
13991398
}
14001399
else
14011400
{
@@ -1444,9 +1443,9 @@ void QgsShapeburstFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* layer )
14441443
// set source color ramp
14451444
if ( mLayer->colorRamp() )
14461445
{
1447-
cboGradientColorRamp->blockSignals( true );
1448-
cboGradientColorRamp->setSourceColorRamp( mLayer->colorRamp() );
1449-
cboGradientColorRamp->blockSignals( false );
1446+
btnColorRamp->blockSignals( true );
1447+
btnColorRamp->setColorRamp( mLayer->colorRamp() );
1448+
btnColorRamp->blockSignals( false );
14501449
}
14511450

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

15501549
void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
15511550
{
1552-
QgsColorRamp* ramp = cboGradientColorRamp->currentColorRamp();
1551+
QgsColorRamp* ramp = btnColorRamp->colorRamp();
15531552
if ( !ramp )
15541553
return;
15551554

src/ui/symbollayer/widget_gradientfill.ui

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,30 +150,26 @@
150150
</widget>
151151
</item>
152152
<item row="2" column="1">
153-
<layout class="QHBoxLayout" name="horizontalLayout_8">
154-
<item>
155-
<widget class="QgsColorRampButton" name="btnColorRamp">
156-
<property name="sizePolicy">
157-
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
158-
<horstretch>0</horstretch>
159-
<verstretch>0</verstretch>
160-
</sizepolicy>
161-
</property>
162-
<property name="minimumSize">
163-
<size>
164-
<width>120</width>
165-
<height>0</height>
166-
</size>
167-
</property>
168-
<property name="maximumSize">
169-
<size>
170-
<width>16777215</width>
171-
<height>16777215</height>
172-
</size>
173-
</property>
174-
</widget>
175-
</item>
176-
</layout>
153+
<widget class="QgsColorRampButton" name="btnColorRamp">
154+
<property name="sizePolicy">
155+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
156+
<horstretch>0</horstretch>
157+
<verstretch>0</verstretch>
158+
</sizepolicy>
159+
</property>
160+
<property name="minimumSize">
161+
<size>
162+
<width>120</width>
163+
<height>0</height>
164+
</size>
165+
</property>
166+
<property name="maximumSize">
167+
<size>
168+
<width>16777215</width>
169+
<height>16777215</height>
170+
</size>
171+
</property>
172+
</widget>
177173
</item>
178174
<item row="8" column="2" rowspan="2">
179175
<widget class="QgsDataDefinedButton" name="mRefPoint1YDDBtn">

src/ui/symbollayer/widget_shapeburstfill.ui

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,26 @@
2929
</widget>
3030
</item>
3131
<item row="3" column="1" colspan="3">
32-
<layout class="QHBoxLayout" name="horizontalLayout_8">
33-
<item>
34-
<widget class="QgsColorRampComboBox" name="cboGradientColorRamp"/>
35-
</item>
36-
<item>
37-
<widget class="QPushButton" name="mButtonEditRamp">
38-
<property name="maximumSize">
39-
<size>
40-
<width>100</width>
41-
<height>16777215</height>
42-
</size>
43-
</property>
44-
<property name="text">
45-
<string>Edit</string>
46-
</property>
47-
</widget>
48-
</item>
49-
</layout>
32+
<widget class="QgsColorRampButton" name="btnColorRamp">
33+
<property name="sizePolicy">
34+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
35+
<horstretch>0</horstretch>
36+
<verstretch>0</verstretch>
37+
</sizepolicy>
38+
</property>
39+
<property name="minimumSize">
40+
<size>
41+
<width>120</width>
42+
<height>0</height>
43+
</size>
44+
</property>
45+
<property name="maximumSize">
46+
<size>
47+
<width>16777215</width>
48+
<height>16777215</height>
49+
</size>
50+
</property>
51+
</widget>
5052
</item>
5153
<item row="5" column="4">
5254
<widget class="QgsDataDefinedButton" name="mShadeWholeShapeDDBtn">
@@ -126,7 +128,7 @@
126128
<item>
127129
<widget class="QRadioButton" name="mRadioUseMaxDistance">
128130
<property name="text">
129-
<string>Shade to a set distance</string>
131+
<string>Set distance</string>
130132
</property>
131133
</widget>
132134
</item>
@@ -339,7 +341,7 @@
339341
<item>
340342
<widget class="QRadioButton" name="mRadioUseWholeShape">
341343
<property name="text">
342-
<string>Shade whole shape</string>
344+
<string>Whole shape</string>
343345
</property>
344346
</widget>
345347
</item>
@@ -424,16 +426,16 @@
424426
<container>1</container>
425427
</customwidget>
426428
<customwidget>
427-
<class>QgsColorRampComboBox</class>
428-
<extends>QComboBox</extends>
429-
<header>qgscolorrampcombobox.h</header>
429+
<class>QgsColorRampButton</class>
430+
<extends>QToolButton</extends>
431+
<header>qgscolorrampbutton.h</header>
432+
<container>1</container>
430433
</customwidget>
431434
</customwidgets>
432435
<tabstops>
433436
<tabstop>radioTwoColor</tabstop>
434437
<tabstop>radioColorRamp</tabstop>
435-
<tabstop>cboGradientColorRamp</tabstop>
436-
<tabstop>mButtonEditRamp</tabstop>
438+
<tabstop>btnColorRamp</tabstop>
437439
<tabstop>mRadioUseWholeShape</tabstop>
438440
<tabstop>mRadioUseMaxDistance</tabstop>
439441
<tabstop>mSpinMaxDistance</tabstop>
@@ -479,7 +481,7 @@
479481
<connection>
480482
<sender>radioColorRamp</sender>
481483
<signal>toggled(bool)</signal>
482-
<receiver>cboGradientColorRamp</receiver>
484+
<receiver>btnColorRamp</receiver>
483485
<slot>setEnabled(bool)</slot>
484486
<hints>
485487
<hint type="sourcelabel">

0 commit comments

Comments
 (0)