summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qinputmethod.cpp
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@theqtcompany.com>2015-11-26 10:37:24 +0100
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2016-04-06 12:26:34 +0000
commit0bb645b1ccc5a9d57b21cf0b2c4306b8e48c611c (patch)
treebf868b455287bffb5b0cab804765802bd3214f1f /src/gui/kernel/qinputmethod.cpp
parent9b699fa839f560a9ea9da69c8975b9aa4654ab8b (diff)
Add support for ImhAnchorRectangle
Adds the following API: * QInputMethod::anchorRectangle() * QPlatformInputContext::setSelectionOnFocusObject() This will be used for determining how to display selection handles. Change-Id: If57e3fd58ff0f1ba7899f7dd62bfa9c006028667 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qinputmethod.cpp')
-rw-r--r--src/gui/kernel/qinputmethod.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp
index ca988f2523..b81e166d3a 100644
--- a/src/gui/kernel/qinputmethod.cpp
+++ b/src/gui/kernel/qinputmethod.cpp
@@ -97,6 +97,7 @@ void QInputMethod::setInputItemTransform(const QTransform &transform)
d->inputItemTransform = transform;
emit cursorRectangleChanged();
+ emit anchorRectangleChanged();
}
@@ -126,6 +127,19 @@ void QInputMethod::setInputItemRectangle(const QRectF &rect)
d->inputRectangle = rect;
}
+static QRectF inputMethodQueryRectangle_helper(Qt::InputMethodQuery imquery, const QTransform &xform)
+{
+ QRectF r;
+ if (QObject *focusObject = qGuiApp->focusObject()) {
+ QInputMethodQueryEvent query(imquery);
+ QGuiApplication::sendEvent(focusObject, &query);
+ r = query.value(imquery).toRectF();
+ if (r.isValid())
+ r = xform.mapRect(r);
+ }
+ return r;
+}
+
/*!
\property QInputMethod::cursorRectangle
\brief Input item's cursor rectangle in window coordinates.
@@ -136,18 +150,20 @@ void QInputMethod::setInputItemRectangle(const QRectF &rect)
QRectF QInputMethod::cursorRectangle() const
{
Q_D(const QInputMethod);
+ return inputMethodQueryRectangle_helper(Qt::ImCursorRectangle, d->inputItemTransform);
+}
- QObject *focusObject = qGuiApp->focusObject();
- if (!focusObject)
- return QRectF();
-
- QInputMethodQueryEvent query(Qt::ImCursorRectangle);
- QGuiApplication::sendEvent(focusObject, &query);
- QRectF r = query.value(Qt::ImCursorRectangle).toRectF();
- if (!r.isValid())
- return QRectF();
+/*!
+ \property QInputMethod::anchorRectangle
+ \brief Input item's anchor rectangle in window coordinates.
- return d->inputItemTransform.mapRect(r);
+ Anchor rectangle is often used by various text editing controls
+ like text prediction popups for following the text selection.
+*/
+QRectF QInputMethod::anchorRectangle() const
+{
+ Q_D(const QInputMethod);
+ return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform);
}
/*!
@@ -300,6 +316,10 @@ void QInputMethod::update(Qt::InputMethodQueries queries)
if (queries & Qt::ImCursorRectangle)
emit cursorRectangleChanged();
+
+ if (queries & (Qt::ImAnchorRectangle))
+ emit anchorRectangleChanged();
+
}
/*!