Skip to content

Commit

Permalink
Fixed second Qt 5.10 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfug committed Mar 31, 2020
1 parent 6ce8b30 commit 9ddded7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Server/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

QFontMetrics metrics( font() );

constexpr int TabWidth = 4;

#if QT_VERSION > QT_VERSION_CHECK( 5, 10, 0 )
setTabStopDistance( TabWidth * metrics.horizontalAdvance( ' ' ) );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
setTabStopDistance( TabWidth * fontMetrics().horizontalAdvance( ' ' ) );
#else
setTabStopWidth( TabWidth * metrics.width( ' ' ) );
setTabStopWidth( TabWidth * fontMetrics().width( ' ' ) );
#endif

mHighlighter = new SyntaxHighlighterLua( document() );
Expand All @@ -39,7 +37,11 @@ int CodeEditor::lineNumberAreaWidth()
++digits;
}

#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
int space = 4 + fontMetrics().horizontalAdvance( '9' ) * digits;
#else
int space = 4 + fontMetrics().width( '9' ) * digits;
#endif

return space;
}
Expand Down

0 comments on commit 9ddded7

Please sign in to comment.