diff options
author | Jan Arve Saether <jan-arve.saether@theqtcompany.com> | 2016-06-09 11:11:59 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@theqtcompany.com> | 2016-08-10 08:32:00 +0000 |
commit | e6e149c6d72c2824d4f9361baf09cea6ef3baa2c (patch) | |
tree | 4e7f58290fbbab9cdf0cc5e37c000249c60bc930 | |
parent | f8ec4e6a1b1356700c165ee703465fe2bbb827b3 (diff) |
Add InputContext::anchorRectangle
This will be needed for the selection handles for the dedicated vkb
[ChangeLog] Added API to support VKB selection handles.
Change-Id: I0cde63217c410559fbc1f8ad034c37fe959d8d28
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/virtualkeyboard/inputcontext.cpp | 30 | ||||
-rw-r--r-- | src/virtualkeyboard/inputcontext.h | 3 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/virtualkeyboard/inputcontext.cpp b/src/virtualkeyboard/inputcontext.cpp index 070e2908..36583204 100644 --- a/src/virtualkeyboard/inputcontext.cpp +++ b/src/virtualkeyboard/inputcontext.cpp @@ -106,6 +106,7 @@ public: preeditTextAttributes(), surroundingText(), selectedText(), + anchorRectangle(), cursorRectangle(), selectionControlVisible(false), anchorRectIntersectsClipRect(false), @@ -134,6 +135,7 @@ public: QList<QInputMethodEvent::Attribute> preeditTextAttributes; QString surroundingText; QString selectedText; + QRectF anchorRectangle; QRectF cursorRectangle; bool selectionControlVisible; bool anchorRectIntersectsClipRect; @@ -282,6 +284,12 @@ QString InputContext::selectedText() const return d->selectedText; } +QRectF InputContext::anchorRectangle() const +{ + Q_D(const InputContext); + return d->anchorRectangle; +} + QRectF InputContext::cursorRectangle() const { Q_D(const InputContext); @@ -653,6 +661,7 @@ void InputContext::update(Qt::InputMethodQueries queries) Qt::InputMethodHints inputMethodHints = Qt::InputMethodHints(d->inputContext->inputMethodQuery(Qt::ImHints).toInt()); const int cursorPosition = d->inputContext->inputMethodQuery(Qt::ImCursorPosition).toInt(); const int anchorPosition = d->inputContext->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + QRectF anchorRectangle = qApp->inputMethod()->anchorRectangle(); QRectF cursorRectangle = qApp->inputMethod()->cursorRectangle(); QString surroundingText = d->inputContext->inputMethodQuery(Qt::ImSurroundingText).toString(); QString selectedText = d->inputContext->inputMethodQuery(Qt::ImCurrentSelection).toString(); @@ -662,6 +671,7 @@ void InputContext::update(Qt::InputMethodQueries queries) bool newSurroundingText = surroundingText != d->surroundingText; bool newSelectedText = selectedText != d->selectedText; bool newCursorPosition = cursorPosition != d->cursorPosition; + bool newAnchorRectangle = anchorRectangle != d->anchorRectangle; bool newCursorRectangle = cursorRectangle != d->cursorRectangle; bool selectionControlVisible = d->inputContext->isInputPanelVisible() && (cursorPosition != anchorPosition); bool newSelectionControlVisible = selectionControlVisible != d->selectionControlVisible; @@ -681,6 +691,7 @@ void InputContext::update(Qt::InputMethodQueries queries) d->surroundingText = surroundingText; d->selectedText = selectedText; d->cursorPosition = cursorPosition; + d->anchorRectangle = anchorRectangle; d->cursorRectangle = cursorRectangle; d->selectionControlVisible = selectionControlVisible; d->anchorRectIntersectsClipRect = anchorRectIntersectsClipRect; @@ -708,6 +719,9 @@ void InputContext::update(Qt::InputMethodQueries queries) if (newCursorPosition) { emit cursorPositionChanged(); } + if (newAnchorRectangle) { + emit anchorRectangleChanged(); + } if (newCursorRectangle) { emit cursorRectangleChanged(); } @@ -904,7 +918,21 @@ bool InputContext::filterEvent(const QEvent *event) */ /*! - \qmlproperty int InputContext::cursorRectangle + \qmlproperty rect InputContext::anchorRectangle + \since QtQuick.VirtualKeyboard 2.1 + + This property is changed when the anchor rectangle changes. +*/ + +/*! + \property QtVirtualKeyboard::InputContext::anchorRectangle + \brief the anchor rectangle. + + This property is changed when the anchor rectangle changes. +*/ + +/*! + \qmlproperty rect InputContext::cursorRectangle This property is changed when the cursor rectangle changes. */ diff --git a/src/virtualkeyboard/inputcontext.h b/src/virtualkeyboard/inputcontext.h index fa7e07c6..dbcc7ceb 100644 --- a/src/virtualkeyboard/inputcontext.h +++ b/src/virtualkeyboard/inputcontext.h @@ -56,6 +56,7 @@ class InputContext : public QObject Q_PROPERTY(QString preeditText READ preeditText WRITE setPreeditText NOTIFY preeditTextChanged) Q_PROPERTY(QString surroundingText READ surroundingText NOTIFY surroundingTextChanged) Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) + Q_PROPERTY(QRectF anchorRectangle READ anchorRectangle NOTIFY anchorRectangleChanged) Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) Q_PROPERTY(QRectF keyboardRectangle READ keyboardRectangle WRITE setKeyboardRectangle NOTIFY keyboardRectangleChanged) Q_PROPERTY(QRectF previewRectangle READ previewRectangle WRITE setPreviewRectangle NOTIFY previewRectangleChanged) @@ -84,6 +85,7 @@ public: void setPreeditText(const QString &text, QList<QInputMethodEvent::Attribute> attributes = QList<QInputMethodEvent::Attribute>(), int replaceFrom = 0, int replaceLength = 0); QString surroundingText() const; QString selectedText() const; + QRectF anchorRectangle() const; QRectF cursorRectangle() const; QRectF keyboardRectangle() const; void setKeyboardRectangle(QRectF rectangle); @@ -124,6 +126,7 @@ signals: void surroundingTextChanged(); void selectedTextChanged(); void cursorPositionChanged(); + void anchorRectangleChanged(); void cursorRectangleChanged(); void shiftChanged(); void capsLockChanged(); |