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

View File

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

View File

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

View File

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

View File

@ -210,7 +210,7 @@ void QgsComposerItemWidget::on_mFrameColorButton_colorChanged( const QColor& new
{
return;
}
mItem->beginCommand( tr( "Frame color changed" ) );
mItem->beginCommand( tr( "Frame color changed" ), QgsComposerMergeCommand::ItemOutlineColor );
mItem->setFrameOutlineColor( newFrameColor );
mItem->update();
mItem->endCommand();
@ -230,7 +230,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
{
return;
}
mItem->beginCommand( tr( "Background color changed" ) );
mItem->beginCommand( tr( "Background color changed" ), QgsComposerMergeCommand::ItemBackgroundColor );
mItem->setBackgroundColor( newBackgroundColor );
//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;
}
mComposerLabel->beginCommand( tr( "Label color changed" ) );
mComposerLabel->beginCommand( tr( "Label color changed" ), QgsComposerMergeCommand::ComposerLabelFontColor );
mComposerLabel->setFontColor( newLabelColor );
mComposerLabel->update();
mComposerLabel->endCommand();

View File

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

View File

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

View File

@ -633,7 +633,7 @@ void QgsComposerPictureWidget::loadPicturePreviews( bool collapsed )
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->endCommand();
mPicture->update();
@ -641,7 +641,7 @@ void QgsComposerPictureWidget::on_mFillColorButton_colorChanged( const QColor& c
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->endCommand();
mPicture->update();

View File

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

View File

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

View File

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