Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:04:23

0001 // Copyright (C) 2021 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QCOREAPPLICATION_PLATFORM_H
0005 #define QCOREAPPLICATION_PLATFORM_H
0006 
0007 //
0008 //  W A R N I N G
0009 //  -------------
0010 //
0011 // This file is part of the native interface APIs. Usage of
0012 // this API may make your code source and binary incompatible
0013 // with future versions of Qt.
0014 //
0015 
0016 #include <QtCore/qglobal.h>
0017 #include <QtCore/qnativeinterface.h>
0018 #include <QtCore/qcoreapplication.h>
0019 
0020 #if defined(Q_OS_ANDROID) || defined(Q_QDOC)
0021 #include <QtCore/qjnitypes.h>
0022 #if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
0023 #include <QtCore/qfuture.h>
0024 #include <QtCore/qvariant.h>
0025 #endif
0026 #endif // #if defined(Q_OS_ANDROID) || defined(Q_QDOC)
0027 
0028 #if defined(Q_OS_ANDROID)
0029 class _jobject;
0030 typedef _jobject* jobject;
0031 #endif
0032 
0033 QT_BEGIN_NAMESPACE
0034 
0035 namespace QNativeInterface
0036 {
0037 #if defined(Q_OS_ANDROID) || defined(Q_QDOC)
0038 struct Q_CORE_EXPORT QAndroidApplication
0039 {
0040     QT_DECLARE_NATIVE_INTERFACE(QAndroidApplication, 1, QCoreApplication)
0041 #ifdef Q_QDOC
0042     static QJniObject context();
0043 #else
0044     static QtJniTypes::Context context();
0045 #endif
0046     static bool isActivityContext();
0047     static int sdkVersion();
0048     static void hideSplashScreen(int duration = 0);
0049 
0050 #if QT_CONFIG(future) && !defined(QT_NO_QOBJECT)
0051     static QFuture<QVariant> runOnAndroidMainThread(const std::function<QVariant()> &runnable,
0052                                             const QDeadlineTimer timeout = QDeadlineTimer::Forever);
0053 
0054     template <class T>
0055     std::enable_if_t<std::is_invocable_v<T> && std::is_same_v<std::invoke_result_t<T>, void>,
0056     QFuture<void>> static runOnAndroidMainThread(const T &runnable,
0057                                             const QDeadlineTimer timeout = QDeadlineTimer::Forever)
0058     {
0059         std::function<QVariant()> func = [runnable](){ runnable(); return QVariant(); };
0060         return static_cast<QFuture<void>>(runOnAndroidMainThread(func, timeout));
0061     }
0062 #endif
0063 };
0064 #endif
0065 }
0066 
0067 QT_END_NAMESPACE
0068 
0069 #endif // QCOREAPPLICATION_PLATFORM_H