diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2017-08-22 00:01:10 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2017-08-24 13:56:04 +0000 |
commit | dc4e962fab576e7c6dd1b5f1b08a71b08fadfc15 (patch) | |
tree | e51385c86f96633b163fa66de5883bb5f04fd3ed /src | |
parent | d80646f8f11283ad4bd9996d5a59a1154e7f651d (diff) |
Clear toggle shift timer when appropriate
The timer in the ShiftHandler is used for detecting double
click events for shift key. A double click event will trigger
caps lock if the initial shift state is lower case.
However, the implementation did not handle a case where
the keyboard layout changes between the first and second
press. This can be done with multitouch.
The second problem was with the automatic test cases, where
the test code toggles the shift to see if there is a secondary
layout triggered by the shift key, e.g. in Arabic and Farsi.
However, if the keyboard layout does not contain secondary
layout, rapid shift state change will trigger caps lock
instead. This issue was identified with certain test case for
Hebrew layout.
This change fixes the issue by clearing the shift toggle timer
when the layout changes and in the automatic tests while
checking for the secondary layout with the shift key.
Also, update test code so that the shift press is simulated
with mouse. This will ensure the key exists in the layout
and that the key is enabled.
Change-Id: I2a528f1b82c30e8b8d9746d380b32ee370b38004
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/virtualkeyboard/content/components/Keyboard.qml | 3 | ||||
-rw-r--r-- | src/virtualkeyboard/shifthandler.cpp | 12 | ||||
-rw-r--r-- | src/virtualkeyboard/shifthandler.h | 1 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/virtualkeyboard/content/components/Keyboard.qml b/src/virtualkeyboard/content/components/Keyboard.qml index 47df1afa..22378b44 100644 --- a/src/virtualkeyboard/content/components/Keyboard.qml +++ b/src/virtualkeyboard/content/components/Keyboard.qml @@ -1179,6 +1179,9 @@ Item { inputModeNeedsReset = false } } + + // Clear the toggle shift timer + InputContext.shiftHandler.clearToggleShiftTimer() } function updateLayout() { diff --git a/src/virtualkeyboard/shifthandler.cpp b/src/virtualkeyboard/shifthandler.cpp index 62d23775..19117c81 100644 --- a/src/virtualkeyboard/shifthandler.cpp +++ b/src/virtualkeyboard/shifthandler.cpp @@ -54,7 +54,6 @@ public: noAutoUppercaseInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::FullwidthLatin << InputEngine::Pinyin << InputEngine::Cangjie << InputEngine::Zhuyin << InputEngine::ChineseHandwriting << InputEngine::JapaneseHandwriting << InputEngine::KoreanHandwriting), allCapsInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::Hiragana << InputEngine::Katakana) { - timer.start(); } InputContext *inputContext; @@ -185,7 +184,7 @@ void ShiftHandler::toggleShift() QStyleHints *style = QGuiApplication::styleHints(); - if (d->timer.elapsed() > style->mouseDoubleClickInterval()) { + if (d->timer.isNull() || d->timer.elapsed() > style->mouseDoubleClickInterval()) { d->timer.restart(); } else if (d->timer.elapsed() < style->mouseDoubleClickInterval() && !d->inputContext->capsLock()) { d->inputContext->setCapsLock(!d->inputContext->capsLock() && d->inputContext->shift() && !d->shiftChanged); @@ -196,6 +195,15 @@ void ShiftHandler::toggleShift() } } +/*! Clears the toggle shift timer. + +*/ +void ShiftHandler::clearToggleShiftTimer() +{ + Q_D(ShiftHandler); + d->timer = QTime(); +} + void ShiftHandler::reset() { Q_D(ShiftHandler); diff --git a/src/virtualkeyboard/shifthandler.h b/src/virtualkeyboard/shifthandler.h index c28a9581..93ba3e34 100644 --- a/src/virtualkeyboard/shifthandler.h +++ b/src/virtualkeyboard/shifthandler.h @@ -57,6 +57,7 @@ public: bool toggleShiftEnabled() const; Q_INVOKABLE void toggleShift(); + Q_INVOKABLE void clearToggleShiftTimer(); signals: void sentenceEndingCharactersChanged(); |