Skip to content

Commit

Permalink
Fix incorrect warning dialog appearing when creating new ramp
Browse files Browse the repository at this point in the history
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 d652114 commit 9a8dcec
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 9a8dcec

Please sign in to comment.