1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include "qquickwidget_plugin.h"
30
31#include <QtDesigner/default_extensionfactory.h>
32#include <QtDesigner/qextensionmanager.h>
33
34#include <QtCore/qplugin.h>
35#include <QtCore/qdebug.h>
36#include <QtQuickWidgets/qquickwidget.h>
37
38QT_BEGIN_NAMESPACE
39
40QQuickWidgetPlugin::QQuickWidgetPlugin(QObject *parent)
41 : QObject(parent)
42{
43}
44
45QString QQuickWidgetPlugin::name() const
46{
47 return QStringLiteral("QQuickWidget");
48}
49
50QString QQuickWidgetPlugin::group() const
51{
52 return QStringLiteral("Display Widgets");
53}
54
55QString QQuickWidgetPlugin::toolTip() const
56{
57 return QStringLiteral("A widget for displaying a Qt Quick 2 user interface.");
58}
59
60QString QQuickWidgetPlugin::whatsThis() const
61{
62 return toolTip();
63}
64
65QString QQuickWidgetPlugin::includeFile() const
66{
67 return QStringLiteral("<QtQuickWidgets/QQuickWidget>");
68}
69
70QIcon QQuickWidgetPlugin::icon() const
71{
72 return QIcon(QStringLiteral(":/qt-project.org/qquickwidget/images/qquickwidget.png"));
73}
74
75bool QQuickWidgetPlugin::isContainer() const
76{
77 return false;
78}
79
80QWidget *QQuickWidgetPlugin::createWidget(QWidget *parent)
81{
82 QQuickWidget *result = new QQuickWidget(parent);
83 connect(sender: result, signal: &QQuickWidget::sceneGraphError,
84 receiver: this, slot: &QQuickWidgetPlugin::sceneGraphError);
85 return result;
86}
87
88bool QQuickWidgetPlugin::isInitialized() const
89{
90 return m_initialized;
91}
92
93void QQuickWidgetPlugin::initialize(QDesignerFormEditorInterface * /*core*/)
94{
95 if (m_initialized)
96 return;
97
98 m_initialized = true;
99}
100
101QString QQuickWidgetPlugin::domXml() const
102{
103 return QStringLiteral("\
104 <ui language=\"c++\">\
105 <widget class=\"QQuickWidget\" name=\"quickWidget\">\
106 <property name=\"resizeMode\">\
107 <enum>QQuickWidget::SizeRootObjectToView</enum>\
108 </property>\
109 <property name=\"geometry\">\
110 <rect>\
111 <x>0</x>\
112 <y>0</y>\
113 <width>300</width>\
114 <height>200</height>\
115 </rect>\
116 </property>\
117 </widget>\
118 </ui>");
119}
120
121void QQuickWidgetPlugin::sceneGraphError(QQuickWindow::SceneGraphError, const QString &message)
122{
123 qWarning() << Q_FUNC_INFO << ':' << message;
124}
125
126QT_END_NAMESPACE
127

source code of qttools/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.cpp