Skip to content

Commit

Permalink
[composer] Correctly handle cancelling shape, overview, grid and page…
Browse files Browse the repository at this point in the history
… style changes
  • Loading branch information
nyalldawson committed Apr 14, 2014
1 parent 96809eb commit 80b7021
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
20 changes: 12 additions & 8 deletions src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,18 +773,20 @@ void QgsComposerMapWidget::on_mOverviewFrameStyleButton_clicked()
return;
}

mComposerMap->beginCommand( tr( "Overview frame style changed" ) );
QgsSymbolV2SelectorDialog d( mComposerMap->overviewFrameMapSymbol(), QgsStyleV2::defaultStyle(), 0 );
QgsFillSymbolV2* newSymbol = dynamic_cast<QgsFillSymbolV2*>( mComposerMap->overviewFrameMapSymbol()->clone() );
QgsSymbolV2SelectorDialog d( newSymbol, QgsStyleV2::defaultStyle(), 0 );

//QgsSymbolV2PropertiesDialog d( mComposerMap->overviewFrameMapSymbol(), 0, this );
if ( d.exec() == QDialog::Accepted )
{
mComposerMap->beginCommand( tr( "Overview frame style changed" ) );
mComposerMap->setOverviewFrameMapSymbol( newSymbol );
updateOverviewSymbolMarker();
mComposerMap->endCommand();
}
else
{
mComposerMap->cancelCommand();
delete newSymbol;
}
}

Expand Down Expand Up @@ -898,19 +900,21 @@ void QgsComposerMapWidget::on_mGridLineStyleButton_clicked()
return;
}

mComposerMap->beginCommand( tr( "Grid line style changed" ) );
QgsSymbolV2SelectorDialog d( mComposerMap->gridLineSymbol(), QgsStyleV2::defaultStyle(), 0 );
QgsLineSymbolV2* newSymbol = dynamic_cast<QgsLineSymbolV2*>( mComposerMap->gridLineSymbol()->clone() );
QgsSymbolV2SelectorDialog d( newSymbol, QgsStyleV2::defaultStyle(), 0 );

if ( d.exec() == QDialog::Accepted )
{
mComposerMap->beginCommand( tr( "Grid line style changed" ) );
mComposerMap->setGridLineSymbol( newSymbol );
updateLineSymbolMarker();
mComposerMap->endCommand();
mComposerMap->update();
}
else
{
mComposerMap->cancelCommand();
delete newSymbol;
}

mComposerMap->update();
}

void QgsComposerMapWidget::on_mGridTypeComboBox_currentIndexChanged( const QString& text )
Expand Down
8 changes: 5 additions & 3 deletions src/app/composer/qgscomposershapewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,19 @@ void QgsComposerShapeWidget::on_mShapeStyleButton_clicked()
coverageLayer = mComposerShape->composition()->atlasComposition().coverageLayer();
}

mComposerShape->beginCommand( tr( "Shape style changed" ) );
QgsSymbolV2SelectorDialog d( mComposerShape->shapeStyleSymbol(), QgsStyleV2::defaultStyle(), coverageLayer );
QgsFillSymbolV2* newSymbol = dynamic_cast<QgsFillSymbolV2*>( mComposerShape->shapeStyleSymbol()->clone() );
QgsSymbolV2SelectorDialog d( newSymbol, QgsStyleV2::defaultStyle(), coverageLayer );

if ( d.exec() == QDialog::Accepted )
{
mComposerShape->beginCommand( tr( "Shape style changed" ) );
mComposerShape->setShapeStyleSymbol( newSymbol );
updateShapeStyle();
mComposerShape->endCommand();
}
else
{
mComposerShape->cancelCommand();
delete newSymbol;
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/app/composer/qgscompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,19 @@ void QgsCompositionWidget::on_mPageStyleButton_clicked()
{
coverageLayer = mComposition->atlasComposition().coverageLayer();
}
QgsSymbolV2SelectorDialog d( mComposition->pageStyleSymbol(), QgsStyleV2::defaultStyle(), coverageLayer );

QgsFillSymbolV2* newSymbol = dynamic_cast<QgsFillSymbolV2*>( mComposition->pageStyleSymbol()->clone() );
QgsSymbolV2SelectorDialog d( newSymbol, QgsStyleV2::defaultStyle(), coverageLayer );

if ( d.exec() == QDialog::Accepted )
{
mComposition->setPageStyleSymbol( newSymbol );
updatePageStyle();
}
else
{
delete newSymbol;
}
}

void QgsCompositionWidget::updatePageStyle()
Expand Down

0 comments on commit 80b7021

Please sign in to comment.