Skip to content
Permalink
Browse files

Use QgsFontButton everywhere we can

  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent 0fd1f8e commit 43f11f4fa0d9d56a71999efc70c8054b97bb509f
Showing with 510 additions and 308 deletions.
  1. +24 −24 src/app/composer/qgscomposerattributetablewidget.cpp
  2. +2 −2 src/app/composer/qgscomposerattributetablewidget.h
  3. +12 −12 src/app/composer/qgscomposerlabelwidget.cpp
  4. +1 −1 src/app/composer/qgscomposerlabelwidget.h
  5. +42 −44 src/app/composer/qgscomposerlegendwidget.cpp
  6. +4 −4 src/app/composer/qgscomposerlegendwidget.h
  7. +10 −11 src/app/composer/qgscomposermapgridwidget.cpp
  8. +1 −1 src/app/composer/qgscomposermapgridwidget.h
  9. +12 −11 src/app/composer/qgscomposerscalebarwidget.cpp
  10. +1 −1 src/app/composer/qgscomposerscalebarwidget.h
  11. +7 −8 src/app/qgsdecorationgriddialog.cpp
  12. +1 −1 src/app/qgsdecorationgriddialog.h
  13. +2 −11 src/app/qgsdecorationlayoutextentdialog.cpp
  14. +0 −2 src/app/qgsdecorationlayoutextentdialog.h
  15. +4 −9 src/app/qgsdiagramproperties.cpp
  16. +0 −2 src/app/qgsdiagramproperties.h
  17. +6 −0 src/gui/qgsfontbutton.cpp
  18. +6 −8 src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp
  19. +1 −1 src/gui/symbology-ng/qgspointdisplacementrendererwidget.h
  20. +87 −38 src/ui/composer/qgscomposerattributetablewidgetbase.ui
  21. +30 −16 src/ui/composer/qgscomposerlabelwidgetbase.ui
  22. +57 −11 src/ui/composer/qgscomposerlegendwidgetbase.ui
  23. +44 −10 src/ui/composer/qgscomposermapgridwidgetbase.ui
  24. +21 −16 src/ui/composer/qgscomposerscalebarwidgetbase.ui
  25. +20 −7 src/ui/qgsdecorationgriddialog.ui
  26. +20 −7 src/ui/qgsdecorationlayoutextentdialog.ui
  27. +64 −30 src/ui/qgsdiagrampropertiesbase.ui
  28. +31 −20 src/ui/qgspointdisplacementrendererwidgetbase.ui
@@ -40,6 +40,9 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt
setupUi( this );
setPanelTitle( tr( "Table properties" ) );

mContentFontToolButton->setMode( QgsFontButton::ModeQFont );
mHeaderFontToolButton->setMode( QgsFontButton::ModeQFont );

blockAllSignals( true );

mResizeModeComboBox->addItem( tr( "Use existing frames" ), QgsComposerMultiFrame::UseExistingFrames );
@@ -106,6 +109,9 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt
QgsComposerItemWidget *itemPropertiesWidget = new QgsComposerItemWidget( this, mFrame );
mainLayout->addWidget( itemPropertiesWidget );
}

connect( mHeaderFontToolButton, &QgsFontButton::changed, this, &QgsComposerAttributeTableWidget::headerFontChanged );
connect( mContentFontToolButton, &QgsFontButton::changed, this, &QgsComposerAttributeTableWidget::contentFontChanged );
}

QgsComposerAttributeTableWidget::~QgsComposerAttributeTableWidget()
@@ -238,24 +244,19 @@ void QgsComposerAttributeTableWidget::on_mMarginSpinBox_valueChanged( double d )
}
}

void QgsComposerAttributeTableWidget::on_mHeaderFontPushButton_clicked()
void QgsComposerAttributeTableWidget::headerFontChanged()
{
if ( !mComposerTable )
return;

bool ok;
QFont newFont = QgsGuiUtils::getFont( ok, mComposerTable->headerFont(), tr( "Select Font" ) );
if ( ok )
{
QgsComposition *composition = mComposerTable->composition();
if ( composition )
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font" ) );
QgsComposition *composition = mComposerTable->composition();
if ( composition )
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font" ) );

mComposerTable->setHeaderFont( newFont );
mComposerTable->setHeaderFont( mHeaderFontToolButton->currentFont() );

if ( composition )
composition->endMultiFrameCommand();
}
if ( composition )
composition->endMultiFrameCommand();
}

void QgsComposerAttributeTableWidget::on_mHeaderFontColorButton_colorChanged( const QColor &newColor )
@@ -277,26 +278,21 @@ void QgsComposerAttributeTableWidget::on_mHeaderFontColorButton_colorChanged( co
}
}

void QgsComposerAttributeTableWidget::on_mContentFontPushButton_clicked()
void QgsComposerAttributeTableWidget::contentFontChanged()
{
if ( !mComposerTable )
{
return;
}

bool ok;
QFont newFont = QgsGuiUtils::getFont( ok, mComposerTable->contentFont(), tr( "Select Font" ) );
if ( ok )
{
QgsComposition *composition = mComposerTable->composition();
if ( composition )
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font" ) );
QgsComposition *composition = mComposerTable->composition();
if ( composition )
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font" ) );

mComposerTable->setContentFont( newFont );
mComposerTable->setContentFont( mContentFontToolButton->currentFont() );

if ( composition )
composition->endMultiFrameCommand();
}
if ( composition )
composition->endMultiFrameCommand();
}

void QgsComposerAttributeTableWidget::on_mContentFontColorButton_colorChanged( const QColor &newColor )
@@ -479,6 +475,8 @@ void QgsComposerAttributeTableWidget::updateGuiElements()

mHeaderFontColorButton->setColor( mComposerTable->headerFontColor() );
mContentFontColorButton->setColor( mComposerTable->contentFontColor() );
mHeaderFontToolButton->setCurrentFont( mComposerTable->headerFont() );
mContentFontToolButton->setCurrentFont( mComposerTable->contentFont() );

if ( mComposerTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
{
@@ -628,6 +626,8 @@ void QgsComposerAttributeTableWidget::blockAllSignals( bool b )
mDrawEmptyCheckBox->blockSignals( b );
mWrapStringLineEdit->blockSignals( b );
mWrapBehaviorComboBox->blockSignals( b );
mContentFontToolButton->blockSignals( b );
mHeaderFontToolButton->blockSignals( b );
}

void QgsComposerAttributeTableWidget::setMaximumNumberOfFeatures( int n )
@@ -51,9 +51,9 @@ class QgsComposerAttributeTableWidget: public QgsComposerItemBaseWidget, private
void on_mGridStrokeWidthSpinBox_valueChanged( double d );
void on_mGridColorButton_colorChanged( const QColor &newColor );
void on_mBackgroundColorButton_colorChanged( const QColor &newColor );
void on_mHeaderFontPushButton_clicked();
void headerFontChanged();
void on_mHeaderFontColorButton_colorChanged( const QColor &newColor );
void on_mContentFontPushButton_clicked();
void contentFontChanged();
void on_mContentFontColorButton_colorChanged( const QColor &newColor );
void on_mDrawHorizontalGrid_toggled( bool state );
void on_mDrawVerticalGrid_toggled( bool state );
@@ -31,6 +31,8 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel *label ): QgsCo
setupUi( this );
setPanelTitle( tr( "Label properties" ) );

mFontButton->setMode( QgsFontButton::ModeQFont );

//add widget for general composer item properties
QgsComposerItemWidget *itemPropertiesWidget = new QgsComposerItemWidget( this, label );
mainLayout->addWidget( itemPropertiesWidget );
@@ -46,6 +48,8 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel *label ): QgsCo
setGuiElementValues();
connect( mComposerLabel, &QgsComposerObject::itemChanged, this, &QgsComposerLabelWidget::setGuiElementValues );
}

connect( mFontButton, &QgsFontButton::changed, this, &QgsComposerLabelWidget::fontChanged );
}

void QgsComposerLabelWidget::on_mHtmlCheckBox_stateChanged( int state )
@@ -80,19 +84,15 @@ void QgsComposerLabelWidget::on_mTextEdit_textChanged()
}
}

void QgsComposerLabelWidget::on_mFontButton_clicked()
void QgsComposerLabelWidget::fontChanged()
{
if ( mComposerLabel )
{
bool ok;
QFont newFont = QgsGuiUtils::getFont( ok, mComposerLabel->font() );
if ( ok )
{
mComposerLabel->beginCommand( tr( "Label font changed" ) );
mComposerLabel->setFont( newFont );
mComposerLabel->update();
mComposerLabel->endCommand();
}
QFont newFont = mFontButton->currentFont();
mComposerLabel->beginCommand( tr( "Label font changed" ) );
mComposerLabel->setFont( newFont );
mComposerLabel->update();
mComposerLabel->endCommand();
}
}

@@ -243,8 +243,7 @@ void QgsComposerLabelWidget::setGuiElementValues()
mCenterRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignHCenter );
mRightRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignRight );
mFontColorButton->setColor( mComposerLabel->fontColor() );


mFontButton->setCurrentFont( mComposerLabel->font() );
mVerticalAlignementLabel->setDisabled( mComposerLabel->htmlState() );
mTopRadioButton->setDisabled( mComposerLabel->htmlState() );
mMiddleRadioButton->setDisabled( mComposerLabel->htmlState() );
@@ -266,4 +265,5 @@ void QgsComposerLabelWidget::blockAllSignals( bool block )
mCenterRadioButton->blockSignals( block );
mRightRadioButton->blockSignals( block );
mFontColorButton->blockSignals( block );
mFontButton->blockSignals( block );
}
@@ -35,7 +35,6 @@ class QgsComposerLabelWidget: public QgsComposerItemBaseWidget, private Ui::QgsC
public slots:
void on_mHtmlCheckBox_stateChanged( int i );
void on_mTextEdit_textChanged();
void on_mFontButton_clicked();
void on_mInsertExpressionButton_clicked();
void on_mMarginXDoubleSpinBox_valueChanged( double d );
void on_mMarginYDoubleSpinBox_valueChanged( double d );
@@ -49,6 +48,7 @@ class QgsComposerLabelWidget: public QgsComposerItemBaseWidget, private Ui::QgsC

private slots:
void setGuiElementValues();
void fontChanged();

private:
QgsComposerLabel *mComposerLabel = nullptr;
@@ -63,6 +63,11 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend *legend )
setupUi( this );
setPanelTitle( tr( "Legend properties" ) );

mTitleFontButton->setMode( QgsFontButton::ModeQFont );
mGroupFontButton->setMode( QgsFontButton::ModeQFont );
mLayerFontButton->setMode( QgsFontButton::ModeQFont );
mItemFontButton->setMode( QgsFontButton::ModeQFont );

// setup icons
mAddToolButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) );
mEditPushButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) );
@@ -108,6 +113,10 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend *legend )

connect( mItemTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &QgsComposerLegendWidget::selectedChanged );
connect( mTitleFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::titleFontChanged );
connect( mGroupFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::groupFontChanged );
connect( mLayerFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::layerFontChanged );
connect( mItemFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::itemFontChanged );
}

QgsComposerLegendWidget::QgsComposerLegendWidget(): QgsComposerItemBaseWidget( nullptr, nullptr ), mLegend( nullptr )
@@ -162,6 +171,11 @@ void QgsComposerLegendWidget::setGuiElements()
const QgsComposerMap *map = mLegend->composerMap();
mMapComboBox->setItem( map );
mFontColorButton->setColor( mLegend->fontColor() );
mTitleFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::Title ).font() );
mGroupFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::Group ).font() );
mLayerFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::Subgroup ).font() );
mItemFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::SymbolLabel ).font() );

blockAllSignals( false );

on_mCheckBoxAutoUpdate_stateChanged( mLegend->autoUpdateModel() ? Qt::Checked : Qt::Unchecked );
@@ -353,71 +367,51 @@ void QgsComposerLegendWidget::on_mIconLabelSpaceSpinBox_valueChanged( double d )
}
}

void QgsComposerLegendWidget::on_mTitleFontButton_clicked()
void QgsComposerLegendWidget::titleFontChanged()
{
if ( mLegend )
{
bool ok;
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::Title ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Title font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::Title, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
mLegend->beginCommand( tr( "Title font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::Title, mTitleFontButton->currentFont() );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

void QgsComposerLegendWidget::on_mGroupFontButton_clicked()
void QgsComposerLegendWidget::groupFontChanged()
{
if ( mLegend )
{
bool ok;
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::Group ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Legend group font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::Group, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
mLegend->beginCommand( tr( "Legend group font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::Group, mGroupFontButton->currentFont() );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

void QgsComposerLegendWidget::on_mLayerFontButton_clicked()
void QgsComposerLegendWidget::layerFontChanged()
{
if ( mLegend )
{
bool ok;
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::Subgroup ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Legend layer font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::Subgroup, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
mLegend->beginCommand( tr( "Legend layer font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::Subgroup, mLayerFontButton->currentFont() );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

void QgsComposerLegendWidget::on_mItemFontButton_clicked()
void QgsComposerLegendWidget::itemFontChanged()
{
if ( mLegend )
{
bool ok;
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::SymbolLabel ).font() );
if ( ok )
{
mLegend->beginCommand( tr( "Legend item font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::SymbolLabel, newFont );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
mLegend->beginCommand( tr( "Legend item font changed" ) );
mLegend->setStyleFont( QgsLegendStyle::SymbolLabel, mItemFontButton->currentFont() );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
}
}

@@ -939,6 +933,10 @@ void QgsComposerLegendWidget::blockAllSignals( bool b )
mCheckboxResizeContents->blockSignals( b );
mTitleSpaceBottomSpinBox->blockSignals( b );
mFilterLegendByAtlasCheckBox->blockSignals( b );
mTitleFontButton->blockSignals( b );
mGroupFontButton->blockSignals( b );
mLayerFontButton->blockSignals( b );
mItemFontButton->blockSignals( b );
}

void QgsComposerLegendWidget::selectedChanged( const QModelIndex &current, const QModelIndex &previous )
@@ -59,10 +59,6 @@ class QgsComposerLegendWidget: public QgsComposerItemBaseWidget, private Ui::Qgs
void on_mLayerSpaceSpinBox_valueChanged( double d );
void on_mSymbolSpaceSpinBox_valueChanged( double d );
void on_mIconLabelSpaceSpinBox_valueChanged( double d );
void on_mTitleFontButton_clicked();
void on_mGroupFontButton_clicked();
void on_mLayerFontButton_clicked();
void on_mItemFontButton_clicked();
void on_mFontColorButton_colorChanged( const QColor &newFontColor );
void on_mBoxSpaceSpinBox_valueChanged( double d );
void on_mColumnSpaceSpinBox_valueChanged( double d );
@@ -102,6 +98,10 @@ class QgsComposerLegendWidget: public QgsComposerItemBaseWidget, private Ui::Qgs
void updateFilterLegendByAtlasButton();

void on_mItemTreeView_doubleClicked( const QModelIndex &index );
void titleFontChanged();
void groupFontChanged();
void layerFontChanged();
void itemFontChanged();

private:
QgsComposerLegendWidget();

0 comments on commit 43f11f4

Please sign in to comment.
You can’t perform that action at this time.