summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qlineedit.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2016-04-11 14:06:02 +0200
committerRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2016-04-13 09:31:28 +0000
commitab67a5b7b631709aae779c767a903b8982fa7f8e (patch)
tree9a2fa10b7f0124b4eb651c8c41bc9726492ab69b /src/widgets/widgets/qlineedit.cpp
parent07a19c12a39034ff85568d82e800edd50a21741e (diff)
QLineEdit: add support for ImCursorPosition with position argument
Follow up f8dbed12, and implement support for IM queries that can take an extra QVariant argument. We use this to implement support for ImCursorPosition with a QPointF argument that specifies that we should return the text position under the given point rather than the current cursor pos (0bb645b). Change-Id: I03ae7af698241f454d35dec84f248ecd5bb6ad51 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src/widgets/widgets/qlineedit.cpp')
-rw-r--r--src/widgets/widgets/qlineedit.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 3cdd7dc0f0..5e88c2034a 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1745,9 +1745,14 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
#endif
}
+QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
+{
+ return inputMethodQuery(property, QVariant());
+}
+
/*!\reimp
*/
-QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
+QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
{
Q_D(const QLineEdit);
switch(property) {
@@ -1755,8 +1760,11 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
return d->cursorRect();
case Qt::ImFont:
return font();
- case Qt::ImCursorPosition:
- return QVariant(d->control->cursor());
+ case Qt::ImCursorPosition: {
+ const QPointF pt = argument.toPointF();
+ if (!pt.isNull())
+ return QVariant(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));
+ return QVariant(d->control->cursor()); }
case Qt::ImSurroundingText:
return QVariant(d->control->text());
case Qt::ImCurrentSelection: