Skip to content

Commit 9a8dcec

Browse files
committed
Fix incorrect warning dialog appearing when creating new ramp
Previously a "not available" warning dialog would appear when attempting to create a new color ramp using the categorised renderer.
1 parent d652114 commit 9a8dcec

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

python/gui/symbology-ng/qgscolorrampcombobox.sip

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ class QgsColorRampComboBox : QComboBox
1717
//! return new instance of the current color ramp or NULL if there is no active color ramp
1818
QgsVectorColorRampV2* currentColorRamp();
1919

20+
/**Returns true if the current selection in the combo box is the option for creating
21+
* a new color ramp
22+
* @note added in QGIS 2.7
23+
*/
24+
bool createNewColorRampSelected() const;
25+
2026
//! @note not available in python bindings
2127
// static QSize rampIconSize;
2228

src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ QgsVectorColorRampV2* QgsCategorizedSymbolRendererV2Widget::getColorRamp()
630630
{
631631
if ( cboCategorizedColorRamp->count() == 0 )
632632
QMessageBox::critical( this, tr( "Error" ), tr( "There are no available color ramps. You can add them in Style Manager." ) );
633-
else
633+
else if ( !cboCategorizedColorRamp->createNewColorRampSelected() )
634634
QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
635635
}
636636
return ramp;

src/gui/symbology-ng/qgscolorrampcombobox.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ QgsVectorColorRampV2* QgsColorRampComboBox::currentColorRamp()
7474
return mStyle->colorRamp( rampName );
7575
}
7676

77+
bool QgsColorRampComboBox::createNewColorRampSelected() const
78+
{
79+
int index = currentIndex();
80+
return index == count() - 1; //create new ramp is last item in combobox
81+
}
82+
7783
void QgsColorRampComboBox::setSourceColorRamp( QgsVectorColorRampV2* sourceRamp )
7884
{
7985
mSourceColorRamp = sourceRamp->clone();

src/gui/symbology-ng/qgscolorrampcombobox.h

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ class GUI_EXPORT QgsColorRampComboBox : public QComboBox
3737
//! return new instance of the current color ramp or NULL if there is no active color ramp
3838
QgsVectorColorRampV2* currentColorRamp();
3939

40+
/**Returns true if the current selection in the combo box is the option for creating
41+
* a new color ramp
42+
* @note added in QGIS 2.7
43+
*/
44+
bool createNewColorRampSelected() const;
45+
4046
//! @note not available in python bindings
4147
static QSize rampIconSize;
4248

0 commit comments

Comments
 (0)