Skip to content

Commit 7727ed6

Browse files
committedApr 21, 2021
Fix build on older Qt
1 parent 5fa4842 commit 7727ed6

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed
 

‎src/gui/qgsrichtexteditor.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ QgsRichTextEditor::QgsRichTextEditor( QWidget *parent )
6363
mParagraphStyleCombo->addItem( tr( "Heading 4" ), ParagraphHeading4 );
6464
mParagraphStyleCombo->addItem( tr( "Monospace" ), ParagraphMonospace );
6565

66-
connect( mParagraphStyleCombo, qOverload< int >( &QComboBox::activated ), this, &QgsRichTextEditor::textStyle );
66+
connect( mParagraphStyleCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsRichTextEditor::textStyle );
6767
mToolBar->insertWidget( mToolBar->actions().at( 0 ), mParagraphStyleCombo );
6868

6969
mFontSizeCombo = new QComboBox();
@@ -168,7 +168,7 @@ QgsRichTextEditor::QgsRichTextEditor( QWidget *parent )
168168
for ( int size : sizes )
169169
mFontSizeCombo->addItem( QString::number( size ), size );
170170

171-
connect( mFontSizeCombo, &QComboBox::textActivated, this, &QgsRichTextEditor::textSize );
171+
connect( mFontSizeCombo, &QComboBox::currentTextChanged, this, &QgsRichTextEditor::textSize );
172172
mFontSizeCombo->setCurrentIndex( mFontSizeCombo->findData( QApplication::font().pointSize() ) );
173173

174174
// text foreground color
@@ -342,7 +342,7 @@ void QgsRichTextEditor::textLink( bool checked )
342342
mergeFormatOnWordOrSelection( fmt );
343343
}
344344

345-
void QgsRichTextEditor::textStyle( int index )
345+
void QgsRichTextEditor::textStyle( int )
346346
{
347347
QTextCursor cursor = mTextEdit->textCursor();
348348
cursor.beginEditBlock();
@@ -356,35 +356,36 @@ void QgsRichTextEditor::textStyle( int index )
356356
cursor.setCharFormat( fmt );
357357
mTextEdit->setCurrentCharFormat( fmt );
358358

359-
if ( index == ParagraphHeading1
360-
|| index == ParagraphHeading2
361-
|| index == ParagraphHeading3
362-
|| index == ParagraphHeading4 )
359+
ParagraphItems style = static_cast< ParagraphItems >( mParagraphStyleCombo->currentData().toInt() );
360+
if ( style == ParagraphHeading1
361+
|| style == ParagraphHeading2
362+
|| style == ParagraphHeading3
363+
|| style == ParagraphHeading4 )
363364
{
364-
if ( index == ParagraphHeading1 )
365+
if ( style == ParagraphHeading1 )
365366
{
366367
fmt.setFontPointSize( mFontSizeH1 );
367368
}
368-
if ( index == ParagraphHeading2 )
369+
if ( style == ParagraphHeading2 )
369370
{
370371
fmt.setFontPointSize( mFontSizeH2 );
371372
}
372-
if ( index == ParagraphHeading3 )
373+
if ( style == ParagraphHeading3 )
373374
{
374375
fmt.setFontPointSize( mFontSizeH3 );
375376
}
376-
if ( index == ParagraphHeading4 )
377+
if ( style == ParagraphHeading4 )
377378
{
378379
fmt.setFontPointSize( mFontSizeH4 );
379380
}
380-
if ( index == ParagraphHeading2 || index == ParagraphHeading4 )
381+
if ( style == ParagraphHeading2 || style == ParagraphHeading4 )
381382
{
382383
fmt.setFontItalic( true );
383384
}
384385

385386
fmt.setFontWeight( QFont::Bold );
386387
}
387-
if ( index == ParagraphMonospace )
388+
if ( style == ParagraphMonospace )
388389
{
389390
fmt = cursor.charFormat();
390391
fmt.setFontFamily( QStringLiteral( "Monospace" ) );

0 commit comments

Comments
 (0)
Please sign in to comment.