Work around QPlainTextEdit / QPainter bug on Mac

Actually, it's not so much "work around", it's just "disable our eye candy" for
tags on Mac. This is quite frustrating. When we do anything that has the
QPainter touch the widget from our GroupedLineEdit::paintEvent() path then the
QPlainTextEdit::paintEvent() doesn't render the text of the tags.

Fixes #298

Sort of.
But I guess tag text without eye candy is better than eye candy without tag text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-11-22 09:44:28 -08:00
parent a3ddb16d88
commit 781266bf18

View file

@ -28,19 +28,21 @@
#include "groupedlineedit.h"
#include <QtGui/QStyleOptionFrameV3>
#include <QtGui/QFontMetrics>
#include <QtGui/QApplication>
#include <QtGui/QScrollBar>
#include <QtGui/QTextDocument>
#include <QtGui/QTextBlock>
#include <QtGui/QTextLayout>
#include <QtGui/QTextLine>
#include <QtGui/QPainter>
#include <QtGui/QPainterPath>
#include <QtGui/QBrush>
#include <QtGui/QColor>
#include <QtGui/QPalette>
#include <QFontMetrics>
#include <QStyleOptionFrameV3>
#include <QFontMetrics>
#include <QApplication>
#include <QScrollBar>
#include <QTextDocument>
#include <QTextBlock>
#include <QTextLayout>
#include <QTextLine>
#include <QPainter>
#include <QPainterPath>
#include <QBrush>
#include <QColor>
#include <QPalette>
#include <QDebug>
struct GroupedLineEdit::Private {
struct Block {
@ -175,7 +177,12 @@ void GroupedLineEdit::keyPressEvent(QKeyEvent *e)
void GroupedLineEdit::paintEvent(QPaintEvent *e)
{
#if !defined __APPLE__
// for reasons we don't understand, yet, touching the painter
// here (even drawing the fill rect) causes the QPlainTextEdit
// paintEvent to not draw the text on MacOS.
// So as a workaround until this is better understood we need
// to disable the eye candy
QTextLine line = document()->findBlock(0).layout()->lineAt(0);
QPainter painter(viewport());
@ -203,6 +210,6 @@ void GroupedLineEdit::paintEvent(QPaintEvent *e)
painter.setBrush(i.next().lighter(180));
painter.drawPath(path);
}
#endif
QPlainTextEdit::paintEvent(e);
}