Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qwasmplatform.h"
5
7
9{
10 static const Platform qtDetectedPlatform = ([]() {
11 // The Platform Detect: expand coverage as needed
12 emscripten::val rawPlatform = emscripten::val::global("navigator")["platform"];
13
14 if (rawPlatform.call<bool>("includes", emscripten::val("Mac")))
15 return Platform::MacOS;
16 if (rawPlatform.call<bool>("includes", emscripten::val("iPhone"))
17 || rawPlatform.call<bool>("includes", emscripten::val("iPad")))
18 return Platform::iOS;
19 if (rawPlatform.call<bool>("includes", emscripten::val("Win32")))
20 return Platform::Windows;
21 if (rawPlatform.call<bool>("includes", emscripten::val("Linux"))) {
22 emscripten::val uAgent = emscripten::val::global("navigator")["userAgent"];
23 if (uAgent.call<bool>("includes", emscripten::val("Android")))
24 return Platform::Android;
25 return Platform::Linux;
26 }
27 return Platform::Generic;
28 })();
29 return qtDetectedPlatform;
30}
31
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Platform platform()
Platform