Skip to content

Commit

Permalink
[composer] Flip all color buttons to QgsColorButtonV2
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 11, 2014
1 parent 856341d commit d8f2120
Show file tree
Hide file tree
Showing 16 changed files with 520 additions and 184 deletions.
15 changes: 11 additions & 4 deletions src/app/composer/qgscomposerarrowwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ QgsComposerArrowWidget::QgsComposerArrowWidget( QgsComposerArrow* arrow ): QgsCo
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, mArrow );
mainLayout->addWidget( itemPropertiesWidget );

mArrowHeadOutlineColorButton->setColorDialogTitle( tr( "Select arrow head outline color" ) );
mArrowHeadOutlineColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mArrowHeadOutlineColorButton->setContext( "composer" );
mArrowHeadOutlineColorButton->setNoColorString( tr( "Transparent outline" ) );
mArrowHeadOutlineColorButton->setShowNoColor( true );
mArrowHeadFillColorButton->setColorDialogTitle( tr( "Select arrow head fill color" ) );
mArrowHeadFillColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mArrowHeadFillColorButton->setContext( "composer" );
mArrowHeadFillColorButton->setNoColorString( tr( "Transparent fill" ) );
mArrowHeadFillColorButton->setShowNoColor( true );

setGuiElementValues();

if ( arrow )
Expand Down Expand Up @@ -131,11 +142,7 @@ void QgsComposerArrowWidget::setGuiElementValues()

blockAllSignals( true );
mArrowHeadFillColorButton->setColor( mArrow->arrowHeadFillColor() );
mArrowHeadFillColorButton->setColorDialogTitle( tr( "Select arrow head fill color" ) );
mArrowHeadFillColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mArrowHeadOutlineColorButton->setColor( mArrow->arrowHeadOutlineColor() );
mArrowHeadOutlineColorButton->setColorDialogTitle( tr( "Select arrow head outline color" ) );
mArrowHeadOutlineColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mOutlineWidthSpinBox->setValue( mArrow->arrowHeadOutlineWidth() );
mArrowHeadWidthSpinBox->setValue( mArrow->arrowHeadWidth() );

Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,10 @@ void QgsComposerItemWidget::setValuesForGuiElements()

mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mBackgroundColorButton->setContext( "composer" );
mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mFrameColorButton->setContext( "composer" );

setValuesForGuiPositionElements();
setValuesForGuiNonPositionElements();
Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgscomposerlabelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel* label ): QgsCo
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, label );
mainLayout->addWidget( itemPropertiesWidget );

mFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mFontColorButton->setContext( "composer" );

if ( mComposerLabel )
{
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposerlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend* legend ): Q
mMoveDownToolButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.png" ) ) );
mCountToolButton->setIcon( QIcon( QgsApplication::iconPath( "mActionSum.png" ) ) );

mFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mFontColorButton->setContext( "composer" );

//add widget for item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, legend );
mainLayout->addWidget( itemPropertiesWidget );
Expand Down
12 changes: 12 additions & 0 deletions src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QgsCo

mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mAnnotationFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mAnnotationFontColorButton->setContext( "composer" );

insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
Expand All @@ -83,10 +84,21 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QgsCo

mGridFramePenColorButton->setColorDialogTitle( tr( "Select grid frame color" ) );
mGridFramePenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mGridFramePenColorButton->setContext( "composer" );
mGridFramePenColorButton->setNoColorString( tr( "Transparent frame" ) );
mGridFramePenColorButton->setShowNoColor( true );

mGridFrameFill1ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) );
mGridFrameFill1ColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mGridFrameFill1ColorButton->setContext( "composer" );
mGridFrameFill1ColorButton->setNoColorString( tr( "Transparent fill" ) );
mGridFrameFill1ColorButton->setShowNoColor( true );

mGridFrameFill2ColorButton->setColorDialogTitle( tr( "Select grid frame fill color" ) );
mGridFrameFill2ColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mGridFrameFill2ColorButton->setContext( "composer" );
mGridFrameFill2ColorButton->setNoColorString( tr( "Transparent fill" ) );
mGridFrameFill2ColorButton->setShowNoColor( true );

//set initial state of frame style controls
toggleFrameControls( false );
Expand Down
13 changes: 13 additions & 0 deletions src/app/composer/qgscomposerscalebarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,25 @@ QgsComposerScaleBarWidget::QgsComposerScaleBarWidget( QgsComposerScaleBar* scale

mFillColorButton->setColorDialogTitle( tr( "Select fill color" ) );
mFillColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mFillColorButton->setContext( "composer" );
mFillColorButton->setNoColorString( tr( "Transparent fill" ) );
mFillColorButton->setShowNoColor( true );

mFillColor2Button->setColorDialogTitle( tr( "Select alternate fill color" ) );
mFillColor2Button->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mFillColor2Button->setContext( "composer" );
mFillColor2Button->setNoColorString( tr( "Transparent fill" ) );
mFillColor2Button->setShowNoColor( true );

mFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mFontColorButton->setContext( "composer" );

mStrokeColorButton->setColorDialogTitle( tr( "Select stroke color" ) );
mStrokeColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mStrokeColorButton->setContext( "composer" );
mStrokeColorButton->setNoColorString( tr( "Transparent stroke" ) );
mStrokeColorButton->setShowNoColor( true );

blockMemberSignals( false );
setGuiElements(); //set the GUI elements to the state of scaleBar
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposertablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table

mHeaderFontColorButton->setColorDialogTitle( tr( "Select header font color" ) );
mHeaderFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mHeaderFontColorButton->setContext( "composer" );
mContentFontColorButton->setColorDialogTitle( tr( "Select content font color" ) );
mContentFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mContentFontColorButton->setContext( "composer" );
mGridColorButton->setColorDialogTitle( tr( "Select grid color" ) );
mGridColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mGridColorButton->setContext( "composer" );

updateGuiElements();
on_mComposerMapComboBox_activated( mComposerMapComboBox->currentIndex() );
Expand Down
9 changes: 8 additions & 1 deletion src/gui/qgscolorswatchgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ QgsColorSwatchGrid::QgsColorSwatchGrid( QgsColorScheme* scheme, QString context,
, mCurrentHoverBox( -1 )
, mFocused( false )
, mCurrentFocusBox( 0 )
, mPressedOnWidget( false )
{
//need to receive all mouse over events
setMouseTracking( true );
Expand Down Expand Up @@ -143,10 +144,16 @@ void QgsColorSwatchGrid::mousePressEvent( QMouseEvent *event )
mDrawBoxDepressed = true;
repaint();
}
mPressedOnWidget = true;
}

void QgsColorSwatchGrid::mouseReleaseEvent( QMouseEvent *event )
{
if ( ! mPressedOnWidget )
{
return;
}

int box = swatchForPosition( event->pos() );
if ( mDrawBoxDepressed && event->button() == Qt::LeftButton )
{
Expand All @@ -158,7 +165,7 @@ void QgsColorSwatchGrid::mouseReleaseEvent( QMouseEvent *event )
if ( box >= 0 && box < mColors.length() && event->button() == Qt::LeftButton )
{
//color clicked
emit colorChanged( mColors.at( mCurrentHoverBox ).first );
emit colorChanged( mColors.at( box ).first );
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgscolorswatchgrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class GUI_EXPORT QgsColorSwatchGrid: public QWidget

int mWidth;

bool mPressedOnWidget;

/**Calculate height of widget based on number of colors
* @returns required height of widget in pixels
*/
Expand Down
Loading

0 comments on commit d8f2120

Please sign in to comment.