File indexing completed on 2026-09-18 09:24:38
0001
0002
0003
0004
0005 #ifndef QCOREAPPLICATION_PLATFORM_H
0006 #define QCOREAPPLICATION_PLATFORM_H
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <QtCore/qglobal.h>
0018 #include <QtCore/qnativeinterface.h>
0019 #include <QtCore/qcoreapplication.h>
0020
0021 #if defined(Q_OS_ANDROID) || defined(Q_QDOC)
0022 #include <QtCore/qjnitypes.h>
0023 #if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
0024 #include <QtCore/qfuture.h>
0025 #include <QtCore/qvariant.h>
0026 #endif
0027 #endif
0028
0029 #if defined(Q_OS_ANDROID)
0030 class _jobject;
0031 typedef _jobject* jobject;
0032 #endif
0033
0034 QT_BEGIN_NAMESPACE
0035
0036 namespace QNativeInterface
0037 {
0038 #if defined(Q_OS_ANDROID) || defined(Q_QDOC)
0039 struct Q_CORE_EXPORT QAndroidApplication
0040 {
0041 QT_DECLARE_NATIVE_INTERFACE(QAndroidApplication, 1, QCoreApplication)
0042 #ifdef Q_QDOC
0043 static QJniObject context();
0044 #else
0045 static QtJniTypes::Context context();
0046 #endif
0047 static bool isActivityContext();
0048 static int sdkVersion();
0049 static void hideSplashScreen(int duration = 0);
0050
0051 #if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
0052 static QFuture<QVariant> runOnAndroidMainThread(const std::function<QVariant()> &runnable,
0053 const QDeadlineTimer timeout = QDeadlineTimer::Forever);
0054
0055 template <class T>
0056 std::enable_if_t<std::is_invocable_v<T> && std::is_same_v<std::invoke_result_t<T>, void>,
0057 QFuture<void>> static runOnAndroidMainThread(const T &runnable,
0058 const QDeadlineTimer timeout = QDeadlineTimer::Forever)
0059 {
0060 std::function<QVariant()> func = [runnable](){ runnable(); return QVariant(); };
0061 return static_cast<QFuture<void>>(runOnAndroidMainThread(func, timeout));
0062 }
0063 #endif
0064 };
0065 #endif
0066 }
0067
0068 QT_END_NAMESPACE
0069
0070 #endif