Commit 26142b84 authored by jkobus's avatar jkobus Committed by Jarek Kobus
Browse files

DiffEditor: Apply visualize whitespaces according to options



Change-Id: I5f7c57479d5342f5457159b14fb6afa087cb988f
Reviewed-by: default avatarMarcel Krems <m.krems@software-vision.eu>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 1f447715
......@@ -43,6 +43,7 @@
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/displaysettings.h>
#include <coreplugin/minisplitter.h>
......@@ -138,6 +139,9 @@ public:
void clearAllData();
QTextBlock firstVisibleBlock() const { return SnippetEditorWidget::firstVisibleBlock(); }
public slots:
void setDisplaySettings(const DisplaySettings &ds);
protected:
virtual int extraAreaWidth(int *markWidthPtr = 0) const { return BaseTextEditorWidget::extraAreaWidth(markWidthPtr); }
BaseTextEditor *createEditor() { return new DiffViewEditorEditable(this); }
......@@ -174,11 +178,26 @@ private:
DiffViewEditorWidget::DiffViewEditorWidget(QWidget *parent)
: SnippetEditorWidget(parent), m_lineNumberDigits(1), m_inPaintEvent(false)
{
setLineNumbersVisible(true);
DisplaySettings settings = displaySettings();
settings.m_textWrapping = false;
settings.m_displayLineNumbers = true;
settings.m_highlightCurrentLine = false;
settings.m_displayFoldingMarkers = true;
settings.m_markTextChanges = false;
settings.m_highlightBlocks = false;
SnippetEditorWidget::setDisplaySettings(settings);
setCodeFoldingSupported(true);
setFrameStyle(QFrame::NoFrame);
}
void DiffViewEditorWidget::setDisplaySettings(const DisplaySettings &ds)
{
DisplaySettings settings = displaySettings();
settings.m_visualizeWhitespace = ds.m_visualizeWhitespace;
SnippetEditorWidget::setDisplaySettings(settings);
}
QString DiffViewEditorWidget::lineNumber(int blockNumber) const
{
if (m_lineNumbers.contains(blockNumber))
......@@ -526,21 +545,23 @@ DiffEditorWidget::DiffEditorWidget(QWidget *parent)
m_leftEditor = new DiffViewEditorWidget(this);
m_leftEditor->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_leftEditor->setReadOnly(true);
m_leftEditor->setHighlightCurrentLine(false);
m_leftEditor->setWordWrapMode(QTextOption::NoWrap);
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_leftEditor, SLOT(setFontSettings(TextEditor::FontSettings)));
m_leftEditor->setFontSettings(settings->fontSettings());
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_leftEditor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
m_leftEditor->setDisplaySettings(settings->displaySettings());
m_leftEditor->setCodeStyle(settings->codeStyle());
m_rightEditor = new DiffViewEditorWidget(this);
m_rightEditor->setCornerWidget(toggleSync);
m_rightEditor->setReadOnly(true);
m_rightEditor->setHighlightCurrentLine(false);
m_rightEditor->setWordWrapMode(QTextOption::NoWrap);
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_rightEditor, SLOT(setFontSettings(TextEditor::FontSettings)));
m_rightEditor->setFontSettings(settings->fontSettings());
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_rightEditor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
m_rightEditor->setDisplaySettings(settings->displaySettings());
m_rightEditor->setCodeStyle(settings->codeStyle());
connect(m_leftEditor->verticalScrollBar(), SIGNAL(valueChanged(int)),
......
Supports Markdown
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