@@ -63,7 +63,7 @@ QgsRichTextEditor::QgsRichTextEditor( QWidget *parent )
63
63
mParagraphStyleCombo ->addItem ( tr ( " Heading 4" ), ParagraphHeading4 );
64
64
mParagraphStyleCombo ->addItem ( tr ( " Monospace" ), ParagraphMonospace );
65
65
66
- connect ( mParagraphStyleCombo , qOverload< int >( &QComboBox::activated ), this , &QgsRichTextEditor::textStyle );
66
+ connect ( mParagraphStyleCombo , qOverload< int >( &QComboBox::currentIndexChanged ), this , &QgsRichTextEditor::textStyle );
67
67
mToolBar ->insertWidget ( mToolBar ->actions ().at ( 0 ), mParagraphStyleCombo );
68
68
69
69
mFontSizeCombo = new QComboBox ();
@@ -168,7 +168,7 @@ QgsRichTextEditor::QgsRichTextEditor( QWidget *parent )
168
168
for ( int size : sizes )
169
169
mFontSizeCombo ->addItem ( QString::number ( size ), size );
170
170
171
- connect ( mFontSizeCombo , &QComboBox::textActivated , this , &QgsRichTextEditor::textSize );
171
+ connect ( mFontSizeCombo , &QComboBox::currentTextChanged , this , &QgsRichTextEditor::textSize );
172
172
mFontSizeCombo ->setCurrentIndex ( mFontSizeCombo ->findData ( QApplication::font ().pointSize () ) );
173
173
174
174
// text foreground color
@@ -342,7 +342,7 @@ void QgsRichTextEditor::textLink( bool checked )
342
342
mergeFormatOnWordOrSelection ( fmt );
343
343
}
344
344
345
- void QgsRichTextEditor::textStyle ( int index )
345
+ void QgsRichTextEditor::textStyle ( int )
346
346
{
347
347
QTextCursor cursor = mTextEdit ->textCursor ();
348
348
cursor.beginEditBlock ();
@@ -356,35 +356,36 @@ void QgsRichTextEditor::textStyle( int index )
356
356
cursor.setCharFormat ( fmt );
357
357
mTextEdit ->setCurrentCharFormat ( fmt );
358
358
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 )
363
364
{
364
- if ( index == ParagraphHeading1 )
365
+ if ( style == ParagraphHeading1 )
365
366
{
366
367
fmt.setFontPointSize ( mFontSizeH1 );
367
368
}
368
- if ( index == ParagraphHeading2 )
369
+ if ( style == ParagraphHeading2 )
369
370
{
370
371
fmt.setFontPointSize ( mFontSizeH2 );
371
372
}
372
- if ( index == ParagraphHeading3 )
373
+ if ( style == ParagraphHeading3 )
373
374
{
374
375
fmt.setFontPointSize ( mFontSizeH3 );
375
376
}
376
- if ( index == ParagraphHeading4 )
377
+ if ( style == ParagraphHeading4 )
377
378
{
378
379
fmt.setFontPointSize ( mFontSizeH4 );
379
380
}
380
- if ( index == ParagraphHeading2 || index == ParagraphHeading4 )
381
+ if ( style == ParagraphHeading2 || style == ParagraphHeading4 )
381
382
{
382
383
fmt.setFontItalic ( true );
383
384
}
384
385
385
386
fmt.setFontWeight ( QFont::Bold );
386
387
}
387
- if ( index == ParagraphMonospace )
388
+ if ( style == ParagraphMonospace )
388
389
{
389
390
fmt = cursor.charFormat ();
390
391
fmt.setFontFamily ( QStringLiteral ( " Monospace" ) );
0 commit comments