QTextEdit: translate IM argument before passing it on to QWidgetTextControl

Since we now have the possibility of providing an extra
position argument when querying for Qt::ImCursorPosition, we
need to ensure that we translate it from scroll view to
local coordinates before passing it on to QWidgetTextControl.

Change-Id: I4383ae3ea984b6140d8e9b4198047aec8b7e100b
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
This commit is contained in:
Richard Moe Gustavsen 2016-03-21 15:44:32 +01:00
parent 5391f3c72f
commit 3b18888982
2 changed files with 38 additions and 2 deletions

View File

@ -2199,8 +2199,26 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant a
Q_D(const QPlainTextEdit);
if (query == Qt::ImHints)
return QWidget::inputMethodQuery(query);
const QVariant v = d->control->inputMethodQuery(query, argument);
const QPointF offset = contentOffset();
switch (argument.type()) {
case QVariant::RectF:
argument = argument.toRectF().translated(-offset);
break;
case QVariant::PointF:
argument = argument.toPointF() - offset;
break;
case QVariant::Rect:
argument = argument.toRect().translated(-offset.toPoint());
break;
case QVariant::Point:
argument = argument.toPoint() - offset;
break;
default:
break;
}
const QVariant v = d->control->inputMethodQuery(query, argument);
switch (v.type()) {
case QVariant::RectF:
return v.toRectF().translated(offset);

View File

@ -1729,8 +1729,26 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argume
Q_D(const QTextEdit);
if (query == Qt::ImHints)
return QWidget::inputMethodQuery(query);
const QVariant v = d->control->inputMethodQuery(query, argument);
const QPointF offset(-d->horizontalOffset(), -d->verticalOffset());
switch (argument.type()) {
case QVariant::RectF:
argument = argument.toRectF().translated(-offset);
break;
case QVariant::PointF:
argument = argument.toPointF() - offset;
break;
case QVariant::Rect:
argument = argument.toRect().translated(-offset.toPoint());
break;
case QVariant::Point:
argument = argument.toPoint() - offset;
break;
default:
break;
}
const QVariant v = d->control->inputMethodQuery(query, argument);
switch (v.type()) {
case QVariant::RectF:
return v.toRectF().translated(offset);