From b448e6e7b955b352e6bc9fcf59cfd6f5b1e03f90 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen <marius.storm-olsen@nokia.com> Date: Fri, 5 Mar 2010 12:33:33 +0100 Subject: [PATCH] Enable suppressing syntax and setting a foreground color on disabled blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the foreground color for the disabled text is different than the normal text foreground, that's an indication that the user wants the disabled block to be colored differently. If so, disable the syntax highlighting and set uniform colors for the block. If the foreground colors are identical apply full syntax highlighting in the disabled block too. Some people want that. Reviewed-by: Thorbjørn Lindeijer --- src/plugins/texteditor/basetexteditor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 7bcca16b848..70048162903 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -2303,6 +2303,8 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) QPointF offset(contentOffset()); bool hasMainSelection = textCursor().hasSelection(); + bool suppressSyntaxInIfdefedOutBlock = (d->m_ifdefedOutFormat.foreground() + != palette().foreground()); QRect er = e->rect(); QRect viewportRect = viewport()->rect(); @@ -2469,17 +2471,15 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) QTextLayout *layout = block.layout(); -#if 0 QTextOption option = layout->textOption(); - if (TextEditDocumentLayout::ifdefedOut(block)) { - option.setFlags(option.flags() /*| QTextOption::SuppressColors*/); + if (suppressSyntaxInIfdefedOutBlock && TextEditDocumentLayout::ifdefedOut(block)) { + option.setFlags(option.flags() | QTextOption::SuppressColors); painter.setPen(d->m_ifdefedOutFormat.foreground().color()); } else { option.setFlags(option.flags() & ~QTextOption::SuppressColors); painter.setPen(context.palette.text().color()); } layout->setTextOption(option); -#endif int blpos = block.position(); int bllen = block.length(); -- GitLab