Skip to content

Commit

Permalink
[composer] Change remaining color push buttons into QgsColorButtons
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 16, 2014
1 parent 61c3704 commit 738107a
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 77 deletions.
14 changes: 6 additions & 8 deletions src/app/composer/qgscomposerlabelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,15 @@ void QgsComposerLabelWidget::on_mMarginDoubleSpinBox_valueChanged( double d )
}
}

void QgsComposerLabelWidget::on_mFontColorButton_clicked()
void QgsComposerLabelWidget::on_mFontColorButton_colorChanged( const QColor &newLabelColor )
{
if ( !mComposerLabel )
{
return;
}
QColor newColor = QColorDialog::getColor( mComposerLabel->fontColor() );
if ( !newColor.isValid() )
{
return;
}
mComposerLabel->beginCommand( tr( "Label font changed" ) );
mComposerLabel->setFontColor( newColor );

mComposerLabel->beginCommand( tr( "Label color changed" ) );
mComposerLabel->setFontColor( newLabelColor );
mComposerLabel->endCommand();
}

Expand Down Expand Up @@ -241,6 +237,7 @@ void QgsComposerLabelWidget::setGuiElementValues()
mLeftRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignLeft );
mCenterRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignHCenter );
mRightRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignRight );
mFontColorButton->setColor( mComposerLabel->fontColor() );
blockAllSignals( false );
}

Expand All @@ -255,4 +252,5 @@ void QgsComposerLabelWidget::blockAllSignals( bool block )
mLeftRadioButton->blockSignals( block );
mCenterRadioButton->blockSignals( block );
mRightRadioButton->blockSignals( block );
mFontColorButton->blockSignals( block );
}
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposerlabelwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class QgsComposerLabelWidget: public QWidget, private Ui::QgsComposerLabelWidget
void on_mFontButton_clicked();
void on_mInsertExpressionButton_clicked();
void on_mMarginDoubleSpinBox_valueChanged( double d );
void on_mFontColorButton_clicked();
void on_mFontColorButton_colorChanged( const QColor& newLabelColor );
void on_mCenterRadioButton_clicked();
void on_mLeftRadioButton_clicked();
void on_mRightRadioButton_clicked();
Expand Down
14 changes: 4 additions & 10 deletions src/app/composer/qgscomposerlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ void QgsComposerLegendWidget::setGuiElements()
{
mMapComboBox->setCurrentIndex( mMapComboBox->findData( -1 ) );
}
mFontColorButton->setColor( mLegend->fontColor() );
blockAllSignals( false );
}

Expand Down Expand Up @@ -472,23 +473,15 @@ void QgsComposerLegendWidget::on_mItemFontButton_clicked()
}
}

void QgsComposerLegendWidget::on_mFontColorPushButton_clicked()
void QgsComposerLegendWidget::on_mFontColorButton_colorChanged( const QColor& newFontColor )
{
if ( !mLegend )
{
return;
}

QColor oldColor = mLegend->fontColor();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mLegend->beginCommand( tr( "Legend font color changed" ) );
mLegend->setFontColor( newColor );
mLegend->setFontColor( newFontColor );
mLegend->update();
mLegend->endCommand();
}
Expand Down Expand Up @@ -947,6 +940,7 @@ void QgsComposerLegendWidget::blockAllSignals( bool b )
mIconLabelSpaceSpinBox->blockSignals( b );
mBoxSpaceSpinBox->blockSignals( b );
mColumnSpaceSpinBox->blockSignals( b );
mFontColorButton->blockSignals( b );
}

void QgsComposerLegendWidget::refreshMapComboBox()
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposerlegendwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class QgsComposerLegendWidget: public QWidget, private Ui::QgsComposerLegendWidg
void on_mGroupFontButton_clicked();
void on_mLayerFontButton_clicked();
void on_mItemFontButton_clicked();
void on_mFontColorPushButton_clicked();
void on_mFontColorButton_colorChanged( const QColor& newFontColor );
void on_mBoxSpaceSpinBox_valueChanged( double d );
void on_mColumnSpaceSpinBox_valueChanged( double d );
void on_mCheckBoxAutoUpdate_stateChanged( int state );
Expand Down
44 changes: 13 additions & 31 deletions src/app/composer/qgscomposerscalebarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ void QgsComposerScaleBarWidget::setGuiElements()
mUnitLabelLineEdit->setText( mComposerScaleBar->unitLabeling() );
mLineJoinStyleCombo->setPenJoinStyle( mComposerScaleBar->lineJoinStyle() );
mLineCapStyleCombo->setPenCapStyle( mComposerScaleBar->lineCapStyle() );
mFontColorButton->setColor( mComposerScaleBar->fontColor() );
mFillColorButton->setColor( mComposerScaleBar->brush().color() );
mStrokeColorButton->setColor( mComposerScaleBar->pen().color() );

//map combo box
if ( mComposerScaleBar->composerMap() )
Expand Down Expand Up @@ -301,21 +304,13 @@ void QgsComposerScaleBarWidget::on_mFontButton_clicked()
mComposerScaleBar->update();
}

void QgsComposerScaleBarWidget::on_mFontColorPushButton_clicked()
void QgsComposerScaleBarWidget::on_mFontColorButton_colorChanged( const QColor& newColor )
{
if ( !mComposerScaleBar )
{
return;
}

QColor oldColor = mComposerScaleBar->fontColor();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar font color changed" ) );
disconnectUpdateSignal();
mComposerScaleBar->setFontColor( newColor );
Expand All @@ -324,21 +319,13 @@ void QgsComposerScaleBarWidget::on_mFontColorPushButton_clicked()
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mColorPushButton_clicked()
void QgsComposerScaleBarWidget::on_mFillColorButton_colorChanged( const QColor& newColor )
{
if ( !mComposerScaleBar )
{
return;
}

QColor oldColor = mComposerScaleBar->brush().color();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ) );
disconnectUpdateSignal();
QBrush newBrush( newColor );
Expand All @@ -348,21 +335,13 @@ void QgsComposerScaleBarWidget::on_mColorPushButton_clicked()
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mStrokeColorPushButton_clicked()
void QgsComposerScaleBarWidget::on_mStrokeColorButton_colorChanged( const QColor& newColor )
{
if ( !mComposerScaleBar )
{
return;
}

QColor oldColor = mComposerScaleBar->pen().color();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar stroke color changed" ) );
disconnectUpdateSignal();
QPen newPen = mComposerScaleBar->pen();
Expand Down Expand Up @@ -462,8 +441,8 @@ void QgsComposerScaleBarWidget::toggleStyleSpecificControls( const QString& styl
mGroupBoxSegments->setCollapsed( true );
mLabelBarSpaceSpinBox->setEnabled( false );
mLineWidthSpinBox->setEnabled( false );
mColorPushButton->setEnabled( false );
mStrokeColorPushButton->setEnabled( false );
mFillColorButton->setEnabled( false );
mStrokeColorButton->setEnabled( false );
mLineJoinStyleCombo->setEnabled( false );
mLineCapStyleCombo->setEnabled( false );
}
Expand All @@ -474,8 +453,8 @@ void QgsComposerScaleBarWidget::toggleStyleSpecificControls( const QString& styl
mGroupBoxSegments->setEnabled( true );
mLabelBarSpaceSpinBox->setEnabled( true );
mLineWidthSpinBox->setEnabled( true );
mColorPushButton->setEnabled( true );
mStrokeColorPushButton->setEnabled( true );
mFillColorButton->setEnabled( true );
mStrokeColorButton->setEnabled( true );
if ( style == "Single Box" || style == "Double Box" )
{
mLineJoinStyleCombo->setEnabled( true );
Expand Down Expand Up @@ -600,6 +579,9 @@ void QgsComposerScaleBarWidget::blockMemberSignals( bool block )
mUnitsComboBox->blockSignals( block );
mLineJoinStyleCombo->blockSignals( block );
mLineCapStyleCombo->blockSignals( block );
mFontColorButton->blockSignals( block );
mFillColorButton->blockSignals( block );
mStrokeColorButton->blockSignals( block );
}

void QgsComposerScaleBarWidget::connectUpdateSignal()
Expand Down
6 changes: 3 additions & 3 deletions src/app/composer/qgscomposerscalebarwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class QgsComposerScaleBarWidget: public QWidget, private Ui::QgsComposerScaleBar
void on_mNumberOfSegmentsSpinBox_valueChanged( int i );
void on_mUnitLabelLineEdit_textChanged( const QString& text );
void on_mMapUnitsPerBarUnitSpinBox_valueChanged( double d );
void on_mColorPushButton_clicked();
void on_mStrokeColorPushButton_clicked();
void on_mFontButton_clicked();
void on_mFontColorPushButton_clicked();
void on_mFontColorButton_colorChanged( const QColor& newColor );
void on_mFillColorButton_colorChanged( const QColor& newColor );
void on_mStrokeColorButton_colorChanged( const QColor& newColor );
void on_mStyleComboBox_currentIndexChanged( const QString& text );
void on_mLabelBarSpaceSpinBox_valueChanged( double d );
void on_mBoxSizeSpinBox_valueChanged( double d );
Expand Down
24 changes: 19 additions & 5 deletions src/ui/qgscomposerlabelwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -52,8 +61,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>298</width>
<height>681</height>
<width>302</width>
<height>682</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
Expand Down Expand Up @@ -107,7 +116,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="mFontColorButton">
<widget class="QgsColorButton" name="mFontColorButton">
<property name="text">
<string>Font color...</string>
</property>
Expand Down Expand Up @@ -310,6 +319,11 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QgsColorButton</class>
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
Expand All @@ -320,7 +334,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
13 changes: 9 additions & 4 deletions src/ui/qgscomposerlegendwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>377</width>
<height>1251</height>
<width>375</width>
<height>1320</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
Expand Down Expand Up @@ -408,7 +408,7 @@
<property name="collapsed" stdset="0">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="mTitleFontButton">
<property name="sizePolicy">
Expand Down Expand Up @@ -444,7 +444,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="mFontColorPushButton">
<widget class="QgsColorButton" name="mFontColorButton">
<property name="text">
<string>Font color...</string>
</property>
Expand Down Expand Up @@ -817,6 +817,11 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QgsColorButton</class>
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
Expand Down
19 changes: 14 additions & 5 deletions src/ui/qgscomposerpicturewidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<width>332</width>
<height>572</height>
</rect>
</property>
Expand All @@ -23,7 +23,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down Expand Up @@ -52,7 +61,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>297</width>
<width>314</width>
<height>589</height>
</rect>
</property>
Expand Down Expand Up @@ -167,7 +176,7 @@
<item>
<widget class="QToolButton" name="mPictureExpressionButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -389,7 +398,7 @@
<customwidget>
<class>QgsCollapsibleGroupBoxBasic</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<header location="global">qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
Expand Down

0 comments on commit 738107a

Please sign in to comment.