diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2016-11-12 22:28:51 +0200 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2016-12-19 18:57:49 +0000 |
commit | b87766345e7089670629b1c75e9c350846849dac (patch) | |
tree | bbbe23baac7d2a5185164e16696ac96446c6bf6f | |
parent | 46960f146d3d44c77108e4766fe0292f125b6d19 (diff) |
Defer shift state change until input panel becomes visible
Monitor the visible state of the QInputMethod and defer
shift state handling until it becomes visible.
Task-number: QTBUG-57082
Change-Id: I6e63e57e2630de37d49a522f05257c9c4dd72286
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/virtualkeyboard/shifthandler.cpp | 18 | ||||
-rw-r--r-- | src/virtualkeyboard/shifthandler.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/virtualkeyboard/shifthandler.cpp b/src/virtualkeyboard/shifthandler.cpp index d6252fa9..997123d8 100644 --- a/src/virtualkeyboard/shifthandler.cpp +++ b/src/virtualkeyboard/shifthandler.cpp @@ -32,6 +32,7 @@ #include "inputengine.h" #include <QtCore/private/qobject_p.h> #include <QSet> +#include <QGuiApplication> namespace QtVirtualKeyboard { @@ -45,6 +46,7 @@ public: autoCapitalizationEnabled(false), toggleShiftEnabled(false), shiftChanged(false), + resetWhenVisible(false), manualShiftLanguageFilter(QSet<QLocale::Language>() << QLocale::Arabic << QLocale::Persian << QLocale::Hindi << QLocale::Korean), manualCapsInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::Cangjie << InputEngine::Zhuyin), noAutoUppercaseInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::FullwidthLatin << InputEngine::Pinyin << InputEngine::Cangjie << InputEngine::Zhuyin), @@ -57,6 +59,7 @@ public: bool autoCapitalizationEnabled; bool toggleShiftEnabled; bool shiftChanged; + bool resetWhenVisible; QLocale locale; const QSet<QLocale::Language> manualShiftLanguageFilter; const QSet<InputEngine::InputMode> manualCapsInputModeFilter; @@ -95,6 +98,7 @@ ShiftHandler::ShiftHandler(InputContext *parent) : connect(d->inputContext, SIGNAL(shiftChanged()), SLOT(shiftChanged())); connect(d->inputContext, SIGNAL(capsLockChanged()), SLOT(shiftChanged())); connect(d->inputContext, SIGNAL(localeChanged()), SLOT(localeChanged())); + connect(qGuiApp->inputMethod(), SIGNAL(visibleChanged()), SLOT(inputMethodVisibleChanged())); d->locale = QLocale(d->inputContext->locale()); } } @@ -239,6 +243,11 @@ void ShiftHandler::autoCapitalize() void ShiftHandler::restart() { + Q_D(ShiftHandler); + if (!qGuiApp->inputMethod()->isVisible()) { + d->resetWhenVisible = true; + return; + } reset(); } @@ -255,6 +264,15 @@ void ShiftHandler::localeChanged() restart(); } +void ShiftHandler::inputMethodVisibleChanged() +{ + Q_D(ShiftHandler); + if (d->resetWhenVisible && qGuiApp->inputMethod()->isVisible()) { + d->resetWhenVisible = false; + reset(); + } +} + void ShiftHandler::setAutoCapitalizationEnabled(bool enabled) { Q_D(ShiftHandler); diff --git a/src/virtualkeyboard/shifthandler.h b/src/virtualkeyboard/shifthandler.h index 4e63a946..c28a9581 100644 --- a/src/virtualkeyboard/shifthandler.h +++ b/src/virtualkeyboard/shifthandler.h @@ -69,6 +69,7 @@ private slots: void restart(); void localeChanged(); void shiftChanged(); + void inputMethodVisibleChanged(); private: void setAutoCapitalizationEnabled(bool enabled); |