Skip to content
Permalink
Browse files

[composer] Use inline panels for grid and overview symbol style selec…

…tors
  • Loading branch information
nyalldawson committed Oct 9, 2016
1 parent 22af5bf commit 8d690fa4f652d6c4f8ad408e77b24328fa6549e5
@@ -292,6 +292,99 @@ void QgsComposerMapWidget::onPresetsChanged()
}
}

void QgsComposerMapWidget::updateGridLineStyleFromWidget()
{
QgsComposerMapGrid* grid = currentGrid();
if ( !grid )
{
return;
}

QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
grid->setLineSymbol( dynamic_cast< QgsLineSymbol* >( w->symbol()->clone() ) );
mComposerMap->update();
}

void QgsComposerMapWidget::cleanUpGridLineStyleSelector( QgsPanelWidget* container )
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( container );
if ( !w )
return;

delete w->symbol();

QgsComposerMapGrid* grid = currentGrid();
if ( !grid )
{
return;
}

updateGridLineSymbolMarker( grid );
mComposerMap->endCommand();
}

void QgsComposerMapWidget::updateGridMarkerStyleFromWidget()
{
QgsComposerMapGrid* grid = currentGrid();
if ( !grid )
{
return;
}

QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
grid->setMarkerSymbol( dynamic_cast< QgsMarkerSymbol* >( w->symbol()->clone() ) );
mComposerMap->update();
}

void QgsComposerMapWidget::cleanUpGridMarkerStyleSelector( QgsPanelWidget* container )
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( container );
if ( !w )
return;

delete w->symbol();

QgsComposerMapGrid* grid = currentGrid();
if ( !grid )
{
return;
}

updateGridMarkerSymbolMarker( grid );
mComposerMap->endCommand();
}

void QgsComposerMapWidget::updateOverviewFrameStyleFromWidget()
{
QgsComposerMapOverview* overview = currentOverview();
if ( !overview )
{
return;
}

QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
overview->setFrameSymbol( dynamic_cast< QgsFillSymbol* >( w->symbol()->clone() ) );
mComposerMap->update();
}

void QgsComposerMapWidget::cleanUpOverviewFrameStyleSelector( QgsPanelWidget* container )
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( container );
if ( !w )
return;

delete w->symbol();

QgsComposerMapOverview* overview = currentOverview();
if ( !overview )
{
return;
}

updateOverviewFrameSymbolMarker( overview );
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mAtlasCheckBox_toggled( bool checked )
{
if ( !mComposerMap )
@@ -1496,21 +1589,21 @@ void QgsComposerMapWidget::on_mGridLineStyleButton_clicked()
return;
}

// use the atlas coverage layer, if any
QgsVectorLayer* coverageLayer = atlasCoverageLayer();

QgsLineSymbol* newSymbol = static_cast<QgsLineSymbol*>( grid->lineSymbol()->clone() );
QgsSymbolSelectorDialog d( newSymbol, QgsStyle::defaultStyle(), nullptr, this );
QgsExpressionContext context = mComposerMap->createExpressionContext();

if ( d.exec() == QDialog::Accepted )
{
mComposerMap->beginCommand( tr( "Grid line style changed" ) );
grid->setLineSymbol( newSymbol );
updateGridLineSymbolMarker( grid );
mComposerMap->endCommand();
mComposerMap->update();
}
else
{
delete newSymbol;
}
QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
d->setContext( symbolContext );

connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateGridLineStyleFromWidget() ) );
connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpGridLineStyleSelector( QgsPanelWidget* ) ) );
openPanel( d );
mComposerMap->beginCommand( tr( "Grid line style changed" ) );
}

void QgsComposerMapWidget::on_mGridMarkerStyleButton_clicked()
@@ -1521,21 +1614,21 @@ void QgsComposerMapWidget::on_mGridMarkerStyleButton_clicked()
return;
}

// use the atlas coverage layer, if any
QgsVectorLayer* coverageLayer = atlasCoverageLayer();

QgsMarkerSymbol* newSymbol = static_cast<QgsMarkerSymbol*>( grid->markerSymbol()->clone() );
QgsSymbolSelectorDialog d( newSymbol, QgsStyle::defaultStyle(), nullptr, this );
QgsExpressionContext context = mComposerMap->createExpressionContext();

if ( d.exec() == QDialog::Accepted )
{
mComposerMap->beginCommand( tr( "Grid markers style changed" ) );
grid->setMarkerSymbol( newSymbol );
updateGridMarkerSymbolMarker( grid );
mComposerMap->endCommand();
mComposerMap->update();
}
else
{
delete newSymbol;
}
QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
d->setContext( symbolContext );

connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateGridMarkerStyleFromWidget() ) );
connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpGridMarkerStyleSelector( QgsPanelWidget* ) ) );
openPanel( d );
mComposerMap->beginCommand( tr( "Grid markers style changed" ) );
}

void QgsComposerMapWidget::on_mIntervalXSpinBox_editingFinished()
@@ -2463,21 +2556,21 @@ void QgsComposerMapWidget::on_mOverviewFrameStyleButton_clicked()
return;
}

// use the atlas coverage layer, if any
QgsVectorLayer* coverageLayer = atlasCoverageLayer();

QgsFillSymbol* newSymbol = static_cast<QgsFillSymbol*>( overview->frameSymbol()->clone() );
QgsSymbolSelectorDialog d( newSymbol, QgsStyle::defaultStyle(), nullptr, this );
QgsExpressionContext context = mComposerMap->createExpressionContext();

if ( d.exec() == QDialog::Accepted )
{
mComposerMap->beginCommand( tr( "Overview frame style changed" ) );
overview->setFrameSymbol( newSymbol );
updateOverviewFrameSymbolMarker( overview );
mComposerMap->endCommand();
mComposerMap->update();
}
else
{
delete newSymbol;
}
QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
d->setContext( symbolContext );

connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateOverviewFrameStyleFromWidget() ) );
connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpOverviewFrameStyleSelector( QgsPanelWidget* ) ) );
openPanel( d );
mComposerMap->beginCommand( tr( "Overview frame style changed" ) );
}

void QgsComposerMapWidget::on_mOverviewBlendModeComboBox_currentIndexChanged( int index )
@@ -174,6 +174,13 @@ class QgsComposerMapWidget: public QgsComposerItemBaseWidget, private Ui::QgsCom

void onPresetsChanged();

void updateGridLineStyleFromWidget();
void cleanUpGridLineStyleSelector( QgsPanelWidget* container );
void updateGridMarkerStyleFromWidget();
void cleanUpGridMarkerStyleSelector( QgsPanelWidget* container );
void updateOverviewFrameStyleFromWidget();
void cleanUpOverviewFrameStyleSelector( QgsPanelWidget* container );

private:
QgsComposerMap* mComposerMap;

@@ -32,7 +32,7 @@ QgsComposerShapeWidget::QgsComposerShapeWidget( QgsComposerShape* composerShape
//add widget for general composer item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, composerShape );

//shapes don't use background or frame, since the symbol style is set through a QgsSymbolSelectorDialog
//shapes don't use background or frame, since the symbol style is set through a QgsSymbolSelectorWidget
itemPropertiesWidget->showBackgroundGroup( false );
itemPropertiesWidget->showFrameGroup( false );

@@ -111,8 +111,6 @@ void QgsComposerShapeWidget::on_mShapeStyleButton_clicked()
QgsFillSymbol* newSymbol = mComposerShape->shapeStyleSymbol()->clone();
QgsExpressionContext context = mComposerShape->createExpressionContext();



QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );

0 comments on commit 8d690fa

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