diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-03-12 16:41:07 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-03-26 11:32:02 +0100 |
commit | d2648237c7e3bfc03077b7b1e63c72dc24ff519c (patch) | |
tree | 903c3eed9283d54437d9748b3b1533fec7e25aa8 /src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod.cpp | |
parent | 007ac4095d554d6cad9c795ab5cb888a255db397 (diff) |
Auto-capitalize only after space following a sentence-ending characterv5.15.0-beta3
A dot alone should not change to capital letters, only the space
following the dot. This is standard behavior on mobile platforms.
In inputmethods that support auto-completion and auto-space-insertion,
we need to watch out if the auto-inserted space triggered auto-
capitalization. If so, then the inserted text needs to be
capitalized even though the keyboard will have shown lower-case
characters.
Fixes: QTBUG-77673
Change-Id: Icd907055d6557a7756468318fba5669eb8f62a28
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod.cpp')
-rw-r--r-- | src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod.cpp b/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod.cpp index 884ec9df..e7bb0a69 100644 --- a/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod.cpp +++ b/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod.cpp @@ -138,6 +138,7 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar QString word = d->wordCandidates.wordAt(0); bool addToWord = d->isValidInputChar(c) && (!word.isEmpty() || !d->isJoiner(c)); if (addToWord) { + QString newText = text; /* Automatic space insertion. */ if (word.isEmpty()) { QString surroundingText = ic->surroundingText(); @@ -153,7 +154,11 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar if (!lastChar.isSpace() && lastChar != Qt::Key_Minus && d->isAutoSpaceAllowed()) { + // auto-insertion of space might trigger auto-capitalization + bool wasShiftActive = ic->isShiftActive(); ic->commit(QLatin1String(" ")); + if (ic->isShiftActive() && !wasShiftActive) + newText = newText.toUpper(); } } } @@ -162,7 +167,7 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar a selection which the pre-edit text will replace. */ d->ignoreUpdate = word.isEmpty(); - word.append(text); + word.append(newText); d->wordCandidates.updateWord(0, word); ic->setPreeditText(word); d->ignoreUpdate = false; |