From 9fdf5bb4d49a9e7a24c571b723f883269ca06b69 Mon Sep 17 00:00:00 2001 From: Jarkko Koivikko Date: Mon, 19 Jan 2015 11:42:27 +0200 Subject: 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 --- src/virtualkeyboard/hunspellinputmethod.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/virtualkeyboard/hunspellinputmethod.cpp') 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; } } -- cgit v1.2.3