Commit 968a3c0f authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Added 'current line number' to color theme settings

Recently it was made to highlight black or write, which isn't nice for
everybody. Now it is dark gray by default, and can be customized. Bold
and italic are also supported.
parent ffaea3fc
......@@ -1513,7 +1513,7 @@ QRect BaseTextEditor::collapseBox()
return QRect();
QTextBlock begin = document()->findBlockByNumber(d->m_highlightBlocksInfo.open.last());
QTextBlock end= document()->findBlockByNumber(d->m_highlightBlocksInfo.close.first());
QTextBlock end = document()->findBlockByNumber(d->m_highlightBlocksInfo.close.first());
if (!begin.isValid() || !end.isValid())
return QRect();
QRectF br = blockBoundingGeometry(begin).translated(contentOffset());
......@@ -2349,7 +2349,11 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
const QString &number = QString::number(blockNumber + 1);
if (blockNumber == cursorBlockNumber) {
painter.save();
painter.setPen(pal.color(QPalette::Background).value() < 128 ? Qt::white : Qt::black);
QFont f = painter.font();
f.setBold(d->m_currentLineNumberFormat.font().bold());
f.setItalic(d->m_currentLineNumberFormat.font().italic());
painter.setFont(f);
painter.setPen(d->m_currentLineNumberFormat.foreground().color());
}
painter.drawText(markWidth, top, extraAreaWidth - markWidth - 4, fm.height(), Qt::AlignRight, number);
if (blockNumber == cursorBlockNumber)
......@@ -3547,10 +3551,11 @@ void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
const QTextCharFormat selectionFormat = fs.toTextCharFormat(QLatin1String(Constants::C_SELECTION));
const QTextCharFormat lineNumberFormat = fs.toTextCharFormat(QLatin1String(Constants::C_LINE_NUMBER));
const QTextCharFormat searchResultFormat = fs.toTextCharFormat(QLatin1String(Constants::C_SEARCH_RESULT));
const QTextCharFormat searchScopeFormat = fs.toTextCharFormat(QLatin1String(Constants::C_SEARCH_SCOPE));
d->m_searchScopeFormat = fs.toTextCharFormat(QLatin1String(Constants::C_SEARCH_SCOPE));
const QTextCharFormat parenthesesFormat = fs.toTextCharFormat(QLatin1String(Constants::C_PARENTHESES));
const QTextCharFormat currentLineFormat = fs.toTextCharFormat(QLatin1String(Constants::C_CURRENT_LINE));
const QTextCharFormat ifdefedOutFormat = fs.toTextCharFormat(QLatin1String(Constants::C_DISABLED_CODE));
d->m_currentLineFormat = fs.toTextCharFormat(QLatin1String(Constants::C_CURRENT_LINE));
d->m_currentLineNumberFormat = fs.toTextCharFormat(QLatin1String(Constants::C_CURRENT_LINE_NUMBER));
d->m_ifdefedOutFormat = fs.toTextCharFormat(QLatin1String(Constants::C_DISABLED_CODE));
QFont font(textFormat.font());
const QColor foreground = textFormat.foreground().color();
......@@ -3578,16 +3583,11 @@ void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
// Search results
d->m_searchResultFormat.setBackground(searchResultFormat.background());
d->m_searchScopeFormat.setBackground(searchScopeFormat.background());
d->m_currentLineFormat.setBackground(currentLineFormat.background());
// Matching braces
d->m_matchFormat.setForeground(parenthesesFormat.foreground());
d->m_rangeFormat.setBackground(parenthesesFormat.background());
// Disabled code
d->m_ifdefedOutFormat.setForeground(ifdefedOutFormat.foreground());
slotUpdateExtraAreaWidth();
}
......
......@@ -207,6 +207,7 @@ public:
QTextCharFormat m_searchResultFormat;
QTextCharFormat m_searchScopeFormat;
QTextCharFormat m_currentLineFormat;
QTextCharFormat m_currentLineNumberFormat;
void highlightSearchResults(const QTextBlock &block,
QVector<QTextLayout::FormatRange> *selections);
......
......@@ -137,9 +137,9 @@ QString FormatDescription::trName() const
QColor FormatDescription::foreground() const
{
if (m_name == QLatin1String("LineNumber"))
if (m_name == QLatin1String(Constants::C_LINE_NUMBER))
return QApplication::palette().dark().color();
if (m_name == QLatin1String("Parentheses"))
if (m_name == QLatin1String(Constants::C_PARENTHESES))
return QColor(Qt::red);
return m_format.foreground();
}
......
......@@ -72,6 +72,7 @@ const char * const C_SEARCH_RESULT = "SearchResult";
const char * const C_SEARCH_SCOPE = "SearchScope";
const char * const C_PARENTHESES = "Parentheses";
const char * const C_CURRENT_LINE = "CurrentLine";
const char * const C_CURRENT_LINE_NUMBER = "CurrentLineNumber";
const char * const C_NUMBER = "Number";
const char * const C_STRING = "String";
......
......@@ -72,6 +72,7 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
formatDescriptions.push_back(FormatDescription(QLatin1String(C_SEARCH_SCOPE), tr("Search Scope")));
formatDescriptions.push_back(FormatDescription(QLatin1String(C_PARENTHESES), tr("Parentheses")));
formatDescriptions.push_back(FormatDescription(QLatin1String(C_CURRENT_LINE), tr("Current Line")));
formatDescriptions.push_back(FormatDescription(QLatin1String(C_CURRENT_LINE_NUMBER), tr("Current Line Number"), Qt::darkGray));
// Standard categories
formatDescriptions.push_back(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment