summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2017-12-15 15:56:25 +0200
committerBogDan Vatra <bogdan@kdab.com>2018-03-14 18:24:29 +0000
commit80f52812f2651e6d427bb3dd2e338b60fb25d48b (patch)
tree33c3c9a6bff550d288c2a9c808f3ed759236ff3b /src/plugins/platforms/android
parentf6fd8dceeab120cd9c0cfd68d06c916963ba796a (diff)
Hide cursor handle after ~4s on inactivity
When the VK is hidden keep cursor handle the cursor handle visible for ~4s after user last activity. Task-number: QTBUG-66806 Change-Id: I8122c5886efaeee86bb691ad971aa7a3e3d7f8e1 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp16
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.h2
2 files changed, 18 insertions, 0 deletions
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 <qpa/qplatforminputcontext.h>
#include <jni.h>
#include <qevent.h>
+#include <QTimer>
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