summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesignerbase/utils/studioquickwidget.h
blob: ef64fb6a69dd2be64c52657589d14be2c0fd1db2 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "../qmldesignerbase_global.h"

#include <QObject>
#include <QQmlPropertyMap>
#include <QtQuickWidgets/QQuickWidget>

class QMLDESIGNERBASE_EXPORT StudioPropertyMap : public QQmlPropertyMap
{
public:
    struct PropertyPair
    {
        QString name;
        QVariant value;
    };

    explicit StudioPropertyMap(QObject *parent = 0);

    void setProperties(const QList<PropertyPair> &properties);
};

class QMLDESIGNERBASE_EXPORT StudioQuickWidget : public QWidget
{
    Q_OBJECT
public:
    explicit StudioQuickWidget(QWidget *parent = nullptr);

    QQmlEngine *engine() const;
    QQmlContext *rootContext() const;

    QQuickItem *rootObject() const;

    void setResizeMode(QQuickWidget::ResizeMode mode);

    void setSource(const QUrl &url);

    void refresh();

    void setClearColor(const QColor &color);

    QList<QQmlError> errors() const;

    StudioPropertyMap *registerPropertyMap(const QByteArray &name);
    QQuickWidget *quickWidget() const;

private:
    QQuickWidget *m_quickWidget = nullptr;
};