From 0947a36c4f2444d50771695df047d165adc4c1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 8 Jun 2019 07:24:38 +0200 Subject: [PATCH] astyle formatting [ci skip] --- gui/codeeditor.cpp | 64 +++++++++++++++++++++---------------------- gui/codeeditor.h | 8 +++--- gui/codeeditorstyle.h | 53 +++++++++++++++++------------------ 3 files changed, 63 insertions(+), 62 deletions(-) diff --git a/gui/codeeditor.cpp b/gui/codeeditor.cpp index 645092df8..aeaafa41c 100644 --- a/gui/codeeditor.cpp +++ b/gui/codeeditor.cpp @@ -3,15 +3,15 @@ #include "codeeditor.h" -Highlighter::Highlighter( QTextDocument *parent, - CodeEditorStyle *widgetStyle ) : - QSyntaxHighlighter( parent ), - mWidgetStyle( widgetStyle ) +Highlighter::Highlighter(QTextDocument *parent, + CodeEditorStyle *widgetStyle) : + QSyntaxHighlighter(parent), + mWidgetStyle(widgetStyle) { HighlightingRule rule; - mKeywordFormat.setForeground( mWidgetStyle->keywordColor ); - mKeywordFormat.setFontWeight( mWidgetStyle->keywordWeight ); + mKeywordFormat.setForeground(mWidgetStyle->keywordColor); + mKeywordFormat.setFontWeight(mWidgetStyle->keywordWeight); QStringList keywordPatterns; keywordPatterns << "bool" << "break" @@ -59,32 +59,32 @@ Highlighter::Highlighter( QTextDocument *parent, mHighlightingRules.append(rule); } - mClassFormat.setForeground( mWidgetStyle->classColor ); - mClassFormat.setFontWeight( mWidgetStyle->classWeight ); + mClassFormat.setForeground(mWidgetStyle->classColor); + mClassFormat.setFontWeight(mWidgetStyle->classWeight); rule.pattern = QRegularExpression("\\bQ[A-Za-z]+\\b"); rule.format = mClassFormat; mHighlightingRules.append(rule); - mQuotationFormat.setForeground( mWidgetStyle->quoteColor ); - mQuotationFormat.setFontWeight( mWidgetStyle->quoteWeight ); + mQuotationFormat.setForeground(mWidgetStyle->quoteColor); + mQuotationFormat.setFontWeight(mWidgetStyle->quoteWeight); rule.pattern = QRegularExpression("\".*\""); rule.format = mQuotationFormat; mHighlightingRules.append(rule); - mSingleLineCommentFormat.setForeground( mWidgetStyle->commentColor ); - mSingleLineCommentFormat.setFontWeight( mWidgetStyle->commentWeight ); + mSingleLineCommentFormat.setForeground(mWidgetStyle->commentColor); + mSingleLineCommentFormat.setFontWeight(mWidgetStyle->commentWeight); rule.pattern = QRegularExpression("//[^\n]*"); rule.format = mSingleLineCommentFormat; mHighlightingRules.append(rule); mHighlightingRulesWithSymbols = mHighlightingRules; - mMultiLineCommentFormat.setForeground( mWidgetStyle->commentColor ); - mMultiLineCommentFormat.setFontWeight( mWidgetStyle->commentWeight ); + mMultiLineCommentFormat.setForeground(mWidgetStyle->commentColor); + mMultiLineCommentFormat.setFontWeight(mWidgetStyle->commentWeight); - mSymbolFormat.setForeground( mWidgetStyle->symbolFGColor ); - mSymbolFormat.setBackground( mWidgetStyle->symbolBGColor ); - mSymbolFormat.setFontWeight( mWidgetStyle->symbolWeight ); + mSymbolFormat.setForeground(mWidgetStyle->symbolFGColor); + mSymbolFormat.setBackground(mWidgetStyle->symbolBGColor); + mSymbolFormat.setFontWeight(mWidgetStyle->symbolWeight); mCommentStartExpression = QRegularExpression("/\\*"); mCommentEndExpression = QRegularExpression("\\*/"); @@ -134,12 +134,12 @@ void Highlighter::highlightBlock(const QString &text) } -CodeEditor::CodeEditor( QWidget *parent, - CodeEditorStyle *widgetStyle /*= nullptr*/ ) : +CodeEditor::CodeEditor(QWidget *parent, + CodeEditorStyle *widgetStyle /*= nullptr*/) : QPlainTextEdit(parent) { - if( widgetStyle ) mWidgetStyle = widgetStyle; - else mWidgetStyle = new CodeEditorStyle( defaultStyle ); + if (widgetStyle) mWidgetStyle = widgetStyle; + else mWidgetStyle = new CodeEditorStyle(defaultStyle); mLineNumberArea = new LineNumberArea(this); mHighlighter = new Highlighter(this->document(), mWidgetStyle); @@ -147,16 +147,16 @@ CodeEditor::CodeEditor( QWidget *parent, // set widget coloring by overriding widget style sheet QString bgcolor = QString("background:rgb(%1,%2,%3);") - .arg(mWidgetStyle->widgetBGColor.red()) - .arg(mWidgetStyle->widgetBGColor.green()) - .arg(mWidgetStyle->widgetBGColor.blue()); + .arg(mWidgetStyle->widgetBGColor.red()) + .arg(mWidgetStyle->widgetBGColor.green()) + .arg(mWidgetStyle->widgetBGColor.blue()); QString fgcolor = QString("color:rgb(%1,%2,%3);") - .arg(mWidgetStyle->widgetFGColor.red()) - .arg(mWidgetStyle->widgetFGColor.green()) - .arg(mWidgetStyle->widgetFGColor.blue()); + .arg(mWidgetStyle->widgetFGColor.red()) + .arg(mWidgetStyle->widgetFGColor.green()) + .arg(mWidgetStyle->widgetFGColor.blue()); QString style = QString("%1 %2") - .arg(bgcolor) - .arg(fgcolor); + .arg(bgcolor) + .arg(fgcolor); setObjectName("CodeEditor"); setStyleSheet(style); @@ -239,7 +239,7 @@ void CodeEditor::highlightErrorLine() QTextEdit::ExtraSelection selection; - selection.format.setBackground( mWidgetStyle->highlightBGColor ); + selection.format.setBackground(mWidgetStyle->highlightBGColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.cursor = QTextCursor(document()); selection.cursor.setPosition(mErrorPosition); @@ -252,7 +252,7 @@ void CodeEditor::highlightErrorLine() void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) { QPainter painter(mLineNumberArea); - painter.fillRect(event->rect(), mWidgetStyle->lineNumBGColor ); + painter.fillRect(event->rect(), mWidgetStyle->lineNumBGColor); QTextBlock block = firstVisibleBlock(); int blockNumber = block.blockNumber(); @@ -262,7 +262,7 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) while (block.isValid() && top <= event->rect().bottom()) { if (block.isVisible() && bottom >= event->rect().top()) { QString number = QString::number(blockNumber + 1); - painter.setPen( mWidgetStyle->lineNumFGColor ); + painter.setPen(mWidgetStyle->lineNumFGColor); painter.drawText(0, top, mLineNumberArea->width(), fontMetrics().height(), Qt::AlignRight, number); } diff --git a/gui/codeeditor.h b/gui/codeeditor.h index f88750e5d..4edbef99d 100644 --- a/gui/codeeditor.h +++ b/gui/codeeditor.h @@ -19,8 +19,8 @@ class Highlighter : public QSyntaxHighlighter { Q_OBJECT public: - explicit Highlighter( QTextDocument *parent, - CodeEditorStyle *widgetStyle ); + explicit Highlighter(QTextDocument *parent, + CodeEditorStyle *widgetStyle); void setSymbols(const QStringList &symbols); @@ -52,8 +52,8 @@ class CodeEditor : public QPlainTextEdit { Q_OBJECT public: - explicit CodeEditor( QWidget *parent, - CodeEditorStyle *widgetStyle = nullptr ); + explicit CodeEditor(QWidget *parent, + CodeEditorStyle *widgetStyle = nullptr); CodeEditor(const CodeEditor &) = delete; CodeEditor &operator=(const CodeEditor &) = delete; diff --git a/gui/codeeditorstyle.h b/gui/codeeditorstyle.h index 50c84221e..0070e62a4 100644 --- a/gui/codeeditorstyle.h +++ b/gui/codeeditorstyle.h @@ -7,7 +7,7 @@ class CodeEditorStyle { private: - CodeEditorStyle(){}; + CodeEditorStyle() {}; public: CodeEditorStyle( const QColor& CtrlFGColor, const QColor& CtrlBGColor, @@ -18,23 +18,23 @@ public: const QColor& QteFGColor, const QFont::Weight& QteWeight, const QColor& CmtFGColor, const QFont::Weight& CmtWeight, const QColor& SymbFGColor, const QColor& SymbBGColor, - const QFont::Weight& SymbWeight ) : - widgetFGColor( CtrlFGColor ), - widgetBGColor( CtrlBGColor ), - highlightBGColor( HiLiBGColor ), - lineNumFGColor( LnNumFGColor ), - lineNumBGColor( LnNumBGColor ), - keywordColor( KeyWdFGColor ), - keywordWeight( KeyWdWeight ), - classColor( ClsFGColor ), - classWeight( ClsWeight ), - quoteColor( QteFGColor ), - quoteWeight( QteWeight ), - commentColor( CmtFGColor ), - commentWeight( CmtWeight ), - symbolFGColor( SymbFGColor ), - symbolBGColor( SymbBGColor ), - symbolWeight( SymbWeight ) + const QFont::Weight& SymbWeight) : + widgetFGColor(CtrlFGColor), + widgetBGColor(CtrlBGColor), + highlightBGColor(HiLiBGColor), + lineNumFGColor(LnNumFGColor), + lineNumBGColor(LnNumBGColor), + keywordColor(KeyWdFGColor), + keywordWeight(KeyWdWeight), + classColor(ClsFGColor), + classWeight(ClsWeight), + quoteColor(QteFGColor), + quoteWeight(QteWeight), + commentColor(CmtFGColor), + commentWeight(CmtWeight), + symbolFGColor(SymbFGColor), + symbolBGColor(SymbBGColor), + symbolWeight(SymbWeight) {} public: @@ -57,13 +57,14 @@ public: }; static const CodeEditorStyle defaultStyle({ -/* editor FG/BG */ Qt::black, QColor( 240, 240, 240 ), -/* highlight BG */ QColor( 255, 220, 220 ), -/* line number FG/BG */ Qt::black, QColor( 240, 240, 240 ), -/* keyword FG/Weight */ Qt::darkBlue, QFont::Bold, -/* class FG/Weight */ Qt::darkMagenta, QFont::Bold, -/* quote FG/Weight */ Qt::darkGreen, QFont::Normal, -/* comment FG/Weight */ Qt::gray, QFont::Normal, -/* Symbol FG/BG/Weight */ Qt::red, QColor( 220, 220, 255 ), QFont::Normal }); + /* editor FG/BG */ Qt::black, QColor(240, 240, 240), + /* highlight BG */ QColor(255, 220, 220), + /* line number FG/BG */ Qt::black, QColor(240, 240, 240), + /* keyword FG/Weight */ Qt::darkBlue, QFont::Bold, + /* class FG/Weight */ Qt::darkMagenta, QFont::Bold, + /* quote FG/Weight */ Qt::darkGreen, QFont::Normal, + /* comment FG/Weight */ Qt::gray, QFont::Normal, + /* Symbol FG/BG/Weight */ Qt::red, QColor(220, 220, 255), QFont::Normal +}); #endif /* CODEEDITORSTYLE_H */