Detect when we are at the sentence boundary
On Samsung devices this would cause it to always to captalize each word even if it was not a new sentence. Therefore we use QTextBoundaryFinder to determine if it is a new sentence or not. Task-number: QTBUG-69398 Task-number: QTBUG-66531 Change-Id: I24bf36f09a2570acfefd4343551cb1720ddc6279 Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
bff307ab93
commit
45c1473847
@ -58,6 +58,7 @@
|
||||
#include <private/qhighdpiscaling_p.h>
|
||||
|
||||
#include <QTextCharFormat>
|
||||
#include <QTextBoundaryFinder>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -892,8 +893,19 @@ jint QAndroidInputContext::getCursorCapsMode(jint /*reqModes*/)
|
||||
return res;
|
||||
|
||||
const uint qtInputMethodHints = query->value(Qt::ImHints).toUInt();
|
||||
const int localPos = query->value(Qt::ImCursorPosition).toInt();
|
||||
|
||||
if (!(qtInputMethodHints & Qt::ImhLowercaseOnly) && !(qtInputMethodHints & Qt::ImhNoAutoUppercase))
|
||||
bool atWordBoundary = (localPos == 0);
|
||||
if (!atWordBoundary) {
|
||||
QString surroundingText = query->value(Qt::ImSurroundingText).toString();
|
||||
surroundingText.truncate(localPos);
|
||||
// Add a character to see if it is at the end of the sentence or not
|
||||
QTextBoundaryFinder finder(QTextBoundaryFinder::Sentence, surroundingText + QLatin1Char('A'));
|
||||
finder.setPosition(localPos);
|
||||
if (finder.isAtBoundary())
|
||||
atWordBoundary = finder.isAtBoundary();
|
||||
}
|
||||
if (atWordBoundary && !(qtInputMethodHints & Qt::ImhLowercaseOnly) && !(qtInputMethodHints & Qt::ImhNoAutoUppercase))
|
||||
res |= CAP_MODE_SENTENCES;
|
||||
|
||||
if (qtInputMethodHints & Qt::ImhUppercaseOnly)
|
||||
|
Loading…
x
Reference in New Issue
Block a user