mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
added name checking to new colorramps as well
This commit is contained in:
parent
b72ddcab7e
commit
29006466ec
@ -425,18 +425,49 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get name
|
// get name
|
||||||
QString name = QInputDialog::getText( parent, tr( "Color ramp name" ),
|
bool nameInvalid = true;
|
||||||
tr( "Please enter name for new color ramp:" ), QLineEdit::Normal, tr( "new color ramp" ), &ok );
|
QString name;
|
||||||
if ( !ok || name.isEmpty() )
|
|
||||||
|
while ( nameInvalid )
|
||||||
{
|
{
|
||||||
if ( ramp )
|
bool ok;
|
||||||
|
name = QInputDialog::getText( parent, tr( "Color Ramp Name" ),
|
||||||
|
tr( "Please enter a name for new color ramp:" ),
|
||||||
|
QLineEdit::Normal,
|
||||||
|
tr( "new ramp" ),
|
||||||
|
&ok );
|
||||||
|
if ( !ok )
|
||||||
|
{
|
||||||
delete ramp;
|
delete ramp;
|
||||||
return QString();
|
return QString();
|
||||||
|
}
|
||||||
|
// validate name
|
||||||
|
if ( name.isEmpty() )
|
||||||
|
{
|
||||||
|
QMessageBox::warning( parent, tr( "Save Color Ramp" ),
|
||||||
|
tr( "Cannot save color ramp without name. Enter a name." ) );
|
||||||
|
}
|
||||||
|
else if ( style->colorRampNames().contains( name ) )
|
||||||
|
{
|
||||||
|
int res = QMessageBox::warning( parent, tr( "Save color ramp" ),
|
||||||
|
tr( "Color ramp with name '%1' already exists. Overwrite?" )
|
||||||
|
.arg( name ),
|
||||||
|
QMessageBox::Yes | QMessageBox::No );
|
||||||
|
if ( res == QMessageBox::Yes )
|
||||||
|
{
|
||||||
|
nameInvalid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// valid name
|
||||||
|
nameInvalid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new symbol to style and re-populate the list
|
// add new symbol to style and re-populate the list
|
||||||
style->addColorRamp( name, ramp, true );
|
style->addColorRamp( name, ramp, true );
|
||||||
// TODO groups and tags
|
// TODO groups and tags, using saveColorRamp
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user