From 4b975405d70529408b2422e42720a80152746c20 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 5 Oct 2016 14:27:55 +0200 Subject: QTextEdit: don't show placeholder text while composing text If using IM to compose text in QTextEdit, the placeholder text will show underneath until the text is committed. This patch will additionally check if the user is currently composing preedit text before deciding whether or not to draw the placeholder text. Task-number: QTBUG-55758 Change-Id: If7943c6c94fb96d46514a81caa118829e6e6a0f9 Reviewed-by: Liang Qi --- src/widgets/widgets/qtextedit.cpp | 2 +- src/widgets/widgets/qwidgettextcontrol.cpp | 5 +++++ src/widgets/widgets/qwidgettextcontrol_p.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 28666f76ce..7e4b86d8fd 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1506,7 +1506,7 @@ void QTextEditPrivate::paint(QPainter *p, QPaintEvent *e) if (layout) layout->setViewport(QRect()); - if (!placeholderText.isEmpty() && doc->isEmpty()) { + if (!placeholderText.isEmpty() && doc->isEmpty() && !control->isPreediting()) { QColor col = control->palette().text().color(); col.setAlpha(128); p->setPen(col); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index deca002bf5..4199ae537d 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -2557,6 +2557,11 @@ bool QWidgetTextControl::isWordSelectionEnabled() const return d->wordSelectionEnabled; } +bool QWidgetTextControl::isPreediting() +{ + return d_func()->isPreediting(); +} + #ifndef QT_NO_PRINTER void QWidgetTextControl::print(QPagedPaintDevice *printer) const { diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index c1180fd665..cd5abf4f5d 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -166,6 +166,8 @@ public: bool isWordSelectionEnabled() const; void setWordSelectionEnabled(bool enabled); + bool isPreediting(); + void print(QPagedPaintDevice *printer) const; virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const; -- cgit v1.2.3