Skip to content
Permalink
Browse files

Use modal dialog when in properties dialog, allowing to cancel

the process and add help button (fix #17903).
Also fix crash that occurs when pressing ESC button.

and fix doc
  • Loading branch information
DelazJ committed Apr 30, 2018
1 parent 89c2b4b commit 1c34339b3c84061ce95dbc60c8600a8378f65e1c
@@ -110,6 +110,10 @@ Changes the selected symbols alone for the change button, if there is a selectio
%End

void changeCategorySymbol();
void applyChangeToSymbol();
%Docstring
Applies current symbol to selected categories, or to all categories if none is selected
%End

virtual QList<QgsSymbol *> selectedSymbols();

@@ -78,6 +78,10 @@ Returns a list of indexes for the classes under selection
void changeRange( int rangeIdx );

void changeSelectedSymbols();
void applyChangeToSymbol();
%Docstring
Applies current symbol to selected ranges, or to all ranges if none is selected
%End

virtual QList<QgsSymbol *> selectedSymbols();

@@ -544,14 +544,32 @@ void QgsCategorizedSymbolRendererWidget::changeSelectedSymbols()

void QgsCategorizedSymbolRendererWidget::changeCategorizedSymbol()
{
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
QgsSymbol *newSymbol = mCategorizedSymbol->clone();
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::updateCategorizedSymbolIcon );
openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( newSymbol, mStyle, mLayer, panel );
dlg.setContext( mContext );
if ( !dlg.exec() || !newSymbol )
{
delete newSymbol;
return;
}

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::updateCategorizedSymbolIcon );
openPanel( dlg );
delete mCategorizedSymbol;
mCategorizedSymbol = newSymbol;
updateCategorizedSymbolIcon();
applyChangeToSymbol();
}
}

void QgsCategorizedSymbolRendererWidget::updateCategorizedSymbolIcon()
@@ -593,11 +611,29 @@ void QgsCategorizedSymbolRendererWidget::changeCategorySymbol()
symbol = QgsSymbol::defaultSymbol( mLayer->geometryType() );
}

QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( symbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( symbol, mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( symbol, mStyle, mLayer, panel );
dlg.setContext( mContext );
if ( !dlg.exec() || !symbol )
{
delete symbol;
return;
}

delete mCategorizedSymbol;
mCategorizedSymbol = symbol;
applyChangeToSymbol();
}
}

static void _createCategories( QgsCategoryList &cats, QList<QVariant> &values, QgsSymbol *symbol )
@@ -954,6 +990,11 @@ void QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget()
QgsSymbolSelectorWidget *dlg = qobject_cast<QgsSymbolSelectorWidget *>( sender() );
mCategorizedSymbol.reset( dlg->symbol()->clone() );

applyChangeToSymbol();
}

void QgsCategorizedSymbolRendererWidget::applyChangeToSymbol()
{
// When there is a selection, change the selected symbols only
QItemSelectionModel *m = viewCategories->selectionModel();
QModelIndexList i = m->selectedRows();
@@ -173,6 +173,8 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,
void changeSelectedSymbols();

void changeCategorySymbol();
//! Applies current symbol to selected categories, or to all categories if none is selected
void applyChangeToSymbol();

QList<QgsSymbol *> selectedSymbols() override;
QgsCategoryList selectedCategoryList();
@@ -754,6 +754,11 @@ void QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget()
QgsSymbolSelectorWidget *dlg = qobject_cast<QgsSymbolSelectorWidget *>( sender() );
mGraduatedSymbol.reset( dlg->symbol()->clone() );

applyChangeToSymbol();
}

void QgsGraduatedSymbolRendererWidget::applyChangeToSymbol()
{
mSizeUnitWidget->blockSignals( true );
mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
@@ -874,13 +879,31 @@ void QgsGraduatedSymbolRendererWidget::reapplySizes()
void QgsGraduatedSymbolRendererWidget::changeGraduatedSymbol()
{
QgsSymbol *newSymbol = mGraduatedSymbol->clone();
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, panel );
dlg->setContext( mContext );

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::updateGraduatedSymbolIcon );
panel->openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( newSymbol, mStyle, mLayer, panel );
if ( !dlg.exec() || !newSymbol )
{
delete newSymbol;
return;
}

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::updateGraduatedSymbolIcon );
openPanel( dlg );
delete mGraduatedSymbol;
mGraduatedSymbol = newSymbol;
updateGraduatedSymbolIcon();
applyChangeToSymbol();
}
}

void QgsGraduatedSymbolRendererWidget::updateGraduatedSymbolIcon()
@@ -953,12 +976,29 @@ void QgsGraduatedSymbolRendererWidget::changeSelectedSymbols()
void QgsGraduatedSymbolRendererWidget::changeRangeSymbol( int rangeIdx )
{
QgsSymbol *newSymbol = mRenderer->ranges()[rangeIdx].symbol()->clone();
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( newSymbol, mStyle, mLayer, panel );
dlg.setContext( mContext );
if ( !dlg.exec() || !newSymbol )
{
delete newSymbol;
return;
}

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
delete mGraduatedSymbol;
mGraduatedSymbol = newSymbol;
applyChangeToSymbol();
}
}

void QgsGraduatedSymbolRendererWidget::changeRange( int rangeIdx )
@@ -146,6 +146,8 @@ class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, pr
void changeRange( int rangeIdx );

void changeSelectedSymbols();
//! Applies current symbol to selected ranges, or to all ranges if none is selected
void applyChangeToSymbol();

QList<QgsSymbol *> selectedSymbols() override;
QgsSymbol *findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList &ranges ) const;

0 comments on commit 1c34339

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