forked from qt-creator/qt-creator
Editor: Fix reaplying display settings
After setting the document the display settings that are configured in a widget might differ from the ones configured in the document. So Check those values against the desired values from the editor and update if they differ. Change-Id: I30c5eddbb09803451fe03769d8e6d189293c5e86 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -7411,15 +7411,15 @@ void TextEditorWidget::setDisplaySettings(const DisplaySettings &ds)
|
||||
setParenthesesMatchingEnabled(ds.m_highlightMatchingParentheses);
|
||||
d->m_fileEncodingLabelAction->setVisible(ds.m_displayFileEncoding);
|
||||
|
||||
if (d->m_displaySettings.m_visualizeWhitespace != ds.m_visualizeWhitespace) {
|
||||
const QTextOption::Flags currentOptionFlags = document()->defaultTextOption().flags();
|
||||
QTextOption::Flags optionFlags = currentOptionFlags;
|
||||
optionFlags.setFlag(QTextOption::AddSpaceForLineAndParagraphSeparators);
|
||||
optionFlags.setFlag(QTextOption::ShowTabsAndSpaces, ds.m_visualizeWhitespace);
|
||||
if (optionFlags != currentOptionFlags) {
|
||||
if (SyntaxHighlighter *highlighter = textDocument()->syntaxHighlighter())
|
||||
highlighter->rehighlight();
|
||||
QTextOption option = document()->defaultTextOption();
|
||||
if (ds.m_visualizeWhitespace)
|
||||
option.setFlags(option.flags() | QTextOption::ShowTabsAndSpaces);
|
||||
else
|
||||
option.setFlags(option.flags() & ~QTextOption::ShowTabsAndSpaces);
|
||||
option.setFlags(option.flags() | QTextOption::AddSpaceForLineAndParagraphSeparators);
|
||||
QTextOption option = document()->defaultTextOption();
|
||||
option.setFlags(optionFlags);
|
||||
document()->setDefaultTextOption(option);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user