Skip to content

Commit

Permalink
Better dialog titles for style manager edit/add dialogs
Browse files Browse the repository at this point in the history
Make it clearer if the dialog is editing an existing symbol, or
creating a new one
  • Loading branch information
nyalldawson committed Oct 11, 2021
1 parent 58287d1 commit 359e8cd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/gui/symbology/qgsstylemanagerdialog.cpp
Expand Up @@ -1128,6 +1128,7 @@ bool QgsStyleManagerDialog::addTextFormat()
{
QgsTextFormat format;
QgsTextFormatDialog formatDlg( format, nullptr, this );
formatDlg.setWindowTitle( tr( "New Text Format" ) );
if ( !formatDlg.exec() )
return false;
format = formatDlg.format();
Expand Down Expand Up @@ -1280,19 +1281,23 @@ bool QgsStyleManagerDialog::addSymbol( int symbolType )
// create new symbol with current type
QgsSymbol *symbol = nullptr;
QString name = tr( "new symbol" );
QString dialogTitle;
switch ( symbolType == -1 ? currentItemType() : symbolType )
{
case static_cast< int >( Qgis::SymbolType::Marker ):
symbol = new QgsMarkerSymbol();
name = tr( "new marker" );
dialogTitle = tr( "New Marker Symbol" );
break;
case static_cast< int>( Qgis::SymbolType::Line ):
symbol = new QgsLineSymbol();
name = tr( "new line" );
dialogTitle = tr( "New Line Symbol" );
break;
case static_cast< int >( Qgis::SymbolType::Fill ):
symbol = new QgsFillSymbol();
name = tr( "new fill symbol" );
dialogTitle = tr( "New Fill Symbol" );
break;
default:
Q_ASSERT( false && "unknown symbol type" );
Expand All @@ -1305,6 +1310,7 @@ bool QgsStyleManagerDialog::addSymbol( int symbolType )
// of style manager and symbol selector can be arrested
// See also: editSymbol()
QgsSymbolSelectorDialog dlg( symbol, mStyle, nullptr, this );
dlg.setWindowTitle( dialogTitle );
if ( dlg.exec() == 0 )
{
delete symbol;
Expand Down Expand Up @@ -1399,6 +1405,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget *parent, QgsStyle *st
if ( rampType == QgsGradientColorRamp::typeString() )
{
QgsGradientColorRampDialog dlg( QgsGradientColorRamp(), parent );
dlg.setWindowTitle( tr( "New Gradient Color Ramp" ) );
if ( !dlg.exec() )
{
return QString();
Expand All @@ -1409,6 +1416,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget *parent, QgsStyle *st
else if ( rampType == QgsLimitedRandomColorRamp::typeString() )
{
QgsLimitedRandomColorRampDialog dlg( QgsLimitedRandomColorRamp(), parent );
dlg.setWindowTitle( tr( "New Random Color Ramp" ) );
if ( !dlg.exec() )
{
return QString();
Expand All @@ -1419,6 +1427,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget *parent, QgsStyle *st
else if ( rampType == QgsColorBrewerColorRamp::typeString() )
{
QgsColorBrewerColorRampDialog dlg( QgsColorBrewerColorRamp(), parent );
dlg.setWindowTitle( tr( "New ColorBrewer Ramp" ) );
if ( !dlg.exec() )
{
return QString();
Expand All @@ -1429,6 +1438,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget *parent, QgsStyle *st
else if ( rampType == QgsPresetSchemeColorRamp::typeString() )
{
QgsPresetColorRampDialog dlg( QgsPresetSchemeColorRamp(), parent );
dlg.setWindowTitle( tr( "New Preset Color Ramp" ) );
if ( !dlg.exec() )
{
return QString();
Expand All @@ -1439,6 +1449,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget *parent, QgsStyle *st
else if ( rampType == QgsCptCityColorRamp::typeString() )
{
QgsCptCityColorRampDialog dlg( QgsCptCityColorRamp( QString(), QString() ), parent );
dlg.setWindowTitle( tr( "New cpt-city Color Ramp" ) );
if ( !dlg.exec() )
{
return QString();
Expand Down Expand Up @@ -1599,6 +1610,7 @@ bool QgsStyleManagerDialog::editSymbol()

// let the user edit the symbol and update list when done
QgsSymbolSelectorDialog dlg( symbol.get(), mStyle, nullptr, this );
dlg.setWindowTitle( symbolName );
if ( mReadOnly )
dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand All @@ -1623,6 +1635,7 @@ bool QgsStyleManagerDialog::editColorRamp()
{
QgsGradientColorRamp *gradRamp = static_cast<QgsGradientColorRamp *>( ramp.get() );
QgsGradientColorRampDialog dlg( *gradRamp, this );
dlg.setWindowTitle( name );
if ( mReadOnly )
dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand All @@ -1636,6 +1649,7 @@ bool QgsStyleManagerDialog::editColorRamp()
{
QgsLimitedRandomColorRamp *randRamp = static_cast<QgsLimitedRandomColorRamp *>( ramp.get() );
QgsLimitedRandomColorRampDialog dlg( *randRamp, this );
dlg.setWindowTitle( name );
if ( mReadOnly )
dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand All @@ -1649,6 +1663,7 @@ bool QgsStyleManagerDialog::editColorRamp()
{
QgsColorBrewerColorRamp *brewerRamp = static_cast<QgsColorBrewerColorRamp *>( ramp.get() );
QgsColorBrewerColorRampDialog dlg( *brewerRamp, this );
dlg.setWindowTitle( name );
if ( mReadOnly )
dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand All @@ -1662,6 +1677,7 @@ bool QgsStyleManagerDialog::editColorRamp()
{
QgsPresetSchemeColorRamp *presetRamp = static_cast<QgsPresetSchemeColorRamp *>( ramp.get() );
QgsPresetColorRampDialog dlg( *presetRamp, this );
dlg.setWindowTitle( name );
if ( mReadOnly )
dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand All @@ -1675,6 +1691,7 @@ bool QgsStyleManagerDialog::editColorRamp()
{
QgsCptCityColorRamp *cptCityRamp = static_cast<QgsCptCityColorRamp *>( ramp.get() );
QgsCptCityColorRampDialog dlg( *cptCityRamp, this );
dlg.setWindowTitle( name );
if ( mReadOnly )
dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand Down Expand Up @@ -1711,6 +1728,7 @@ bool QgsStyleManagerDialog::editTextFormat()

// let the user edit the format and update list when done
QgsTextFormatDialog dlg( format, nullptr, this );
dlg.setWindowTitle( formatName );
if ( mReadOnly )
dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand All @@ -1727,6 +1745,7 @@ bool QgsStyleManagerDialog::addLabelSettings( QgsWkbTypes::GeometryType type )
{
QgsPalLayerSettings settings;
QgsLabelSettingsDialog settingsDlg( settings, nullptr, nullptr, this, type );
settingsDlg.setWindowTitle( tr( "New Label Settings" ) );
if ( mReadOnly )
settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand Down Expand Up @@ -1802,6 +1821,7 @@ bool QgsStyleManagerDialog::editLabelSettings()

// let the user edit the settings and update list when done
QgsLabelSettingsDialog dlg( settings, nullptr, nullptr, this, geomType );
dlg.setWindowTitle( formatName );
if ( !dlg.exec() )
return false;

Expand All @@ -1818,6 +1838,7 @@ bool QgsStyleManagerDialog::addLegendPatchShape( Qgis::SymbolType type )
{
QgsLegendPatchShape shape = mStyle->defaultPatch( type, QSizeF( 10, 5 ) );
QgsLegendPatchShapeDialog dialog( shape, this );
dialog.setWindowTitle( tr( "New Legend Patch Shape" ) );
if ( mReadOnly )
dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand Down Expand Up @@ -1893,6 +1914,7 @@ bool QgsStyleManagerDialog::editLegendPatchShape()

// let the user edit the shape and update list when done
QgsLegendPatchShapeDialog dlg( shape, this );
dlg.setWindowTitle( shapeName );
if ( !dlg.exec() )
return false;

Expand All @@ -1911,6 +1933,7 @@ bool QgsStyleManagerDialog::addSymbol3D( const QString &type )
return false;

Qgs3DSymbolDialog dialog( symbol.get(), this );
dialog.setWindowTitle( tr( "New 3D Symbol" ) );
if ( mReadOnly )
dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand Down Expand Up @@ -1989,6 +2012,7 @@ bool QgsStyleManagerDialog::editSymbol3D()

// let the user edit the symbol and update list when done
Qgs3DSymbolDialog dlg( symbol.get(), this );
dlg.setWindowTitle( symbolName );
if ( !dlg.exec() )
return false;

Expand Down

0 comments on commit 359e8cd

Please sign in to comment.