diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2016-10-05 14:27:55 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2016-10-06 13:53:11 +0000 |
commit | 4b975405d70529408b2422e42720a80152746c20 (patch) | |
tree | 6e2193ba1077fc4938e777d6f8c0554e41873c19 /src | |
parent | 8f4054a7e6d5052a1030ce42c680f933c6f3a896 (diff) |
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 <liang.qi@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/widgets/qtextedit.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol_p.h | 2 |
3 files changed, 8 insertions, 1 deletions
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; |