summaryrefslogtreecommitdiffstats
path: root/src/common-lib/qml-utilities.h
blob: 388ceefa40d1a41426b6b890b8ef4fcc9144a02f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QML_UTILITIES_H
#define QML_UTILITIES_H

#include <QtAppManCommon/global.h>
#include <QtQml/QQmlEngine>
#include <QtQml/qqml.h>

// This macro is necessary to force the linker to include the code that registers the types. We
// are statically linking, so any unreferenced symbol is not linked in at all.
#define AM_QML_REGISTER_TYPES(URI_UNDERSCORE) \
    QT_BEGIN_NAMESPACE \
    extern void qml_register_types_##URI_UNDERSCORE(); \
    auto qtam_static_qml_register_types_##URI_UNDERSCORE = &qml_register_types_##URI_UNDERSCORE; \
    QT_END_NAMESPACE


QT_BEGIN_NAMESPACE_AM

// recursively resolve QJSValues
QVariant convertFromJSVariant(const QVariant &variant);

void loadQmlDummyDataFiles(QQmlEngine *engine, const QString &directory);

bool tagQmlContext(QQmlContext *context, const QVariant &value);
QVariant findTaggedQmlContext(QObject *object);

bool ensureCurrentContextIsSystemUI(QObject *object);
bool ensureCurrentContextIsInProcessApplication(QObject *object);

QT_END_NAMESPACE_AM

#endif // QML_UTILITIES_H