Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 a0c1380
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions python/gui/symbology-ng/qgscolorrampcombobox.sip
Expand Up @@ -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;

Expand Down
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/gui/symbology-ng/qgscolorrampcombobox.cpp
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/gui/symbology-ng/qgscolorrampcombobox.h
Expand Up @@ -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;

Expand Down

0 comments on commit a0c1380

Please sign in to comment.