Skip to content
Permalink
Browse files

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.
  • Loading branch information
nyalldawson committed Nov 24, 2014
1 parent 9213a84 commit a0c1380e791eb8a6b41013e35169ed5be6e7f467
@@ -17,6 +17,12 @@ class QgsColorRampComboBox : QComboBox
//! return new instance of the current color ramp or NULL if there is no active color ramp
QgsVectorColorRampV2* currentColorRamp();

/**Returns true if the current selection in the combo box is the option for creating
* a new color ramp
* @note added in QGIS 2.7
*/
bool createNewColorRampSelected() const;

//! @note not available in python bindings
// static QSize rampIconSize;

@@ -630,7 +630,7 @@ QgsVectorColorRampV2* QgsCategorizedSymbolRendererV2Widget::getColorRamp()
{
if ( cboCategorizedColorRamp->count() == 0 )
QMessageBox::critical( this, tr( "Error" ), tr( "There are no available color ramps. You can add them in Style Manager." ) );
else
else if ( !cboCategorizedColorRamp->createNewColorRampSelected() )
QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
}
return ramp;
@@ -74,6 +74,12 @@ QgsVectorColorRampV2* QgsColorRampComboBox::currentColorRamp()
return mStyle->colorRamp( rampName );
}

bool QgsColorRampComboBox::createNewColorRampSelected() const
{
int index = currentIndex();
return index == count() - 1; //create new ramp is last item in combobox
}

void QgsColorRampComboBox::setSourceColorRamp( QgsVectorColorRampV2* sourceRamp )
{
mSourceColorRamp = sourceRamp->clone();
@@ -37,6 +37,12 @@ class GUI_EXPORT QgsColorRampComboBox : public QComboBox
//! return new instance of the current color ramp or NULL if there is no active color ramp
QgsVectorColorRampV2* currentColorRamp();

/**Returns true if the current selection in the combo box is the option for creating
* a new color ramp
* @note added in QGIS 2.7
*/
bool createNewColorRampSelected() const;

//! @note not available in python bindings
static QSize rampIconSize;

0 comments on commit a0c1380

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