Skip to content

Commit 661df0e

Browse files
m-kuhndakcarto
authored andcommitted
Update core components to use the new QgsColorButton implementation
1 parent 4339fdc commit 661df0e

22 files changed

+65
-274
lines changed

src/app/composer/qgscompositionwidget.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,8 @@ void QgsCompositionWidget::on_mOffsetYSpinBox_valueChanged( double d )
435435
}
436436
}
437437

438-
void QgsCompositionWidget::on_mGridColorButton_clicked()
438+
void QgsCompositionWidget::on_mGridColorButton_colorChanged( const QColor &newColor )
439439
{
440-
QColor newColor = QColorDialog::getColor( mGridColorButton->color() );
441-
if ( !newColor.isValid() )
442-
{
443-
return ; //dialog canceled by user
444-
}
445-
mGridColorButton->setColor( newColor );
446-
447440
if ( mComposition )
448441
{
449442
QPen pen = mComposition->gridPen();

src/app/composer/qgscompositionwidget.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
5353
void on_mGridResolutionSpinBox_valueChanged( double d );
5454
void on_mOffsetXSpinBox_valueChanged( double d );
5555
void on_mOffsetYSpinBox_valueChanged( double d );
56-
void on_mGridColorButton_clicked();
56+
void on_mGridColorButton_colorChanged( const QColor &newColor );
5757
void on_mGridStyleComboBox_currentIndexChanged( const QString& text );
5858
void on_mPenWidthSpinBox_valueChanged( double d );
5959
void on_mSelectionToleranceSpinBox_valueChanged( double d );

src/app/qgsannotationwidget.cpp

+8-24
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
4242
}
4343
mFrameWidthSpinBox->setValue( mItem->frameBorderWidth() );
4444
mFrameColorButton->setColor( mItem->frameColor() );
45+
mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
46+
mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
4547
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
48+
mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
49+
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
4650

4751
const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
4852
if ( symbol )
@@ -102,23 +106,14 @@ void QgsAnnotationWidget::on_mMapMarkerButton_clicked()
102106
}
103107
}
104108

105-
void QgsAnnotationWidget::on_mFrameColorButton_clicked()
109+
void QgsAnnotationWidget::on_mFrameColorButton_colorChanged( const QColor &color )
106110
{
107111
if ( !mItem )
108112
{
109113
return;
110114
}
111115

112-
#if QT_VERSION >= 0x040500
113-
QColor c = QColorDialog::getColor( mFrameColorButton->color(), 0, tr( "Select frame color" ), QColorDialog::ShowAlphaChannel );
114-
#else
115-
QColor c = QColorDialog::getColor( mFrameColorButton->color() );
116-
#endif
117-
if ( c.isValid() )
118-
{
119-
mFrameColorButton->setColor( c );
120-
mItem->setFrameColor( c );
121-
}
116+
mItem->setFrameColor( color );
122117
}
123118

124119
void QgsAnnotationWidget::updateCenterIcon()
@@ -131,24 +126,13 @@ void QgsAnnotationWidget::updateCenterIcon()
131126
mMapMarkerButton->setIcon( icon );
132127
}
133128

134-
void QgsAnnotationWidget::on_mBackgroundColorButton_clicked()
129+
void QgsAnnotationWidget::on_mBackgroundColorButton_colorChanged( const QColor &color )
135130
{
136131
if ( !mItem )
137132
{
138133
return;
139134
}
140135

141-
QColor bgColor;
142-
#if QT_VERSION >= 0x040500
143-
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor(), 0, tr( "Select background color" ), QColorDialog::ShowAlphaChannel );
144-
#else
145-
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor() );
146-
#endif
147-
148-
if ( bgColor.isValid() )
149-
{
150-
mItem->setFrameBackgroundColor( bgColor );
151-
mBackgroundColorButton->setColor( bgColor );
152-
}
136+
mItem->setFrameBackgroundColor( color );
153137
}
154138

src/app/qgsannotationwidget.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase
3636

3737
private slots:
3838
void on_mMapMarkerButton_clicked();
39-
void on_mFrameColorButton_clicked();
40-
void on_mBackgroundColorButton_clicked();
39+
void on_mFrameColorButton_colorChanged( const QColor &color );
40+
void on_mBackgroundColorButton_colorChanged( const QColor &color );
4141

4242
private:
4343
QgsAnnotationItem* mItem;

src/app/qgscontinuouscolordialog.cpp

+6-14
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ QgsContinuousColorDialog::QgsContinuousColorDialog( QgsVectorLayer * layer )
3434
setupUi( this );
3535
QgsDebugMsg( "entered." );
3636

37-
QObject::connect( btnMinValue, SIGNAL( clicked() ), this, SLOT( selectMinimumColor() ) );
38-
QObject::connect( btnMaxValue, SIGNAL( clicked() ), this, SLOT( selectMaximumColor() ) );
37+
QObject::connect( btnMinValue, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( selectMinimumColor( const QColor& ) ) );
38+
QObject::connect( btnMaxValue, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( selectMaximumColor( const QColor& ) ) );
3939

4040
//find out the numerical fields of mVectorLayer
4141
const QgsFields & fields = mVectorLayer->pendingFields();
@@ -175,23 +175,15 @@ void QgsContinuousColorDialog::apply()
175175
renderer->setDrawPolygonOutline( drawOutline );
176176
}
177177

178-
void QgsContinuousColorDialog::selectMinimumColor()
178+
void QgsContinuousColorDialog::selectMinimumColor( const QColor& color )
179179
{
180-
QColor mincolor = QColorDialog::getColor( btnMinValue->color(), this );
181-
if ( mincolor.isValid() )
182-
{
183-
btnMinValue->setColor( mincolor );
184-
}
180+
Q_UNUSED( color )
185181
activateWindow();
186182
}
187183

188-
void QgsContinuousColorDialog::selectMaximumColor()
184+
void QgsContinuousColorDialog::selectMaximumColor( const QColor& color )
189185
{
190-
QColor maxcolor = QColorDialog::getColor( btnMaxValue->color(), this );
191-
if ( maxcolor.isValid() )
192-
{
193-
btnMaxValue->setColor( maxcolor );
194-
}
186+
Q_UNUSED( color )
195187
activateWindow();
196188
}
197189

src/app/qgscontinuouscolordialog.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class QgsContinuousColorDialog: public QDialog, private Ui::QgsContinuousColorDi
3737
void apply();
3838

3939
protected slots:
40-
void selectMinimumColor();
41-
void selectMaximumColor();
40+
void selectMinimumColor( const QColor& color );
41+
void selectMaximumColor( const QColor& color );
4242
void on_cb_polygonOutline_clicked();
4343

4444
protected:

src/app/qgsdecorationscalebardialog.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,6 @@ void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
8484
accept();
8585
}
8686

87-
void QgsDecorationScaleBarDialog::on_pbnChangeColor_clicked()
88-
{
89-
QColor color = QColorDialog::getColor( pbnChangeColor->color(), this );
90-
91-
if ( color.isValid() )
92-
pbnChangeColor->setColor( color );
93-
}
94-
9587
void QgsDecorationScaleBarDialog::on_buttonBox_rejected()
9688
{
9789
reject();

src/app/qgsdecorationscalebardialog.h

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class QgsDecorationScaleBarDialog : public QDialog, private Ui::QgsDecorationSca
3232
void on_buttonBox_accepted();
3333
void on_buttonBox_rejected();
3434
void on_buttonBox_helpRequested();
35-
void on_pbnChangeColor_clicked();
3635

3736
protected:
3837
QgsDecorationScaleBar& mDeco;

src/app/qgsdiagramproperties.cpp

+6-26
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
4444

4545
setupUi( this );
4646

47+
48+
mBackgroundColorButton->setColorDialogTitle( tr( "Background color" ) );
49+
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
50+
mDiagramPenColorButton->setColorDialogTitle( tr( "Pen color" ) );
51+
mDiagramPenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
52+
4753
mValueLineEdit->setValidator( new QDoubleValidator( mValueLineEdit ) );
4854
mMinimumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMinimumDiagramScaleLineEdit ) );
4955
mMaximumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMaximumDiagramScaleLineEdit ) );
@@ -386,19 +392,6 @@ void QgsDiagramProperties::on_mRemoveCategoryPushButton_clicked()
386392
}
387393
}
388394

389-
void QgsDiagramProperties::on_mBackgroundColorButton_clicked()
390-
{
391-
#if QT_VERSION >= 0x040500
392-
QColor newColor = QColorDialog::getColor( mBackgroundColorButton->color(), 0, tr( "Background color" ), QColorDialog::ShowAlphaChannel );
393-
#else
394-
QColor newColor = QColorDialog::getColor( mBackgroundColorButton->color() );
395-
#endif
396-
if ( newColor.isValid() )
397-
{
398-
mBackgroundColorButton->setColor( newColor );
399-
}
400-
}
401-
402395
void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
403396
{
404397
//get maximum value from provider (ignoring not-commited edits)
@@ -412,19 +405,6 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
412405
}
413406
}
414407

415-
void QgsDiagramProperties::on_mDiagramPenColorButton_clicked()
416-
{
417-
#if QT_VERSION >= 0x040500
418-
QColor newColor = QColorDialog::getColor( mDiagramPenColorButton->color(), 0, tr( "Pen color" ), QColorDialog::ShowAlphaChannel );
419-
#else
420-
QColor newColor = QColorDialog::getColor( mDiagramPenColorButton->color() );
421-
#endif
422-
if ( newColor.isValid() )
423-
{
424-
mDiagramPenColorButton->setColor( newColor );
425-
}
426-
}
427-
428408
void QgsDiagramProperties::on_mDisplayDiagramsGroupBox_toggled( bool checked )
429409
{
430410
// if enabled show diagram specific options

src/app/qgsdiagramproperties.h

-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ class QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPropertiesBas
3838
void on_mTransparencySlider_valueChanged( int value );
3939
void on_mAddCategoryPushButton_clicked();
4040
void on_mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem * item, int column );
41-
void on_mBackgroundColorButton_clicked();
4241
void on_mFindMaximumValueButton_clicked();
43-
void on_mDiagramPenColorButton_clicked();
4442
void on_mDisplayDiagramsGroupBox_toggled( bool checked );
4543
void on_mRemoveCategoryPushButton_clicked();
4644
void on_mDiagramFontButton_clicked();

src/app/qgslabelinggui.cpp

+7-20
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
4848
mRefFont = lblFontPreview->font();
4949
mPreviewSize = 24;
5050

51-
connect( btnTextColor, SIGNAL( clicked() ), this, SLOT( changeTextColor() ) );
51+
connect( btnTextColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( changeTextColor( const QColor& ) ) );
5252
connect( btnChangeFont, SIGNAL( clicked() ), this, SLOT( changeTextFont() ) );
5353
connect( mFontTranspSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ) );
5454
connect( chkBuffer, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ) );
55-
connect( btnBufferColor, SIGNAL( clicked() ), this, SLOT( changeBufferColor() ) );
55+
connect( btnBufferColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( changeBufferColor( const QColor& ) ) );
5656
connect( spinBufferSize, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ) );
5757
connect( mBufferTranspSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ) );
5858
connect( mBufferJoinStyleComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updatePreview() ) );
@@ -661,13 +661,9 @@ void QgsLabelingGui::populateDataDefinedCombos( QgsPalLayerSettings& s )
661661
setCurrentComboValue( mAlwaysShowAttributeComboBox, s, QgsPalLayerSettings::AlwaysShow );
662662
}
663663

664-
void QgsLabelingGui::changeTextColor()
664+
void QgsLabelingGui::changeTextColor( const QColor &color )
665665
{
666-
QColor color = QColorDialog::getColor( btnTextColor->color(), this );
667-
if ( !color.isValid() )
668-
return;
669-
670-
btnTextColor->setColor( color );
666+
Q_UNUSED( color )
671667
updatePreview();
672668
}
673669

@@ -940,13 +936,9 @@ void QgsLabelingGui::updateUi()
940936
offlineOptions->setEnabled( offline );
941937
}
942938

943-
void QgsLabelingGui::changeBufferColor()
939+
void QgsLabelingGui::changeBufferColor( const QColor &color )
944940
{
945-
QColor color = QColorDialog::getColor( btnBufferColor->color(), this );
946-
if ( !color.isValid() )
947-
return;
948-
949-
btnBufferColor->setColor( color );
941+
Q_UNUSED( color )
950942
updatePreview();
951943
}
952944

@@ -1143,13 +1135,8 @@ void QgsLabelingGui::on_mPreviewTextBtn_clicked()
11431135
updatePreview();
11441136
}
11451137

1146-
void QgsLabelingGui::on_mPreviewBackgroundBtn_clicked()
1138+
void QgsLabelingGui::on_mPreviewBackgroundBtn_colorChanged( const QColor &color )
11471139
{
1148-
QColor color = QColorDialog::getColor( mPreviewBackgroundBtn->color(), this );
1149-
if ( !color.isValid() )
1150-
return;
1151-
1152-
mPreviewBackgroundBtn->setColor( color );
11531140
setPreviewBackground( color );
11541141
}
11551142

src/app/qgslabelinggui.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
4242
public slots:
4343
void collapseSample( bool collapse );
4444
void apply();
45-
void changeTextColor();
45+
void changeTextColor( const QColor &color );
4646
void changeTextFont();
4747
void showEngineConfigDialog();
4848
void showExpressionDialog();
49-
void changeBufferColor();
49+
void changeBufferColor( const QColor &color );
5050

5151
void updateUi();
5252
void updatePreview();
@@ -71,7 +71,7 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
7171

7272
void on_mPreviewTextEdit_textChanged( const QString & text );
7373
void on_mPreviewTextBtn_clicked();
74-
void on_mPreviewBackgroundBtn_clicked();
74+
void on_mPreviewBackgroundBtn_colorChanged( const QColor &color );
7575
void on_mDirectSymbLeftToolBtn_clicked();
7676
void on_mDirectSymbRightToolBtn_clicked();
7777

src/app/qgslabelpropertydialog.cpp

+8-22
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId, const
109109
mMaxScaleSpinBox->setValue( layerSettings.scaleMax );
110110
mHaliComboBox->setCurrentIndex( mHaliComboBox->findText( "Left" ) );
111111
mValiComboBox->setCurrentIndex( mValiComboBox->findText( "Bottom" ) );
112+
mFontColorButton->setColorDialogTitle( tr( "Font color" ) );
113+
mFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
114+
mBufferColorButton->setColorDialogTitle( tr( "Buffer color" ) );
115+
mBufferColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
112116

113117
disableGuiElements();
114118

@@ -326,32 +330,14 @@ void QgsLabelPropertyDialog::on_mFontPushButton_clicked()
326330
}
327331
}
328332

329-
void QgsLabelPropertyDialog::on_mFontColorButton_clicked()
333+
void QgsLabelPropertyDialog::on_mFontColorButton_colorChanged( const QColor &color )
330334
{
331-
#if QT_VERSION >= 0x040500
332-
QColor c = QColorDialog::getColor( mFontColorButton->color(), 0, tr( "Font color" ), QColorDialog::ShowAlphaChannel );
333-
#else
334-
QColor c = QColorDialog::getColor( mFontColorButton->color() );
335-
#endif
336-
if ( c.isValid() )
337-
{
338-
mFontColorButton->setColor( c );
339-
insertChangedValue( QgsPalLayerSettings::Color, c.name() );
340-
}
335+
insertChangedValue( QgsPalLayerSettings::Color, color.name() );
341336
}
342337

343-
void QgsLabelPropertyDialog::on_mBufferColorButton_clicked()
338+
void QgsLabelPropertyDialog::on_mBufferColorButton_colorChanged( const QColor &color )
344339
{
345-
#if QT_VERSION >= 0x040500
346-
QColor c = QColorDialog::getColor( mBufferColorButton->color(), 0, tr( "Buffer color" ), QColorDialog::ShowAlphaChannel );
347-
#else
348-
QColor c = QColorDialog::getColor( mBufferColorButton->color() );
349-
#endif
350-
if ( c.isValid() )
351-
{
352-
mFontColorButton->setColor( c );
353-
insertChangedValue( QgsPalLayerSettings::BufferColor, c.name() );
354-
}
340+
insertChangedValue( QgsPalLayerSettings::BufferColor, color.name() );
355341
}
356342

357343
void QgsLabelPropertyDialog::on_mHaliComboBox_currentIndexChanged( const QString& text )

src/app/qgslabelpropertydialog.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class QgsLabelPropertyDialog: public QDialog, private Ui::QgsLabelPropertyDialog
4848
void on_mBufferSizeSpinBox_valueChanged( double d );
4949
void on_mRotationSpinBox_valueChanged( double d );
5050
void on_mFontPushButton_clicked();
51-
void on_mFontColorButton_clicked();
52-
void on_mBufferColorButton_clicked();
51+
void on_mFontColorButton_colorChanged( const QColor &color );
52+
void on_mBufferColorButton_colorChanged( const QColor &color );
5353
void on_mHaliComboBox_currentIndexChanged( const QString& text );
5454
void on_mValiComboBox_currentIndexChanged( const QString& text );
5555
void on_mLabelTextLineEdit_textChanged( const QString& text );

0 commit comments

Comments
 (0)