diff options
author | Roger Maclean <rmaclean@qnx.com> | 2013-11-12 11:58:42 -0500 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-24 19:17:36 +0100 |
commit | 8a5c261954836e2aeac53f5e6581135ffaa9a2e0 (patch) | |
tree | edc7eb5c203f571ddce7026e177a65d337d29632 /src/plugins/platforms/qnx/qqnxinputcontext_imf.h | |
parent | 432674d787124ecfd6f3e1cca74f13f0f0096e53 (diff) |
QNX: Add support for BB10 text highlighting and spell checking
Adds the QPA side of the support for text highlighting during text
entry and for spell checking. The changes are compatible with
existing Qt text controls though require more advanced ones to have
any effect.
QQnxInputContext has three colors it can now use for highlighting
text during composition to represent the active region, auto
corrected text and reverted text. If any of these colors is invalid,
that form of highlighting is not used. By default, only the active
region color has a valid default which corresponds to the highlighting
capabilities of classes such as QQuickTextInput. The QNX QPA native
interface has been augmented with the ability to get a function
pointer that can be used to set any or all of the three colors. The
set of colors is reset to the default at any time that focus changes
to ensure appropriate behavior if there is a mix of controls.
It's worth noting that while the colors can be changed even when
used with one of the standard Qt text controls, the auto-correct
color will not show up since it is applied immediately before
committing the text. Appropriate display of this highlighting
requires that the control maintain the highlighting for a period
after committing the text.
Spell checking is provided via another function accessible through
the QNX QPA native interface. This takes a string and a callback
function to be called once spell checking is complete.
As a slightly unrelated change, toSpannableString now uses
toWCharArray to convert the QString to UTF-32 as required by IMF,
the previous code was invalid in the case of strings containing
UTF-16 surrogate pairs.
Removed some extraneous includes.
Change-Id: Ifdf3744d1990e0560d1923bca5db30953dea0192
Reviewed-by: Roger Maclean <rmaclean@qnx.com>
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxinputcontext_imf.h')
-rw-r--r-- | src/plugins/platforms/qnx/qqnxinputcontext_imf.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.h b/src/plugins/platforms/qnx/qqnxinputcontext_imf.h index cda4f2e88e..5028215bbe 100644 --- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.h +++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.h @@ -47,6 +47,7 @@ #include <QtCore/QLocale> #include <QtCore/QMetaType> +#include <QtCore/QList> #include <qpa/qplatformintegration.h> #include "imf/imf_client.h" @@ -65,6 +66,13 @@ public: explicit QQnxInputContext(QQnxIntegration *integration, QQnxAbstractVirtualKeyboard &keyboard); ~QQnxInputContext(); + // Indices for selecting and setting highlight colors. + enum HighlightIndex { + ActiveRegion, + AutoCorrected, + Reverted, + }; + bool isValid() const; bool filterEvent(const QEvent *event); @@ -82,6 +90,10 @@ public: QLocale locale() const; void setFocusObject(QObject *object); + static void setHighlightColor(int index, const QColor &color); + + static bool checkSpelling(const QString &text, void *context, void (*spellCheckDone)(void *context, const QString &text, const QList<int> &indices)); + private Q_SLOTS: void keyboardVisibilityChanged(bool visible); void keyboardLocaleChanged(const QLocale &locale); @@ -93,6 +105,7 @@ private: void dispatchFocusLossEvent(); bool dispatchRequestSoftwareInputPanel(); bool dispatchCloseSoftwareInputPanel(); + int handleSpellCheck(spell_check_event_t *event); int32_t processEvent(event_t *event); void closeSession(); @@ -113,7 +126,6 @@ private: spannable_string_t *onGetTextAfterCursor(int32_t n, int32_t flags); spannable_string_t *onGetTextBeforeCursor(int32_t n, int32_t flags); int32_t onSendEvent(event_t *event); - int32_t onSendAsyncEvent(event_t *event); int32_t onSetComposingRegion(int32_t start, int32_t end); int32_t onSetComposingText(spannable_string_t *text, int32_t new_cursor_position); int32_t onIsTextSelected(int32_t* pIsSelected); @@ -126,6 +138,10 @@ private: bool m_isUpdatingText; bool m_inputPanelVisible; QLocale m_inputPanelLocale; + // The object that had focus when the last highlight color was set. + QObject *m_focusObject; + // Indexed by HighlightIndex + QColor m_highlightColor[3]; QQnxIntegration *m_integration; QQnxAbstractVirtualKeyboard &m_virtualKeyboard; }; |