Skip to content

Commit 521cc3b

Browse files
committed
[composer] Merge color change undo commands
Avoids color modifications spamming the undo stack
1 parent 028db7e commit 521cc3b

12 files changed

+65
-23
lines changed

python/core/composer/qgscomposeritemcommand.sip

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
4949
//composer label
5050
ComposerLabelSetText,
5151
ComposerLabelSetId,
52+
ComposerLabelFontColor,
5253
//composer map
5354
ComposerMapRotation,
5455
ComposerMapAnnotationDistance,
56+
ComposerMapGridFramePenColor,
57+
ComposerMapGridFrameFill1Color,
58+
ComposerMapGridFrameFill2Color,
59+
ComposerMapGridAnnotationFontColor,
5560
//composer legend
5661
ComposerLegendText,
5762
LegendColumnCount,
@@ -69,8 +74,12 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
6974
LegendBoxSpace,
7075
LegendColumnSpace,
7176
LegendRasterBorderWidth,
77+
LegendFontColor,
78+
LegendRasterBorderColor,
7279
//composer picture
7380
ComposerPictureRotation,
81+
ComposerPictureFillColor,
82+
ComposerPictureOutlineColor,
7483
// composer scalebar
7584
ScaleBarLineWidth,
7685
ScaleBarHeight,
@@ -81,6 +90,10 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
8190
ScaleBarMapUnitsSegment,
8291
ScaleBarLabelBarSize,
8392
ScaleBarBoxContentSpace,
93+
ScaleBarFontColor,
94+
ScaleBarFillColor,
95+
ScaleBarFill2Color,
96+
ScaleBarStrokeColor,
8497
// composer table
8598
TableMaximumFeatures,
8699
TableMargin,
@@ -90,9 +103,13 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
90103
ShapeOutlineWidth,
91104
//composer arrow
92105
ArrowOutlineWidth,
106+
ArrowHeadFillColor,
107+
ArrowHeadOutlineColor,
93108
ArrowHeadWidth,
94109
//item
95110
ItemOutlineWidth,
111+
ItemOutlineColor,
112+
ItemBackgroundColor,
96113
ItemMove,
97114
ItemRotation,
98115
ItemTransparency,

python/core/composer/qgscomposermultiframecommand.sip

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ class QgsComposerMultiFrameMergeCommand: QgsComposerMultiFrameCommand
4949
TableMaximumFeatures,
5050
TableMargin,
5151
TableGridStrokeWidth,
52-
TableCellStyle
52+
TableCellStyle,
53+
TableHeaderFontColor,
54+
TableContentFontColor,
55+
TableGridColor,
56+
TableBackgroundColor,
5357
};
5458

5559
QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text );

src/app/composer/qgscomposerarrowwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void QgsComposerArrowWidget::on_mArrowHeadFillColorButton_colorChanged( const QC
9999
return;
100100
}
101101

102-
mArrow->beginCommand( tr( "Arrow head fill color" ) );
102+
mArrow->beginCommand( tr( "Arrow head fill color" ), QgsComposerMergeCommand::ArrowHeadFillColor );
103103
mArrow->setArrowHeadFillColor( newColor );
104104
mArrow->update();
105105
mArrow->endCommand();
@@ -112,7 +112,7 @@ void QgsComposerArrowWidget::on_mArrowHeadOutlineColorButton_colorChanged( const
112112
return;
113113
}
114114

115-
mArrow->beginCommand( tr( "Arrow head outline color" ) );
115+
mArrow->beginCommand( tr( "Arrow head outline color" ), QgsComposerMergeCommand::ArrowHeadOutlineColor );
116116
mArrow->setArrowHeadOutlineColor( newColor );
117117
mArrow->update();
118118
mArrow->endCommand();

src/app/composer/qgscomposerattributetablewidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void QgsComposerAttributeTableWidget::on_mHeaderFontColorButton_colorChanged( co
269269
QgsComposition* composition = mComposerTable->composition();
270270
if ( composition )
271271
{
272-
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font color" ) );
272+
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font color" ), QgsComposerMultiFrameMergeCommand::TableHeaderFontColor );
273273
}
274274
mComposerTable->setHeaderFontColor( newColor );
275275
if ( composition )
@@ -310,7 +310,7 @@ void QgsComposerAttributeTableWidget::on_mContentFontColorButton_colorChanged( c
310310
QgsComposition* composition = mComposerTable->composition();
311311
if ( composition )
312312
{
313-
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font color" ) );
313+
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font color" ), QgsComposerMultiFrameMergeCommand::TableContentFontColor );
314314
}
315315
mComposerTable->setContentFontColor( newColor );
316316
if ( composition )
@@ -348,7 +348,7 @@ void QgsComposerAttributeTableWidget::on_mGridColorButton_colorChanged( const QC
348348
QgsComposition* composition = mComposerTable->composition();
349349
if ( composition )
350350
{
351-
composition->beginMultiFrameCommand( mComposerTable, tr( "Table grid color" ) );
351+
composition->beginMultiFrameCommand( mComposerTable, tr( "Table grid color" ), QgsComposerMultiFrameMergeCommand::TableGridColor );
352352
}
353353
mComposerTable->setGridColor( newColor );
354354
if ( composition )
@@ -386,7 +386,7 @@ void QgsComposerAttributeTableWidget::on_mBackgroundColorButton_colorChanged( co
386386
QgsComposition* composition = mComposerTable->composition();
387387
if ( composition )
388388
{
389-
composition->beginMultiFrameCommand( mComposerTable, tr( "Table background color" ) );
389+
composition->beginMultiFrameCommand( mComposerTable, tr( "Table background color" ), QgsComposerMultiFrameMergeCommand::TableBackgroundColor );
390390
}
391391
mComposerTable->setBackgroundColor( newColor );
392392
if ( composition )

src/app/composer/qgscomposeritemwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void QgsComposerItemWidget::on_mFrameColorButton_colorChanged( const QColor& new
210210
{
211211
return;
212212
}
213-
mItem->beginCommand( tr( "Frame color changed" ) );
213+
mItem->beginCommand( tr( "Frame color changed" ), QgsComposerMergeCommand::ItemOutlineColor );
214214
mItem->setFrameOutlineColor( newFrameColor );
215215
mItem->update();
216216
mItem->endCommand();
@@ -230,7 +230,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_colorChanged( const QColor
230230
{
231231
return;
232232
}
233-
mItem->beginCommand( tr( "Background color changed" ) );
233+
mItem->beginCommand( tr( "Background color changed" ), QgsComposerMergeCommand::ItemBackgroundColor );
234234
mItem->setBackgroundColor( newBackgroundColor );
235235

236236
//if the item is a composer map, we need to regenerate the map image

src/app/composer/qgscomposerlabelwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void QgsComposerLabelWidget::on_mFontColorButton_colorChanged( const QColor &new
125125
return;
126126
}
127127

128-
mComposerLabel->beginCommand( tr( "Label color changed" ) );
128+
mComposerLabel->beginCommand( tr( "Label color changed" ), QgsComposerMergeCommand::ComposerLabelFontColor );
129129
mComposerLabel->setFontColor( newLabelColor );
130130
mComposerLabel->update();
131131
mComposerLabel->endCommand();

src/app/composer/qgscomposerlegendwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ void QgsComposerLegendWidget::on_mFontColorButton_colorChanged( const QColor& ne
406406
return;
407407
}
408408

409-
mLegend->beginCommand( tr( "Legend font color changed" ) );
409+
mLegend->beginCommand( tr( "Legend font color changed" ), QgsComposerMergeCommand::LegendFontColor );
410410
mLegend->setFontColor( newFontColor );
411411
mLegend->update();
412412
mLegend->endCommand();
@@ -624,7 +624,7 @@ void QgsComposerLegendWidget::on_mRasterBorderColorButton_colorChanged( const QC
624624
return;
625625
}
626626

627-
mLegend->beginCommand( tr( "Legend raster border color" ) );
627+
mLegend->beginCommand( tr( "Legend raster border color" ), QgsComposerMergeCommand::LegendRasterBorderColor );
628628
mLegend->setRasterBorderColor( newColor );
629629
mLegend->update();
630630
mLegend->endCommand();

src/app/composer/qgscomposermapwidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ void QgsComposerMapWidget::on_mGridFramePenColorButton_colorChanged( const QColo
17301730
return;
17311731
}
17321732

1733-
mComposerMap->beginCommand( tr( "Grid frame color changed" ) );
1733+
mComposerMap->beginCommand( tr( "Grid frame color changed" ), QgsComposerMergeCommand::ComposerMapGridFramePenColor );
17341734
grid->setFramePenColor( newColor );
17351735
mComposerMap->update();
17361736
mComposerMap->endCommand();
@@ -1744,7 +1744,7 @@ void QgsComposerMapWidget::on_mGridFrameFill1ColorButton_colorChanged( const QCo
17441744
return;
17451745
}
17461746

1747-
mComposerMap->beginCommand( tr( "Grid frame first fill color changed" ) );
1747+
mComposerMap->beginCommand( tr( "Grid frame first fill color changed" ), QgsComposerMergeCommand::ComposerMapGridFrameFill1Color );
17481748
grid->setFrameFillColor1( newColor );
17491749
mComposerMap->update();
17501750
mComposerMap->endCommand();
@@ -1758,7 +1758,7 @@ void QgsComposerMapWidget::on_mGridFrameFill2ColorButton_colorChanged( const QCo
17581758
return;
17591759
}
17601760

1761-
mComposerMap->beginCommand( tr( "Grid frame second fill color changed" ) );
1761+
mComposerMap->beginCommand( tr( "Grid frame second fill color changed" ), QgsComposerMergeCommand::ComposerMapGridFrameFill2Color );
17621762
grid->setFrameFillColor2( newColor );
17631763
mComposerMap->update();
17641764
mComposerMap->endCommand();
@@ -2077,7 +2077,7 @@ void QgsComposerMapWidget::on_mAnnotationFontColorButton_colorChanged( const QCo
20772077
return;
20782078
}
20792079

2080-
mComposerMap->beginCommand( tr( "Annotation color changed" ) );
2080+
mComposerMap->beginCommand( tr( "Annotation color changed" ), QgsComposerMergeCommand::ComposerMapGridAnnotationFontColor );
20812081
grid->setAnnotationFontColor( color );
20822082
mComposerMap->update();
20832083
mComposerMap->endCommand();

src/app/composer/qgscomposerpicturewidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,15 +633,15 @@ void QgsComposerPictureWidget::loadPicturePreviews( bool collapsed )
633633

634634
void QgsComposerPictureWidget::on_mFillColorButton_colorChanged( const QColor& color )
635635
{
636-
mPicture->beginCommand( tr( "Picture fill color changed" ) );
636+
mPicture->beginCommand( tr( "Picture fill color changed" ), QgsComposerMergeCommand::ComposerPictureFillColor );
637637
mPicture->setSvgFillColor( color );
638638
mPicture->endCommand();
639639
mPicture->update();
640640
}
641641

642642
void QgsComposerPictureWidget::on_mOutlineColorButton_colorChanged( const QColor& color )
643643
{
644-
mPicture->beginCommand( tr( "Picture border color changed" ) );
644+
mPicture->beginCommand( tr( "Picture border color changed" ), QgsComposerMergeCommand::ComposerPictureOutlineColor );
645645
mPicture->setSvgBorderColor( color );
646646
mPicture->endCommand();
647647
mPicture->update();

src/app/composer/qgscomposerscalebarwidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void QgsComposerScaleBarWidget::on_mFontColorButton_colorChanged( const QColor&
263263
return;
264264
}
265265

266-
mComposerScaleBar->beginCommand( tr( "Scalebar font color changed" ) );
266+
mComposerScaleBar->beginCommand( tr( "Scalebar font color changed" ), QgsComposerMergeCommand::ScaleBarFontColor );
267267
disconnectUpdateSignal();
268268
mComposerScaleBar->setFontColor( newColor );
269269
mComposerScaleBar->update();
@@ -278,7 +278,7 @@ void QgsComposerScaleBarWidget::on_mFillColorButton_colorChanged( const QColor&
278278
return;
279279
}
280280

281-
mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ) );
281+
mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ), QgsComposerMergeCommand::ScaleBarFillColor );
282282
disconnectUpdateSignal();
283283
QBrush newBrush = mComposerScaleBar->brush();
284284
newBrush.setColor( newColor );
@@ -295,7 +295,7 @@ void QgsComposerScaleBarWidget::on_mFillColor2Button_colorChanged( const QColor
295295
return;
296296
}
297297

298-
mComposerScaleBar->beginCommand( tr( "Scalebar secondary color changed" ) );
298+
mComposerScaleBar->beginCommand( tr( "Scalebar secondary color changed" ), QgsComposerMergeCommand::ScaleBarFill2Color );
299299
disconnectUpdateSignal();
300300
QBrush newBrush = mComposerScaleBar->brush2();
301301
newBrush.setColor( newColor );
@@ -312,7 +312,7 @@ void QgsComposerScaleBarWidget::on_mStrokeColorButton_colorChanged( const QColor
312312
return;
313313
}
314314

315-
mComposerScaleBar->beginCommand( tr( "Scalebar line color changed" ) );
315+
mComposerScaleBar->beginCommand( tr( "Scalebar line color changed" ), QgsComposerMergeCommand::ScaleBarStrokeColor );
316316
disconnectUpdateSignal();
317317
QPen newPen = mComposerScaleBar->pen();
318318
newPen.setColor( newColor );

src/core/composer/qgscomposeritemcommand.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
8787
//composer label
8888
ComposerLabelSetText,
8989
ComposerLabelSetId,
90+
ComposerLabelFontColor,
9091
//composer map
9192
ComposerMapRotation,
9293
ComposerMapAnnotationDistance,
94+
ComposerMapGridFramePenColor,
95+
ComposerMapGridFrameFill1Color,
96+
ComposerMapGridFrameFill2Color,
97+
ComposerMapGridAnnotationFontColor,
9398
//composer legend
9499
ComposerLegendText,
95100
LegendColumnCount,
@@ -107,8 +112,12 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
107112
LegendBoxSpace,
108113
LegendColumnSpace,
109114
LegendRasterBorderWidth,
115+
LegendFontColor,
116+
LegendRasterBorderColor,
110117
//composer picture
111118
ComposerPictureRotation,
119+
ComposerPictureFillColor,
120+
ComposerPictureOutlineColor,
112121
// composer scalebar
113122
ScaleBarLineWidth,
114123
ScaleBarHeight,
@@ -119,6 +128,10 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
119128
ScaleBarMapUnitsSegment,
120129
ScaleBarLabelBarSize,
121130
ScaleBarBoxContentSpace,
131+
ScaleBarFontColor,
132+
ScaleBarFillColor,
133+
ScaleBarFill2Color,
134+
ScaleBarStrokeColor,
122135
// composer table
123136
TableMaximumFeatures,
124137
TableMargin,
@@ -128,9 +141,13 @@ class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
128141
ShapeOutlineWidth,
129142
//composer arrow
130143
ArrowOutlineWidth,
144+
ArrowHeadFillColor,
145+
ArrowHeadOutlineColor,
131146
ArrowHeadWidth,
132147
//item
133148
ItemOutlineWidth,
149+
ItemOutlineColor,
150+
ItemBackgroundColor,
134151
ItemMove,
135152
ItemRotation,
136153
ItemTransparency,

src/core/composer/qgscomposermultiframecommand.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ class CORE_EXPORT QgsComposerMultiFrameMergeCommand: public QgsComposerMultiFram
7878
TableMaximumFeatures,
7979
TableMargin,
8080
TableGridStrokeWidth,
81-
TableCellStyle
81+
TableCellStyle,
82+
TableHeaderFontColor,
83+
TableContentFontColor,
84+
TableGridColor,
85+
TableBackgroundColor,
8286
};
8387

8488
QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text );

0 commit comments

Comments
 (0)