Delay showing keyboard until application is active

Android starts asking lots of questions when the software keyboard
pops up, so let's wait until the application is initialized. This
works around a deadlock on startup.

Task-number: QTBUG-41369
Change-Id: I1c79e32d08c7cc11748ec55efbff3bc25e40f4b2
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Paul Olav Tvete 2014-10-13 13:09:06 +02:00
parent 096d0ef02b
commit 1faba97683
2 changed files with 15 additions and 0 deletions

View File

@ -519,6 +519,10 @@ bool QAndroidInputContext::isAnimating() const
void QAndroidInputContext::showInputPanel()
{
if (QGuiApplication::applicationState() != Qt::ApplicationActive) {
connect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState)));
return;
}
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe();
if (query.isNull())
return;
@ -541,6 +545,14 @@ void QAndroidInputContext::showInputPanel()
query->value(Qt::ImHints).toUInt());
}
void QAndroidInputContext::showInputPanelLater(Qt::ApplicationState state)
{
if (state != Qt::ApplicationActive)
return;
disconnect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState)));
showInputPanel();
}
void QAndroidInputContext::hideInputPanel()
{
QtAndroidInput::hideSoftwareKeyboard();

View File

@ -112,6 +112,9 @@ public:
public slots:
void updateCursorPosition();
private slots:
void showInputPanelLater(Qt::ApplicationState);
private:
void sendInputMethodEventThreadSafe(QInputMethodEvent *event);
Q_INVOKABLE void sendInputMethodEventUnsafe(QInputMethodEvent *event);