Skip to content

Commit 43f11f4

Browse files
committed
Use QgsFontButton everywhere we can
1 parent 0fd1f8e commit 43f11f4

28 files changed

+510
-308
lines changed

src/app/composer/qgscomposerattributetablewidget.cpp

+24-24
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt
4040
setupUi( this );
4141
setPanelTitle( tr( "Table properties" ) );
4242

43+
mContentFontToolButton->setMode( QgsFontButton::ModeQFont );
44+
mHeaderFontToolButton->setMode( QgsFontButton::ModeQFont );
45+
4346
blockAllSignals( true );
4447

4548
mResizeModeComboBox->addItem( tr( "Use existing frames" ), QgsComposerMultiFrame::UseExistingFrames );
@@ -106,6 +109,9 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt
106109
QgsComposerItemWidget *itemPropertiesWidget = new QgsComposerItemWidget( this, mFrame );
107110
mainLayout->addWidget( itemPropertiesWidget );
108111
}
112+
113+
connect( mHeaderFontToolButton, &QgsFontButton::changed, this, &QgsComposerAttributeTableWidget::headerFontChanged );
114+
connect( mContentFontToolButton, &QgsFontButton::changed, this, &QgsComposerAttributeTableWidget::contentFontChanged );
109115
}
110116

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

241-
void QgsComposerAttributeTableWidget::on_mHeaderFontPushButton_clicked()
247+
void QgsComposerAttributeTableWidget::headerFontChanged()
242248
{
243249
if ( !mComposerTable )
244250
return;
245251

246-
bool ok;
247-
QFont newFont = QgsGuiUtils::getFont( ok, mComposerTable->headerFont(), tr( "Select Font" ) );
248-
if ( ok )
249-
{
250-
QgsComposition *composition = mComposerTable->composition();
251-
if ( composition )
252-
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font" ) );
252+
QgsComposition *composition = mComposerTable->composition();
253+
if ( composition )
254+
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font" ) );
253255

254-
mComposerTable->setHeaderFont( newFont );
256+
mComposerTable->setHeaderFont( mHeaderFontToolButton->currentFont() );
255257

256-
if ( composition )
257-
composition->endMultiFrameCommand();
258-
}
258+
if ( composition )
259+
composition->endMultiFrameCommand();
259260
}
260261

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

280-
void QgsComposerAttributeTableWidget::on_mContentFontPushButton_clicked()
281+
void QgsComposerAttributeTableWidget::contentFontChanged()
281282
{
282283
if ( !mComposerTable )
283284
{
284285
return;
285286
}
286287

287-
bool ok;
288-
QFont newFont = QgsGuiUtils::getFont( ok, mComposerTable->contentFont(), tr( "Select Font" ) );
289-
if ( ok )
290-
{
291-
QgsComposition *composition = mComposerTable->composition();
292-
if ( composition )
293-
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font" ) );
288+
QgsComposition *composition = mComposerTable->composition();
289+
if ( composition )
290+
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font" ) );
294291

295-
mComposerTable->setContentFont( newFont );
292+
mComposerTable->setContentFont( mContentFontToolButton->currentFont() );
296293

297-
if ( composition )
298-
composition->endMultiFrameCommand();
299-
}
294+
if ( composition )
295+
composition->endMultiFrameCommand();
300296
}
301297

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

480476
mHeaderFontColorButton->setColor( mComposerTable->headerFontColor() );
481477
mContentFontColorButton->setColor( mComposerTable->contentFontColor() );
478+
mHeaderFontToolButton->setCurrentFont( mComposerTable->headerFont() );
479+
mContentFontToolButton->setCurrentFont( mComposerTable->contentFont() );
482480

483481
if ( mComposerTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
484482
{
@@ -628,6 +626,8 @@ void QgsComposerAttributeTableWidget::blockAllSignals( bool b )
628626
mDrawEmptyCheckBox->blockSignals( b );
629627
mWrapStringLineEdit->blockSignals( b );
630628
mWrapBehaviorComboBox->blockSignals( b );
629+
mContentFontToolButton->blockSignals( b );
630+
mHeaderFontToolButton->blockSignals( b );
631631
}
632632

633633
void QgsComposerAttributeTableWidget::setMaximumNumberOfFeatures( int n )

src/app/composer/qgscomposerattributetablewidget.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class QgsComposerAttributeTableWidget: public QgsComposerItemBaseWidget, private
5151
void on_mGridStrokeWidthSpinBox_valueChanged( double d );
5252
void on_mGridColorButton_colorChanged( const QColor &newColor );
5353
void on_mBackgroundColorButton_colorChanged( const QColor &newColor );
54-
void on_mHeaderFontPushButton_clicked();
54+
void headerFontChanged();
5555
void on_mHeaderFontColorButton_colorChanged( const QColor &newColor );
56-
void on_mContentFontPushButton_clicked();
56+
void contentFontChanged();
5757
void on_mContentFontColorButton_colorChanged( const QColor &newColor );
5858
void on_mDrawHorizontalGrid_toggled( bool state );
5959
void on_mDrawVerticalGrid_toggled( bool state );

src/app/composer/qgscomposerlabelwidget.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel *label ): QgsCo
3131
setupUi( this );
3232
setPanelTitle( tr( "Label properties" ) );
3333

34+
mFontButton->setMode( QgsFontButton::ModeQFont );
35+
3436
//add widget for general composer item properties
3537
QgsComposerItemWidget *itemPropertiesWidget = new QgsComposerItemWidget( this, label );
3638
mainLayout->addWidget( itemPropertiesWidget );
@@ -46,6 +48,8 @@ QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel *label ): QgsCo
4648
setGuiElementValues();
4749
connect( mComposerLabel, &QgsComposerObject::itemChanged, this, &QgsComposerLabelWidget::setGuiElementValues );
4850
}
51+
52+
connect( mFontButton, &QgsFontButton::changed, this, &QgsComposerLabelWidget::fontChanged );
4953
}
5054

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

83-
void QgsComposerLabelWidget::on_mFontButton_clicked()
87+
void QgsComposerLabelWidget::fontChanged()
8488
{
8589
if ( mComposerLabel )
8690
{
87-
bool ok;
88-
QFont newFont = QgsGuiUtils::getFont( ok, mComposerLabel->font() );
89-
if ( ok )
90-
{
91-
mComposerLabel->beginCommand( tr( "Label font changed" ) );
92-
mComposerLabel->setFont( newFont );
93-
mComposerLabel->update();
94-
mComposerLabel->endCommand();
95-
}
91+
QFont newFont = mFontButton->currentFont();
92+
mComposerLabel->beginCommand( tr( "Label font changed" ) );
93+
mComposerLabel->setFont( newFont );
94+
mComposerLabel->update();
95+
mComposerLabel->endCommand();
9696
}
9797
}
9898

@@ -243,8 +243,7 @@ void QgsComposerLabelWidget::setGuiElementValues()
243243
mCenterRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignHCenter );
244244
mRightRadioButton->setChecked( mComposerLabel->hAlign() == Qt::AlignRight );
245245
mFontColorButton->setColor( mComposerLabel->fontColor() );
246-
247-
246+
mFontButton->setCurrentFont( mComposerLabel->font() );
248247
mVerticalAlignementLabel->setDisabled( mComposerLabel->htmlState() );
249248
mTopRadioButton->setDisabled( mComposerLabel->htmlState() );
250249
mMiddleRadioButton->setDisabled( mComposerLabel->htmlState() );
@@ -266,4 +265,5 @@ void QgsComposerLabelWidget::blockAllSignals( bool block )
266265
mCenterRadioButton->blockSignals( block );
267266
mRightRadioButton->blockSignals( block );
268267
mFontColorButton->blockSignals( block );
268+
mFontButton->blockSignals( block );
269269
}

src/app/composer/qgscomposerlabelwidget.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class QgsComposerLabelWidget: public QgsComposerItemBaseWidget, private Ui::QgsC
3535
public slots:
3636
void on_mHtmlCheckBox_stateChanged( int i );
3737
void on_mTextEdit_textChanged();
38-
void on_mFontButton_clicked();
3938
void on_mInsertExpressionButton_clicked();
4039
void on_mMarginXDoubleSpinBox_valueChanged( double d );
4140
void on_mMarginYDoubleSpinBox_valueChanged( double d );
@@ -49,6 +48,7 @@ class QgsComposerLabelWidget: public QgsComposerItemBaseWidget, private Ui::QgsC
4948

5049
private slots:
5150
void setGuiElementValues();
51+
void fontChanged();
5252

5353
private:
5454
QgsComposerLabel *mComposerLabel = nullptr;

src/app/composer/qgscomposerlegendwidget.cpp

+42-44
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend *legend )
6363
setupUi( this );
6464
setPanelTitle( tr( "Legend properties" ) );
6565

66+
mTitleFontButton->setMode( QgsFontButton::ModeQFont );
67+
mGroupFontButton->setMode( QgsFontButton::ModeQFont );
68+
mLayerFontButton->setMode( QgsFontButton::ModeQFont );
69+
mItemFontButton->setMode( QgsFontButton::ModeQFont );
70+
6671
// setup icons
6772
mAddToolButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) );
6873
mEditPushButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) );
@@ -108,6 +113,10 @@ QgsComposerLegendWidget::QgsComposerLegendWidget( QgsComposerLegend *legend )
108113

109114
connect( mItemTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
110115
this, &QgsComposerLegendWidget::selectedChanged );
116+
connect( mTitleFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::titleFontChanged );
117+
connect( mGroupFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::groupFontChanged );
118+
connect( mLayerFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::layerFontChanged );
119+
connect( mItemFontButton, &QgsFontButton::changed, this, &QgsComposerLegendWidget::itemFontChanged );
111120
}
112121

113122
QgsComposerLegendWidget::QgsComposerLegendWidget(): QgsComposerItemBaseWidget( nullptr, nullptr ), mLegend( nullptr )
@@ -162,6 +171,11 @@ void QgsComposerLegendWidget::setGuiElements()
162171
const QgsComposerMap *map = mLegend->composerMap();
163172
mMapComboBox->setItem( map );
164173
mFontColorButton->setColor( mLegend->fontColor() );
174+
mTitleFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::Title ).font() );
175+
mGroupFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::Group ).font() );
176+
mLayerFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::Subgroup ).font() );
177+
mItemFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::SymbolLabel ).font() );
178+
165179
blockAllSignals( false );
166180

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

356-
void QgsComposerLegendWidget::on_mTitleFontButton_clicked()
370+
void QgsComposerLegendWidget::titleFontChanged()
357371
{
358372
if ( mLegend )
359373
{
360-
bool ok;
361-
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::Title ).font() );
362-
if ( ok )
363-
{
364-
mLegend->beginCommand( tr( "Title font changed" ) );
365-
mLegend->setStyleFont( QgsLegendStyle::Title, newFont );
366-
mLegend->adjustBoxSize();
367-
mLegend->update();
368-
mLegend->endCommand();
369-
}
374+
mLegend->beginCommand( tr( "Title font changed" ) );
375+
mLegend->setStyleFont( QgsLegendStyle::Title, mTitleFontButton->currentFont() );
376+
mLegend->adjustBoxSize();
377+
mLegend->update();
378+
mLegend->endCommand();
370379
}
371380
}
372381

373-
void QgsComposerLegendWidget::on_mGroupFontButton_clicked()
382+
void QgsComposerLegendWidget::groupFontChanged()
374383
{
375384
if ( mLegend )
376385
{
377-
bool ok;
378-
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::Group ).font() );
379-
if ( ok )
380-
{
381-
mLegend->beginCommand( tr( "Legend group font changed" ) );
382-
mLegend->setStyleFont( QgsLegendStyle::Group, newFont );
383-
mLegend->adjustBoxSize();
384-
mLegend->update();
385-
mLegend->endCommand();
386-
}
386+
mLegend->beginCommand( tr( "Legend group font changed" ) );
387+
mLegend->setStyleFont( QgsLegendStyle::Group, mGroupFontButton->currentFont() );
388+
mLegend->adjustBoxSize();
389+
mLegend->update();
390+
mLegend->endCommand();
387391
}
388392
}
389393

390-
void QgsComposerLegendWidget::on_mLayerFontButton_clicked()
394+
void QgsComposerLegendWidget::layerFontChanged()
391395
{
392396
if ( mLegend )
393397
{
394-
bool ok;
395-
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::Subgroup ).font() );
396-
if ( ok )
397-
{
398-
mLegend->beginCommand( tr( "Legend layer font changed" ) );
399-
mLegend->setStyleFont( QgsLegendStyle::Subgroup, newFont );
400-
mLegend->adjustBoxSize();
401-
mLegend->update();
402-
mLegend->endCommand();
403-
}
398+
mLegend->beginCommand( tr( "Legend layer font changed" ) );
399+
mLegend->setStyleFont( QgsLegendStyle::Subgroup, mLayerFontButton->currentFont() );
400+
mLegend->adjustBoxSize();
401+
mLegend->update();
402+
mLegend->endCommand();
404403
}
405404
}
406405

407-
void QgsComposerLegendWidget::on_mItemFontButton_clicked()
406+
void QgsComposerLegendWidget::itemFontChanged()
408407
{
409408
if ( mLegend )
410409
{
411-
bool ok;
412-
QFont newFont = QgsGuiUtils::getFont( ok, mLegend->style( QgsLegendStyle::SymbolLabel ).font() );
413-
if ( ok )
414-
{
415-
mLegend->beginCommand( tr( "Legend item font changed" ) );
416-
mLegend->setStyleFont( QgsLegendStyle::SymbolLabel, newFont );
417-
mLegend->adjustBoxSize();
418-
mLegend->update();
419-
mLegend->endCommand();
420-
}
410+
mLegend->beginCommand( tr( "Legend item font changed" ) );
411+
mLegend->setStyleFont( QgsLegendStyle::SymbolLabel, mItemFontButton->currentFont() );
412+
mLegend->adjustBoxSize();
413+
mLegend->update();
414+
mLegend->endCommand();
421415
}
422416
}
423417

@@ -939,6 +933,10 @@ void QgsComposerLegendWidget::blockAllSignals( bool b )
939933
mCheckboxResizeContents->blockSignals( b );
940934
mTitleSpaceBottomSpinBox->blockSignals( b );
941935
mFilterLegendByAtlasCheckBox->blockSignals( b );
936+
mTitleFontButton->blockSignals( b );
937+
mGroupFontButton->blockSignals( b );
938+
mLayerFontButton->blockSignals( b );
939+
mItemFontButton->blockSignals( b );
942940
}
943941

944942
void QgsComposerLegendWidget::selectedChanged( const QModelIndex &current, const QModelIndex &previous )

src/app/composer/qgscomposerlegendwidget.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ class QgsComposerLegendWidget: public QgsComposerItemBaseWidget, private Ui::Qgs
5959
void on_mLayerSpaceSpinBox_valueChanged( double d );
6060
void on_mSymbolSpaceSpinBox_valueChanged( double d );
6161
void on_mIconLabelSpaceSpinBox_valueChanged( double d );
62-
void on_mTitleFontButton_clicked();
63-
void on_mGroupFontButton_clicked();
64-
void on_mLayerFontButton_clicked();
65-
void on_mItemFontButton_clicked();
6662
void on_mFontColorButton_colorChanged( const QColor &newFontColor );
6763
void on_mBoxSpaceSpinBox_valueChanged( double d );
6864
void on_mColumnSpaceSpinBox_valueChanged( double d );
@@ -102,6 +98,10 @@ class QgsComposerLegendWidget: public QgsComposerItemBaseWidget, private Ui::Qgs
10298
void updateFilterLegendByAtlasButton();
10399

104100
void on_mItemTreeView_doubleClicked( const QModelIndex &index );
101+
void titleFontChanged();
102+
void groupFontChanged();
103+
void layerFontChanged();
104+
void itemFontChanged();
105105

106106
private:
107107
QgsComposerLegendWidget();

0 commit comments

Comments
 (0)