diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp
index 43b617e0..addf45d9 100644
--- a/src/PreferencesDialog.cpp
+++ b/src/PreferencesDialog.cpp
@@ -177,6 +177,8 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
return QColor(Qt::darkMagenta).name();
else if(name == "string_colour")
return QColor(Qt::red).name();
+ else if(name == "currentline_colour")
+ return QColor(236, 236, 245).name();
}
}
diff --git a/src/PreferencesDialog.ui b/src/PreferencesDialog.ui
index 92aa35a7..37473826 100644
--- a/src/PreferencesDialog.ui
+++ b/src/PreferencesDialog.ui
@@ -267,6 +267,14 @@
+ -
+
+ currentline
+
+
+ Current line
+
+
diff --git a/src/sqltextedit.cpp b/src/sqltextedit.cpp
index 76b861a5..73bea775 100644
--- a/src/sqltextedit.cpp
+++ b/src/sqltextedit.cpp
@@ -1,4 +1,5 @@
#include "sqltextedit.h"
+#include "PreferencesDialog.h"
#include
#include
@@ -16,8 +17,10 @@ SqlTextEdit::SqlTextEdit(QWidget* parent) :
m_Completer->setWrapAround(false);
m_Completer->setWidget(this);
- QObject::connect(m_Completer, SIGNAL(activated(QString)),
- this, SLOT(insertCompletion(QString)));
+ connect(m_Completer, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString)));
+ connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
+
+ highlightCurrentLine();
}
SqlTextEdit::~SqlTextEdit()
@@ -91,6 +94,23 @@ void SqlTextEdit::insertCompletion(const QString& completion)
setTextCursor(tc);
}
+void SqlTextEdit::highlightCurrentLine()
+{
+ QList extra_selections;
+
+ QTextEdit::ExtraSelection selection;
+ selection.format.setBackground(QColor(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_colour").toString()));
+ selection.format.setFontWeight(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_bold").toBool() ? QFont::Bold : QFont::Normal);
+ selection.format.setFontItalic(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_italic").toBool());
+ selection.format.setFontUnderline(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_underline").toBool());
+ selection.format.setProperty(QTextFormat::FullWidthSelection, true);
+ selection.cursor = textCursor();
+ selection.cursor.clearSelection();
+ extra_selections.append(selection);
+
+ setExtraSelections(extra_selections);
+}
+
namespace {
bool isSqliteIdentifierChar(QChar c) {
return c.isLetterOrNumber() || c == '.' || c == '_';
diff --git a/src/sqltextedit.h b/src/sqltextedit.h
index 4a754db6..9d408d72 100644
--- a/src/sqltextedit.h
+++ b/src/sqltextedit.h
@@ -37,6 +37,7 @@ private:
private slots:
void insertCompletion(const QString& completion);
+ void highlightCurrentLine();
private:
QCompleter* m_Completer;