diff --git a/qtsolutions/codeeditor/codeeditor.cpp b/qtsolutions/codeeditor/codeeditor.cpp index 7811dc4b4..812a4e7fd 100644 --- a/qtsolutions/codeeditor/codeeditor.cpp +++ b/qtsolutions/codeeditor/codeeditor.cpp @@ -38,7 +38,10 @@ ** ****************************************************************************/ -#include +#include +#include +#include +#include #include "codeeditor.h" @@ -50,10 +53,10 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); //we manage highlighting within GC, this is not required. - //connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); + connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateLineNumberAreaWidth(0); - //highlightCurrentLine(); + highlightCurrentLine(); lineAreaColor=QColor(Qt::darkGray); lineAreaText=QColor(Qt::white); @@ -114,9 +117,7 @@ void CodeEditor::highlightCurrentLine() if (!isReadOnly()) { QTextEdit::ExtraSelection selection; - QColor lineColor = QColor(Qt::yellow).lighter(160); - - selection.format.setBackground(lineColor); + selection.format.setBackground(lineAreaColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.cursor = textCursor(); selection.cursor.clearSelection(); diff --git a/src/WorkoutWidget.cpp b/src/WorkoutWidget.cpp index 5e5e91e84..44cc08623 100644 --- a/src/WorkoutWidget.cpp +++ b/src/WorkoutWidget.cpp @@ -824,16 +824,6 @@ WorkoutWidget::setBlockCursor() // cursor to work with the document text QTextCursor cursor(parent->code->document()); - // highlighting block - QTextBlockFormat normal; - QTextBlockFormat highlight = cursor.blockFormat(); - highlight.setBackground(QBrush(QColor(127,127,127,127))); - - // set all normal before highlighting current hover - cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); - cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); - cursor.setBlockFormat(normal); - // look for line of code that includes the point we are // hovering over so we can highlight it in the text edit int indexin=0; @@ -845,13 +835,9 @@ WorkoutWidget::setBlockCursor() || (i==codePoints.count()-1))) { // we have found the line in coreStrings that we - // are hovering on and should now set it to be - // highlighted - - // lets color it as a gray block + // move cursor, the line will be highlighted by the editor cursor.setPosition(indexin, QTextCursor::MoveAnchor); cursor.setPosition(indexin + codeStrings[i].length(), QTextCursor::KeepAnchor); - cursor.setBlockFormat(highlight); cursor.clearSelection(); // move the visible cursor and make visible