diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2015-01-19 11:42:27 +0200 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2015-01-22 11:38:41 +0200 |
commit | 9fdf5bb4d49a9e7a24c571b723f883269ca06b69 (patch) | |
tree | 2e798c12339cda25076fb69f41700a721a0f74b1 /src/virtualkeyboard/hunspellinputmethod.cpp | |
parent | 32dd5559f5cdf0bc5470cec285de6eeb7f8cbd4d (diff) |
Allow entering complete url / email with HunspellInputMethod
This change allows the user to enter complete url / email address
with HunspellInputMethod, without breaking the url into multiple
parts.
Change-Id: I19397064aaf6b0f9011b04efbee7e83d474c1ea9
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/virtualkeyboard/hunspellinputmethod.cpp')
-rw-r--r-- | src/virtualkeyboard/hunspellinputmethod.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/virtualkeyboard/hunspellinputmethod.cpp b/src/virtualkeyboard/hunspellinputmethod.cpp index 27afcb93..8ba05a9c 100644 --- a/src/virtualkeyboard/hunspellinputmethod.cpp +++ b/src/virtualkeyboard/hunspellinputmethod.cpp @@ -217,6 +217,7 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar Q_UNUSED(modifiers) Q_D(HunspellInputMethod); DeclarativeInputContext *ic = inputContext(); + Qt::InputMethodHints inputMethodHints = ic->inputMethodHints(); bool accept = false; switch (key) { case Qt::Key_Enter: @@ -237,14 +238,16 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar } break; default: - if (ic->inputMethodHints().testFlag(Qt::ImhNoPredictiveText)) + if (inputMethodHints.testFlag(Qt::ImhNoPredictiveText)) break; if (text.length() > 0) { QChar c = text.at(0); bool addToWord = !c.isPunct() && !c.isSymbol(); if (!addToWord) { if (!d->word.isEmpty()) { - if (c == Qt::Key_Apostrophe || c == Qt::Key_Minus) + if (inputMethodHints.testFlag(Qt::ImhUrlCharactersOnly) || inputMethodHints.testFlag(Qt::ImhEmailCharactersOnly)) + addToWord = QString(QStringLiteral(":/?#[]@!$&'()*+,;=-_.%")).contains(c); + else if (c == Qt::Key_Apostrophe || c == Qt::Key_Minus) addToWord = true; } } |