[composer] Merge color change undo commands

Avoids color modifications spamming the undo stack
This commit is contained in:
Nyall Dawson 2016-10-06 19:03:00 +10:00
parent 028db7e541
commit 521cc3becd
12 changed files with 65 additions and 23 deletions

View File

@ -49,9 +49,14 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
//composer label //composer label
ComposerLabelSetText, ComposerLabelSetText,
ComposerLabelSetId, ComposerLabelSetId,
ComposerLabelFontColor,
//composer map //composer map
ComposerMapRotation, ComposerMapRotation,
ComposerMapAnnotationDistance, ComposerMapAnnotationDistance,
ComposerMapGridFramePenColor,
ComposerMapGridFrameFill1Color,
ComposerMapGridFrameFill2Color,
ComposerMapGridAnnotationFontColor,
//composer legend //composer legend
ComposerLegendText, ComposerLegendText,
LegendColumnCount, LegendColumnCount,
@ -69,8 +74,12 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
LegendBoxSpace, LegendBoxSpace,
LegendColumnSpace, LegendColumnSpace,
LegendRasterBorderWidth, LegendRasterBorderWidth,
LegendFontColor,
LegendRasterBorderColor,
//composer picture //composer picture
ComposerPictureRotation, ComposerPictureRotation,
ComposerPictureFillColor,
ComposerPictureOutlineColor,
// composer scalebar // composer scalebar
ScaleBarLineWidth, ScaleBarLineWidth,
ScaleBarHeight, ScaleBarHeight,
@ -81,6 +90,10 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
ScaleBarMapUnitsSegment, ScaleBarMapUnitsSegment,
ScaleBarLabelBarSize, ScaleBarLabelBarSize,
ScaleBarBoxContentSpace, ScaleBarBoxContentSpace,
ScaleBarFontColor,
ScaleBarFillColor,
ScaleBarFill2Color,
ScaleBarStrokeColor,
// composer table // composer table
TableMaximumFeatures, TableMaximumFeatures,
TableMargin, TableMargin,
@ -90,9 +103,13 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
ShapeOutlineWidth, ShapeOutlineWidth,
//composer arrow //composer arrow
ArrowOutlineWidth, ArrowOutlineWidth,
ArrowHeadFillColor,
ArrowHeadOutlineColor,
ArrowHeadWidth, ArrowHeadWidth,
//item //item
ItemOutlineWidth, ItemOutlineWidth,
ItemOutlineColor,
ItemBackgroundColor,
ItemMove, ItemMove,
ItemRotation, ItemRotation,
ItemTransparency, ItemTransparency,

View File

@ -49,7 +49,11 @@ class QgsComposerMultiFrameMergeCommand: QgsComposerMultiFrameCommand
TableMaximumFeatures, TableMaximumFeatures,
TableMargin, TableMargin,
TableGridStrokeWidth, TableGridStrokeWidth,
TableCellStyle TableCellStyle,
TableHeaderFontColor,
TableContentFontColor,
TableGridColor,
TableBackgroundColor,
}; };
QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text ); QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text );

View File

@ -99,7 +99,7 @@ void QgsComposerArrowWidget::on_mArrowHeadFillColorButton_colorChanged( const QC
return; return;
} }
mArrow->beginCommand( tr( "Arrow head fill color" ) ); mArrow->beginCommand( tr( "Arrow head fill color" ), QgsComposerMergeCommand::ArrowHeadFillColor );
mArrow->setArrowHeadFillColor( newColor ); mArrow->setArrowHeadFillColor( newColor );
mArrow->update(); mArrow->update();
mArrow->endCommand(); mArrow->endCommand();
@ -112,7 +112,7 @@ void QgsComposerArrowWidget::on_mArrowHeadOutlineColorButton_colorChanged( const
return; return;
} }
mArrow->beginCommand( tr( "Arrow head outline color" ) ); mArrow->beginCommand( tr( "Arrow head outline color" ), QgsComposerMergeCommand::ArrowHeadOutlineColor );
mArrow->setArrowHeadOutlineColor( newColor ); mArrow->setArrowHeadOutlineColor( newColor );
mArrow->update(); mArrow->update();
mArrow->endCommand(); mArrow->endCommand();

View File

@ -269,7 +269,7 @@ void QgsComposerAttributeTableWidget::on_mHeaderFontColorButton_colorChanged( co
QgsComposition* composition = mComposerTable->composition(); QgsComposition* composition = mComposerTable->composition();
if ( composition ) if ( composition )
{ {
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font color" ) ); composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font color" ), QgsComposerMultiFrameMergeCommand::TableHeaderFontColor );
} }
mComposerTable->setHeaderFontColor( newColor ); mComposerTable->setHeaderFontColor( newColor );
if ( composition ) if ( composition )
@ -310,7 +310,7 @@ void QgsComposerAttributeTableWidget::on_mContentFontColorButton_colorChanged( c
QgsComposition* composition = mComposerTable->composition(); QgsComposition* composition = mComposerTable->composition();
if ( composition ) if ( composition )
{ {
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font color" ) ); composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font color" ), QgsComposerMultiFrameMergeCommand::TableContentFontColor );
} }
mComposerTable->setContentFontColor( newColor ); mComposerTable->setContentFontColor( newColor );
if ( composition ) if ( composition )
@ -348,7 +348,7 @@ void QgsComposerAttributeTableWidget::on_mGridColorButton_colorChanged( const QC
QgsComposition* composition = mComposerTable->composition(); QgsComposition* composition = mComposerTable->composition();
if ( composition ) if ( composition )
{ {
composition->beginMultiFrameCommand( mComposerTable, tr( "Table grid color" ) ); composition->beginMultiFrameCommand( mComposerTable, tr( "Table grid color" ), QgsComposerMultiFrameMergeCommand::TableGridColor );
} }
mComposerTable->setGridColor( newColor ); mComposerTable->setGridColor( newColor );
if ( composition ) if ( composition )
@ -386,7 +386,7 @@ void QgsComposerAttributeTableWidget::on_mBackgroundColorButton_colorChanged( co
QgsComposition* composition = mComposerTable->composition(); QgsComposition* composition = mComposerTable->composition();
if ( composition ) if ( composition )
{ {
composition->beginMultiFrameCommand( mComposerTable, tr( "Table background color" ) ); composition->beginMultiFrameCommand( mComposerTable, tr( "Table background color" ), QgsComposerMultiFrameMergeCommand::TableBackgroundColor );
} }
mComposerTable->setBackgroundColor( newColor ); mComposerTable->setBackgroundColor( newColor );
if ( composition ) if ( composition )

View File

@ -210,7 +210,7 @@ void QgsComposerItemWidget::on_mFrameColorButton_colorChanged( const QColor& new
{ {
return; return;
} }
mItem->beginCommand( tr( "Frame color changed" ) ); mItem->beginCommand( tr( "Frame color changed" ), QgsComposerMergeCommand::ItemOutlineColor );
mItem->setFrameOutlineColor( newFrameColor ); mItem->setFrameOutlineColor( newFrameColor );
mItem->update(); mItem->update();
mItem->endCommand(); mItem->endCommand();
@ -230,7 +230,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
{ {
return; return;
} }
mItem->beginCommand( tr( "Background color changed" ) ); mItem->beginCommand( tr( "Background color changed" ), QgsComposerMergeCommand::ItemBackgroundColor );
mItem->setBackgroundColor( newBackgroundColor ); mItem->setBackgroundColor( newBackgroundColor );
//if the item is a composer map, we need to regenerate the map image //if the item is a composer map, we need to regenerate the map image

View File

@ -125,7 +125,7 @@ void QgsComposerLabelWidget::on_mFontColorButton_colorChanged( const QColor &new
return; return;
} }
mComposerLabel->beginCommand( tr( "Label color changed" ) ); mComposerLabel->beginCommand( tr( "Label color changed" ), QgsComposerMergeCommand::ComposerLabelFontColor );
mComposerLabel->setFontColor( newLabelColor ); mComposerLabel->setFontColor( newLabelColor );
mComposerLabel->update(); mComposerLabel->update();
mComposerLabel->endCommand(); mComposerLabel->endCommand();

View File

@ -406,7 +406,7 @@ void QgsComposerLegendWidget::on_mFontColorButton_colorChanged( const QColor& ne
return; return;
} }
mLegend->beginCommand( tr( "Legend font color changed" ) ); mLegend->beginCommand( tr( "Legend font color changed" ), QgsComposerMergeCommand::LegendFontColor );
mLegend->setFontColor( newFontColor ); mLegend->setFontColor( newFontColor );
mLegend->update(); mLegend->update();
mLegend->endCommand(); mLegend->endCommand();
@ -624,7 +624,7 @@ void QgsComposerLegendWidget::on_mRasterBorderColorButton_colorChanged( const QC
return; return;
} }
mLegend->beginCommand( tr( "Legend raster border color" ) ); mLegend->beginCommand( tr( "Legend raster border color" ), QgsComposerMergeCommand::LegendRasterBorderColor );
mLegend->setRasterBorderColor( newColor ); mLegend->setRasterBorderColor( newColor );
mLegend->update(); mLegend->update();
mLegend->endCommand(); mLegend->endCommand();

View File

@ -1730,7 +1730,7 @@ void QgsComposerMapWidget::on_mGridFramePenColorButton_colorChanged( const QColo
return; return;
} }
mComposerMap->beginCommand( tr( "Grid frame color changed" ) ); mComposerMap->beginCommand( tr( "Grid frame color changed" ), QgsComposerMergeCommand::ComposerMapGridFramePenColor );
grid->setFramePenColor( newColor ); grid->setFramePenColor( newColor );
mComposerMap->update(); mComposerMap->update();
mComposerMap->endCommand(); mComposerMap->endCommand();
@ -1744,7 +1744,7 @@ void QgsComposerMapWidget::on_mGridFrameFill1ColorButton_colorChanged( const QCo
return; return;
} }
mComposerMap->beginCommand( tr( "Grid frame first fill color changed" ) ); mComposerMap->beginCommand( tr( "Grid frame first fill color changed" ), QgsComposerMergeCommand::ComposerMapGridFrameFill1Color );
grid->setFrameFillColor1( newColor ); grid->setFrameFillColor1( newColor );
mComposerMap->update(); mComposerMap->update();
mComposerMap->endCommand(); mComposerMap->endCommand();
@ -1758,7 +1758,7 @@ void QgsComposerMapWidget::on_mGridFrameFill2ColorButton_colorChanged( const QCo
return; return;
} }
mComposerMap->beginCommand( tr( "Grid frame second fill color changed" ) ); mComposerMap->beginCommand( tr( "Grid frame second fill color changed" ), QgsComposerMergeCommand::ComposerMapGridFrameFill2Color );
grid->setFrameFillColor2( newColor ); grid->setFrameFillColor2( newColor );
mComposerMap->update(); mComposerMap->update();
mComposerMap->endCommand(); mComposerMap->endCommand();
@ -2077,7 +2077,7 @@ void QgsComposerMapWidget::on_mAnnotationFontColorButton_colorChanged( const QCo
return; return;
} }
mComposerMap->beginCommand( tr( "Annotation color changed" ) ); mComposerMap->beginCommand( tr( "Annotation color changed" ), QgsComposerMergeCommand::ComposerMapGridAnnotationFontColor );
grid->setAnnotationFontColor( color ); grid->setAnnotationFontColor( color );
mComposerMap->update(); mComposerMap->update();
mComposerMap->endCommand(); mComposerMap->endCommand();

View File

@ -633,7 +633,7 @@ void QgsComposerPictureWidget::loadPicturePreviews( bool collapsed )
void QgsComposerPictureWidget::on_mFillColorButton_colorChanged( const QColor& color ) void QgsComposerPictureWidget::on_mFillColorButton_colorChanged( const QColor& color )
{ {
mPicture->beginCommand( tr( "Picture fill color changed" ) ); mPicture->beginCommand( tr( "Picture fill color changed" ), QgsComposerMergeCommand::ComposerPictureFillColor );
mPicture->setSvgFillColor( color ); mPicture->setSvgFillColor( color );
mPicture->endCommand(); mPicture->endCommand();
mPicture->update(); mPicture->update();
@ -641,7 +641,7 @@ void QgsComposerPictureWidget::on_mFillColorButton_colorChanged( const QColor& c
void QgsComposerPictureWidget::on_mOutlineColorButton_colorChanged( const QColor& color ) void QgsComposerPictureWidget::on_mOutlineColorButton_colorChanged( const QColor& color )
{ {
mPicture->beginCommand( tr( "Picture border color changed" ) ); mPicture->beginCommand( tr( "Picture border color changed" ), QgsComposerMergeCommand::ComposerPictureOutlineColor );
mPicture->setSvgBorderColor( color ); mPicture->setSvgBorderColor( color );
mPicture->endCommand(); mPicture->endCommand();
mPicture->update(); mPicture->update();

View File

@ -263,7 +263,7 @@ void QgsComposerScaleBarWidget::on_mFontColorButton_colorChanged( const QColor&
return; return;
} }
mComposerScaleBar->beginCommand( tr( "Scalebar font color changed" ) ); mComposerScaleBar->beginCommand( tr( "Scalebar font color changed" ), QgsComposerMergeCommand::ScaleBarFontColor );
disconnectUpdateSignal(); disconnectUpdateSignal();
mComposerScaleBar->setFontColor( newColor ); mComposerScaleBar->setFontColor( newColor );
mComposerScaleBar->update(); mComposerScaleBar->update();
@ -278,7 +278,7 @@ void QgsComposerScaleBarWidget::on_mFillColorButton_colorChanged( const QColor&
return; return;
} }
mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ) ); mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ), QgsComposerMergeCommand::ScaleBarFillColor );
disconnectUpdateSignal(); disconnectUpdateSignal();
QBrush newBrush = mComposerScaleBar->brush(); QBrush newBrush = mComposerScaleBar->brush();
newBrush.setColor( newColor ); newBrush.setColor( newColor );
@ -295,7 +295,7 @@ void QgsComposerScaleBarWidget::on_mFillColor2Button_colorChanged( const QColor
return; return;
} }
mComposerScaleBar->beginCommand( tr( "Scalebar secondary color changed" ) ); mComposerScaleBar->beginCommand( tr( "Scalebar secondary color changed" ), QgsComposerMergeCommand::ScaleBarFill2Color );
disconnectUpdateSignal(); disconnectUpdateSignal();
QBrush newBrush = mComposerScaleBar->brush2(); QBrush newBrush = mComposerScaleBar->brush2();
newBrush.setColor( newColor ); newBrush.setColor( newColor );
@ -312,7 +312,7 @@ void QgsComposerScaleBarWidget::on_mStrokeColorButton_colorChanged( const QColor
return; return;
} }
mComposerScaleBar->beginCommand( tr( "Scalebar line color changed" ) ); mComposerScaleBar->beginCommand( tr( "Scalebar line color changed" ), QgsComposerMergeCommand::ScaleBarStrokeColor );
disconnectUpdateSignal(); disconnectUpdateSignal();
QPen newPen = mComposerScaleBar->pen(); QPen newPen = mComposerScaleBar->pen();
newPen.setColor( newColor ); newPen.setColor( newColor );

View File

@ -87,9 +87,14 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
//composer label //composer label
ComposerLabelSetText, ComposerLabelSetText,
ComposerLabelSetId, ComposerLabelSetId,
ComposerLabelFontColor,
//composer map //composer map
ComposerMapRotation, ComposerMapRotation,
ComposerMapAnnotationDistance, ComposerMapAnnotationDistance,
ComposerMapGridFramePenColor,
ComposerMapGridFrameFill1Color,
ComposerMapGridFrameFill2Color,
ComposerMapGridAnnotationFontColor,
//composer legend //composer legend
ComposerLegendText, ComposerLegendText,
LegendColumnCount, LegendColumnCount,
@ -107,8 +112,12 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
LegendBoxSpace, LegendBoxSpace,
LegendColumnSpace, LegendColumnSpace,
LegendRasterBorderWidth, LegendRasterBorderWidth,
LegendFontColor,
LegendRasterBorderColor,
//composer picture //composer picture
ComposerPictureRotation, ComposerPictureRotation,
ComposerPictureFillColor,
ComposerPictureOutlineColor,
// composer scalebar // composer scalebar
ScaleBarLineWidth, ScaleBarLineWidth,
ScaleBarHeight, ScaleBarHeight,
@ -119,6 +128,10 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
ScaleBarMapUnitsSegment, ScaleBarMapUnitsSegment,
ScaleBarLabelBarSize, ScaleBarLabelBarSize,
ScaleBarBoxContentSpace, ScaleBarBoxContentSpace,
ScaleBarFontColor,
ScaleBarFillColor,
ScaleBarFill2Color,
ScaleBarStrokeColor,
// composer table // composer table
TableMaximumFeatures, TableMaximumFeatures,
TableMargin, TableMargin,
@ -128,9 +141,13 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
ShapeOutlineWidth, ShapeOutlineWidth,
//composer arrow //composer arrow
ArrowOutlineWidth, ArrowOutlineWidth,
ArrowHeadFillColor,
ArrowHeadOutlineColor,
ArrowHeadWidth, ArrowHeadWidth,
//item //item
ItemOutlineWidth, ItemOutlineWidth,
ItemOutlineColor,
ItemBackgroundColor,
ItemMove, ItemMove,
ItemRotation, ItemRotation,
ItemTransparency, ItemTransparency,

View File

@ -78,7 +78,11 @@ class CORE_EXPORT QgsComposerMultiFrameMergeCommand: public QgsComposerMultiFram
TableMaximumFeatures, TableMaximumFeatures,
TableMargin, TableMargin,
TableGridStrokeWidth, TableGridStrokeWidth,
TableCellStyle TableCellStyle,
TableHeaderFontColor,
TableContentFontColor,
TableGridColor,
TableBackgroundColor,
}; };
QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text ); QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text );