Skip to content
Permalink
Browse files
Update core components to use the new QgsColorButton implementation
  • Loading branch information
m-kuhn authored and dakcarto committed Mar 21, 2013
1 parent 4339fdc commit 661df0e446b7a8ef452e5f718800bb40a27c9b92
@@ -435,15 +435,8 @@ void QgsCompositionWidget::on_mOffsetYSpinBox_valueChanged( double d )
}
}

void QgsCompositionWidget::on_mGridColorButton_clicked()
void QgsCompositionWidget::on_mGridColorButton_colorChanged( const QColor &newColor )
{
QColor newColor = QColorDialog::getColor( mGridColorButton->color() );
if ( !newColor.isValid() )
{
return ; //dialog canceled by user
}
mGridColorButton->setColor( newColor );

if ( mComposition )
{
QPen pen = mComposition->gridPen();
@@ -53,7 +53,7 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
void on_mGridResolutionSpinBox_valueChanged( double d );
void on_mOffsetXSpinBox_valueChanged( double d );
void on_mOffsetYSpinBox_valueChanged( double d );
void on_mGridColorButton_clicked();
void on_mGridColorButton_colorChanged( const QColor &newColor );
void on_mGridStyleComboBox_currentIndexChanged( const QString& text );
void on_mPenWidthSpinBox_valueChanged( double d );
void on_mSelectionToleranceSpinBox_valueChanged( double d );
@@ -42,7 +42,11 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
}
mFrameWidthSpinBox->setValue( mItem->frameBorderWidth() );
mFrameColorButton->setColor( mItem->frameColor() );
mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );

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

void QgsAnnotationWidget::on_mFrameColorButton_clicked()
void QgsAnnotationWidget::on_mFrameColorButton_colorChanged( const QColor &color )
{
if ( !mItem )
{
return;
}

#if QT_VERSION >= 0x040500
QColor c = QColorDialog::getColor( mFrameColorButton->color(), 0, tr( "Select frame color" ), QColorDialog::ShowAlphaChannel );
#else
QColor c = QColorDialog::getColor( mFrameColorButton->color() );
#endif
if ( c.isValid() )
{
mFrameColorButton->setColor( c );
mItem->setFrameColor( c );
}
mItem->setFrameColor( color );
}

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

void QgsAnnotationWidget::on_mBackgroundColorButton_clicked()
void QgsAnnotationWidget::on_mBackgroundColorButton_colorChanged( const QColor &color )
{
if ( !mItem )
{
return;
}

QColor bgColor;
#if QT_VERSION >= 0x040500
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor(), 0, tr( "Select background color" ), QColorDialog::ShowAlphaChannel );
#else
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor() );
#endif

if ( bgColor.isValid() )
{
mItem->setFrameBackgroundColor( bgColor );
mBackgroundColorButton->setColor( bgColor );
}
mItem->setFrameBackgroundColor( color );
}

@@ -36,8 +36,8 @@ class QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase

private slots:
void on_mMapMarkerButton_clicked();
void on_mFrameColorButton_clicked();
void on_mBackgroundColorButton_clicked();
void on_mFrameColorButton_colorChanged( const QColor &color );
void on_mBackgroundColorButton_colorChanged( const QColor &color );

private:
QgsAnnotationItem* mItem;
@@ -34,8 +34,8 @@ QgsContinuousColorDialog::QgsContinuousColorDialog( QgsVectorLayer * layer )
setupUi( this );
QgsDebugMsg( "entered." );

QObject::connect( btnMinValue, SIGNAL( clicked() ), this, SLOT( selectMinimumColor() ) );
QObject::connect( btnMaxValue, SIGNAL( clicked() ), this, SLOT( selectMaximumColor() ) );
QObject::connect( btnMinValue, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( selectMinimumColor( const QColor& ) ) );
QObject::connect( btnMaxValue, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( selectMaximumColor( const QColor& ) ) );

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

void QgsContinuousColorDialog::selectMinimumColor()
void QgsContinuousColorDialog::selectMinimumColor( const QColor& color )
{
QColor mincolor = QColorDialog::getColor( btnMinValue->color(), this );
if ( mincolor.isValid() )
{
btnMinValue->setColor( mincolor );
}
Q_UNUSED( color )
activateWindow();
}

void QgsContinuousColorDialog::selectMaximumColor()
void QgsContinuousColorDialog::selectMaximumColor( const QColor& color )
{
QColor maxcolor = QColorDialog::getColor( btnMaxValue->color(), this );
if ( maxcolor.isValid() )
{
btnMaxValue->setColor( maxcolor );
}
Q_UNUSED( color )
activateWindow();
}

@@ -37,8 +37,8 @@ class QgsContinuousColorDialog: public QDialog, private Ui::QgsContinuousColorDi
void apply();

protected slots:
void selectMinimumColor();
void selectMaximumColor();
void selectMinimumColor( const QColor& color );
void selectMaximumColor( const QColor& color );
void on_cb_polygonOutline_clicked();

protected:
@@ -84,14 +84,6 @@ void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
accept();
}

void QgsDecorationScaleBarDialog::on_pbnChangeColor_clicked()
{
QColor color = QColorDialog::getColor( pbnChangeColor->color(), this );

if ( color.isValid() )
pbnChangeColor->setColor( color );
}

void QgsDecorationScaleBarDialog::on_buttonBox_rejected()
{
reject();
@@ -32,7 +32,6 @@ class QgsDecorationScaleBarDialog : public QDialog, private Ui::QgsDecorationSca
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
void on_pbnChangeColor_clicked();

protected:
QgsDecorationScaleBar& mDeco;
@@ -44,6 +44,12 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare

setupUi( this );


mBackgroundColorButton->setColorDialogTitle( tr( "Background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mDiagramPenColorButton->setColorDialogTitle( tr( "Pen color" ) );
mDiagramPenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );

mValueLineEdit->setValidator( new QDoubleValidator( mValueLineEdit ) );
mMinimumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMinimumDiagramScaleLineEdit ) );
mMaximumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMaximumDiagramScaleLineEdit ) );
@@ -386,19 +392,6 @@ void QgsDiagramProperties::on_mRemoveCategoryPushButton_clicked()
}
}

void QgsDiagramProperties::on_mBackgroundColorButton_clicked()
{
#if QT_VERSION >= 0x040500
QColor newColor = QColorDialog::getColor( mBackgroundColorButton->color(), 0, tr( "Background color" ), QColorDialog::ShowAlphaChannel );
#else
QColor newColor = QColorDialog::getColor( mBackgroundColorButton->color() );
#endif
if ( newColor.isValid() )
{
mBackgroundColorButton->setColor( newColor );
}
}

void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
{
//get maximum value from provider (ignoring not-commited edits)
@@ -412,19 +405,6 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
}
}

void QgsDiagramProperties::on_mDiagramPenColorButton_clicked()
{
#if QT_VERSION >= 0x040500
QColor newColor = QColorDialog::getColor( mDiagramPenColorButton->color(), 0, tr( "Pen color" ), QColorDialog::ShowAlphaChannel );
#else
QColor newColor = QColorDialog::getColor( mDiagramPenColorButton->color() );
#endif
if ( newColor.isValid() )
{
mDiagramPenColorButton->setColor( newColor );
}
}

void QgsDiagramProperties::on_mDisplayDiagramsGroupBox_toggled( bool checked )
{
// if enabled show diagram specific options
@@ -38,9 +38,7 @@ class QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPropertiesBas
void on_mTransparencySlider_valueChanged( int value );
void on_mAddCategoryPushButton_clicked();
void on_mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem * item, int column );
void on_mBackgroundColorButton_clicked();
void on_mFindMaximumValueButton_clicked();
void on_mDiagramPenColorButton_clicked();
void on_mDisplayDiagramsGroupBox_toggled( bool checked );
void on_mRemoveCategoryPushButton_clicked();
void on_mDiagramFontButton_clicked();
@@ -48,11 +48,11 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
mRefFont = lblFontPreview->font();
mPreviewSize = 24;

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

void QgsLabelingGui::changeTextColor()
void QgsLabelingGui::changeTextColor( const QColor &color )
{
QColor color = QColorDialog::getColor( btnTextColor->color(), this );
if ( !color.isValid() )
return;

btnTextColor->setColor( color );
Q_UNUSED( color )
updatePreview();
}

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

void QgsLabelingGui::changeBufferColor()
void QgsLabelingGui::changeBufferColor( const QColor &color )
{
QColor color = QColorDialog::getColor( btnBufferColor->color(), this );
if ( !color.isValid() )
return;

btnBufferColor->setColor( color );
Q_UNUSED( color )
updatePreview();
}

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

void QgsLabelingGui::on_mPreviewBackgroundBtn_clicked()
void QgsLabelingGui::on_mPreviewBackgroundBtn_colorChanged( const QColor &color )
{
QColor color = QColorDialog::getColor( mPreviewBackgroundBtn->color(), this );
if ( !color.isValid() )
return;

mPreviewBackgroundBtn->setColor( color );
setPreviewBackground( color );
}

@@ -42,11 +42,11 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
public slots:
void collapseSample( bool collapse );
void apply();
void changeTextColor();
void changeTextColor( const QColor &color );
void changeTextFont();
void showEngineConfigDialog();
void showExpressionDialog();
void changeBufferColor();
void changeBufferColor( const QColor &color );

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

void on_mPreviewTextEdit_textChanged( const QString & text );
void on_mPreviewTextBtn_clicked();
void on_mPreviewBackgroundBtn_clicked();
void on_mPreviewBackgroundBtn_colorChanged( const QColor &color );
void on_mDirectSymbLeftToolBtn_clicked();
void on_mDirectSymbRightToolBtn_clicked();

@@ -109,6 +109,10 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId, const
mMaxScaleSpinBox->setValue( layerSettings.scaleMax );
mHaliComboBox->setCurrentIndex( mHaliComboBox->findText( "Left" ) );
mValiComboBox->setCurrentIndex( mValiComboBox->findText( "Bottom" ) );
mFontColorButton->setColorDialogTitle( tr( "Font color" ) );
mFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mBufferColorButton->setColorDialogTitle( tr( "Buffer color" ) );
mBufferColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );

disableGuiElements();

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

void QgsLabelPropertyDialog::on_mFontColorButton_clicked()
void QgsLabelPropertyDialog::on_mFontColorButton_colorChanged( const QColor &color )
{
#if QT_VERSION >= 0x040500
QColor c = QColorDialog::getColor( mFontColorButton->color(), 0, tr( "Font color" ), QColorDialog::ShowAlphaChannel );
#else
QColor c = QColorDialog::getColor( mFontColorButton->color() );
#endif
if ( c.isValid() )
{
mFontColorButton->setColor( c );
insertChangedValue( QgsPalLayerSettings::Color, c.name() );
}
insertChangedValue( QgsPalLayerSettings::Color, color.name() );
}

void QgsLabelPropertyDialog::on_mBufferColorButton_clicked()
void QgsLabelPropertyDialog::on_mBufferColorButton_colorChanged( const QColor &color )
{
#if QT_VERSION >= 0x040500
QColor c = QColorDialog::getColor( mBufferColorButton->color(), 0, tr( "Buffer color" ), QColorDialog::ShowAlphaChannel );
#else
QColor c = QColorDialog::getColor( mBufferColorButton->color() );
#endif
if ( c.isValid() )
{
mFontColorButton->setColor( c );
insertChangedValue( QgsPalLayerSettings::BufferColor, c.name() );
}
insertChangedValue( QgsPalLayerSettings::BufferColor, color.name() );
}

void QgsLabelPropertyDialog::on_mHaliComboBox_currentIndexChanged( const QString& text )
@@ -48,8 +48,8 @@ class QgsLabelPropertyDialog: public QDialog, private Ui::QgsLabelPropertyDialog
void on_mBufferSizeSpinBox_valueChanged( double d );
void on_mRotationSpinBox_valueChanged( double d );
void on_mFontPushButton_clicked();
void on_mFontColorButton_clicked();
void on_mBufferColorButton_clicked();
void on_mFontColorButton_colorChanged( const QColor &color );
void on_mBufferColorButton_colorChanged( const QColor &color );
void on_mHaliComboBox_currentIndexChanged( const QString& text );
void on_mValiComboBox_currentIndexChanged( const QString& text );
void on_mLabelTextLineEdit_textChanged( const QString& text );

0 comments on commit 661df0e

Please sign in to comment.