Skip to content
Permalink
Browse files

Cleanup style handling

  • Loading branch information
nyalldawson committed Apr 21, 2021
1 parent 5bae3a2 commit 1404a79a17f88480d6d588d8d86cf3d8346c2c99
Showing with 31 additions and 27 deletions.
  1. +31 −27 src/gui/qgsrichtexteditor.cpp
@@ -31,6 +31,7 @@
#include "qgsrichtexteditor.h"
#include "qgsguiutils.h"
#include "qgscolorbutton.h"
#include "qgscodeeditor.h"

#include <QMimeData>
#include <QApplication>
@@ -362,41 +363,44 @@ void QgsRichTextEditor::textStyle( int )
mTextEdit->setCurrentCharFormat( format );

ParagraphItems style = static_cast< ParagraphItems >( mParagraphStyleCombo->currentData().toInt() );
if ( style == ParagraphHeading1
|| style == ParagraphHeading2
|| style == ParagraphHeading3
|| style == ParagraphHeading4 )

switch ( style )
{
if ( style == ParagraphHeading1 )
{
case QgsRichTextEditor::ParagraphStandard:
break;

case QgsRichTextEditor::ParagraphHeading1:
format.setFontPointSize( mFontSizeH1 );
}
if ( style == ParagraphHeading2 )
{
format.setFontWeight( QFont::Bold );
break;

case QgsRichTextEditor::ParagraphHeading2:
format.setFontPointSize( mFontSizeH2 );
}
if ( style == ParagraphHeading3 )
{
format.setFontWeight( QFont::Bold );
format.setFontItalic( true );
break;

case QgsRichTextEditor::ParagraphHeading3:
format.setFontPointSize( mFontSizeH3 );
}
if ( style == ParagraphHeading4 )
{
format.setFontWeight( QFont::Bold );
break;

case QgsRichTextEditor::ParagraphHeading4:
format.setFontPointSize( mFontSizeH4 );
}
if ( style == ParagraphHeading2 || style == ParagraphHeading4 )
{
format.setFontWeight( QFont::Bold );
format.setFontItalic( true );
}
break;

format.setFontWeight( QFont::Bold );
}
if ( style == ParagraphMonospace )
{
format = cursor.charFormat();
format.setFontFamily( QStringLiteral( "Monospace" ) );
format.setFontStyleHint( QFont::Monospace );
format.setFontFixedPitch( true );
case QgsRichTextEditor::ParagraphMonospace:
{
format = cursor.charFormat();
format.setFontFamily( QgsCodeEditor::getMonospaceFont().family() );
format.setFontStyleHint( QFont::Monospace );
format.setFontFixedPitch( true );
break;
}
}

cursor.setCharFormat( format );
mTextEdit->setCurrentCharFormat( format );

0 comments on commit 1404a79

Please sign in to comment.