diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index d6da1998cf..430eaf638b 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -471,6 +471,13 @@ QAndroidInputContext::QAndroidInputContext() updateSelectionHandles(); } }); + m_hideCursorHandleTimer.setInterval(4000); + m_hideCursorHandleTimer.setSingleShot(true); + m_hideCursorHandleTimer.setTimerType(Qt::VeryCoarseTimer); + connect(&m_hideCursorHandleTimer, &QTimer::timeout, this, [this]{ + m_handleMode = Hidden; + updateSelectionHandles(); + }); } QAndroidInputContext::~QAndroidInputContext() @@ -590,6 +597,10 @@ void QAndroidInputContext::updateSelectionHandles() QPoint editMenuPoint(curRect.center().x(), curRect.top()); QtAndroidInput::updateHandles(m_handleMode, cursorPoint * pixelDensity, editMenuPoint * pixelDensity); + m_handleMode |= ShowCursor; + // The VK is hidden, reset the timer + if (m_hideCursorHandleTimer.isActive()) + m_hideCursorHandleTimer.start(); return; } @@ -603,6 +614,7 @@ void QAndroidInputContext::updateSelectionHandles() QPoint righPoint(rightRect.bottomRight().toPoint() * pixelDensity); QtAndroidInput::updateHandles(ShowSelection, leftPoint, righPoint, query.value(Qt::ImCurrentSelection).toString().isRightToLeft()); + m_hideCursorHandleTimer.stop(); } /* @@ -690,6 +702,8 @@ void QAndroidInputContext::touchDown(int x, int y) if (m_focusObject && inputItemRectangle().contains(x, y)) { // If the user touch the input rectangle, we can show the cursor handle m_handleMode = ShowCursor; + // The VK will appear in a moment, stop the timer + m_hideCursorHandleTimer.stop(); QMetaObject::invokeMethod(this, "updateSelectionHandles", Qt::QueuedConnection); } } @@ -747,6 +761,8 @@ void QAndroidInputContext::hideSelectionHandles() if (m_handleMode & ShowSelection) { m_handleMode = Hidden; updateSelectionHandles(); + } else { + m_hideCursorHandleTimer.start(); } } diff --git a/src/plugins/platforms/android/qandroidinputcontext.h b/src/plugins/platforms/android/qandroidinputcontext.h index a6e22fa4f7..1b351f16bd 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.h +++ b/src/plugins/platforms/android/qandroidinputcontext.h @@ -44,6 +44,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -157,6 +158,7 @@ private: HandleModes m_handleMode; QAtomicInt m_batchEditNestingLevel; QObject *m_focusObject; + QTimer m_hideCursorHandleTimer; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QAndroidInputContext::HandleModes) QT_END_NAMESPACE