Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmplatform.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
8
9Platform platform()
10{
11 static const Platform qtDetectedPlatform = ([]() {
12 // The Platform Detect: expand coverage as needed
13 emscripten::val rawPlatform = emscripten::val::global("navigator")["platform"];
14
15 if (rawPlatform.call<bool>("includes", emscripten::val("Mac")))
16 return Platform::MacOS;
17 if (rawPlatform.call<bool>("includes", emscripten::val("iPhone"))
18 || rawPlatform.call<bool>("includes", emscripten::val("iPad")))
19 return Platform::iOS;
20 if (rawPlatform.call<bool>("includes", emscripten::val("Win32")))
21 return Platform::Windows;
22 if (rawPlatform.call<bool>("includes", emscripten::val("Linux"))) {
23 emscripten::val uAgent = emscripten::val::global("navigator")["userAgent"];
24 if (uAgent.call<bool>("includes", emscripten::val("Android")))
25 return Platform::Android;
26 return Platform::Linux;
27 }
28 return Platform::Generic;
29 })();
30 return qtDetectedPlatform;
31}
32
33QT_END_NAMESPACE
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Platform platform()