From 12770fd63e172acc8b6b0089350313d6550be7cd Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Date: Thu, 24 Mar 2016 11:02:38 +0100
Subject: [PATCH] Add a Qt Designer plugin for QWebEngineView.

Task-number: QTBUG-52104
Change-Id: I8c7c431e8256b2b44d42b9a1532d7341fdafee9c
---
 src/designer/src/plugins/plugins.pro               |   1 +
 .../qwebengineview/images/qwebengineview.png       | Bin 0 -> 1473 bytes
 .../src/plugins/qwebengineview/qwebengineview.pro  |   9 ++
 .../qwebengineview/qwebengineview_plugin.cpp       | 129 +++++++++++++++++++++
 .../plugins/qwebengineview/qwebengineview_plugin.h |  67 +++++++++++
 .../qwebengineview/qwebengineview_plugin.qrc       |   5 +
 sync.profile                                       |   1 +
 7 files changed, 212 insertions(+)
 create mode 100644 src/designer/src/plugins/qwebengineview/images/qwebengineview.png
 create mode 100644 src/designer/src/plugins/qwebengineview/qwebengineview.pro
 create mode 100644 src/designer/src/plugins/qwebengineview/qwebengineview_plugin.cpp
 create mode 100644 src/designer/src/plugins/qwebengineview/qwebengineview_plugin.h
 create mode 100644 src/designer/src/plugins/qwebengineview/qwebengineview_plugin.qrc

diff --git a/src/designer/src/plugins/plugins.pro b/src/designer/src/plugins/plugins.pro
index 500a153..d554155 100644
--- a/src/designer/src/plugins/plugins.pro
+++ b/src/designer/src/plugins/plugins.pro
@@ -2,5 +2,6 @@ TEMPLATE = subdirs
 
 # qtHaveModule(opengl): SUBDIRS += tools/view3d
 qtHaveModule(webkitwidgets): SUBDIRS += qwebview
+qtHaveModule(webenginewidgets): SUBDIRS += qwebengineview
 win32: qtHaveModule(axcontainer): SUBDIRS += activeqt
 qtHaveModule(quickwidgets): SUBDIRS += qquickwidget
diff --git a/src/designer/src/plugins/qwebengineview/images/qwebengineview.png b/src/designer/src/plugins/qwebengineview/images/qwebengineview.png
new file mode 100644
index 0000000000000000000000000000000000000000..01a0920c93c67e94ee3c9b8317fd6dd1437e8e4d
GIT binary patch
diff --git a/src/designer/src/plugins/qwebengineview/qwebengineview.pro b/src/designer/src/plugins/qwebengineview/qwebengineview.pro
new file mode 100644
index 0000000..d4d1cc8
--- /dev/null
+++ b/src/designer/src/plugins/qwebengineview/qwebengineview.pro
@@ -0,0 +1,9 @@
+TARGET      = qwebengineview
+QT         += webenginewidgets
+
+PLUGIN_CLASS_NAME = QWebEngineViewPlugin
+include(../plugins.pri)
+
+SOURCES += qwebengineview_plugin.cpp
+HEADERS += qwebengineview_plugin.h
+RESOURCES += qwebengineview_plugin.qrc
diff --git a/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.cpp b/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.cpp
new file mode 100644
index 0000000..04dbfac
--- /dev/null
+++ b/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebengineview_plugin.h"
+
+#include <QtDesigner/QExtensionFactory>
+#include <QtDesigner/QExtensionManager>
+
+#include <QtCore/qplugin.h>
+#include <QWebEngineView>
+
+QT_BEGIN_NAMESPACE
+
+static const char toolTipC[] =
+    QT_TRANSLATE_NOOP(QWebEngineViewPlugin,
+                      "A widget for displaying a web page, from the Qt WebEngineWidgets module");
+
+QWebEngineViewPlugin::QWebEngineViewPlugin(QObject *parent) :
+    QObject(parent),
+    m_initialized(false)
+{
+}
+
+QString QWebEngineViewPlugin::name() const
+{
+    return QStringLiteral("QWebEngineView");
+}
+
+QString QWebEngineViewPlugin::group() const
+{
+    return QStringLiteral("Display Widgets");
+}
+
+QString QWebEngineViewPlugin::toolTip() const
+{
+    return tr(toolTipC);
+}
+
+QString QWebEngineViewPlugin::whatsThis() const
+{
+    return tr(toolTipC);
+}
+
+QString QWebEngineViewPlugin::includeFile() const
+{
+    return QStringLiteral("<QtWebEngineWidgets/QWebEngineView>");
+}
+
+QIcon QWebEngineViewPlugin::icon() const
+{
+    return QIcon(QStringLiteral(":/qt-project.org/qwebengineview/images/qwebengineview.png"));
+}
+
+bool QWebEngineViewPlugin::isContainer() const
+{
+    return false;
+}
+
+QWidget *QWebEngineViewPlugin::createWidget(QWidget *parent)
+{
+    return new QWebEngineView(parent);
+}
+
+bool QWebEngineViewPlugin::isInitialized() const
+{
+    return m_initialized;
+}
+
+void QWebEngineViewPlugin::initialize(QDesignerFormEditorInterface * /*core*/)
+{
+    if (m_initialized)
+        return;
+
+    m_initialized = true;
+}
+
+QString QWebEngineViewPlugin::domXml() const
+{
+    return QStringLiteral("\
+    <ui language=\"c++\">\
+        <widget class=\"QWebEngineView\" name=\"webEngineView\">\
+            <property name=\"url\">\
+                <url>\
+                    <string>about:blank</string>\
+                </url>\
+            </property>\
+            <property name=\"geometry\">\
+                <rect>\
+                    <x>0</x>\
+                    <y>0</y>\
+                    <width>300</width>\
+                    <height>200</height>\
+                </rect>\
+            </property>\
+        </widget>\
+    </ui>");
+}
+
+QT_END_NAMESPACE
diff --git a/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.h b/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.h
new file mode 100644
index 0000000..331fbc5
--- /dev/null
+++ b/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINEVIEW_PLUGIN_H
+#define QWEBENGINEVIEW_PLUGIN_H
+
+#include <QtUiPlugin/QDesignerCustomWidgetInterface>
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineViewPlugin: public QObject, public QDesignerCustomWidgetInterface
+{
+    Q_OBJECT
+    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
+    Q_INTERFACES(QDesignerCustomWidgetInterface)
+public:
+    explicit QWebEngineViewPlugin(QObject *parent = Q_NULLPTR);
+
+    QString name() const Q_DECL_OVERRIDE;
+    QString group() const Q_DECL_OVERRIDE;
+    QString toolTip() const Q_DECL_OVERRIDE;
+    QString whatsThis() const Q_DECL_OVERRIDE;
+    QString includeFile() const Q_DECL_OVERRIDE;
+    QIcon icon() const Q_DECL_OVERRIDE;
+    bool isContainer() const Q_DECL_OVERRIDE;
+    QWidget *createWidget(QWidget *parent) Q_DECL_OVERRIDE;
+    bool isInitialized() const Q_DECL_OVERRIDE;
+    void initialize(QDesignerFormEditorInterface *core) Q_DECL_OVERRIDE;
+    QString domXml() const Q_DECL_OVERRIDE;
+
+private:
+    bool m_initialized;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEVIEW_PLUGIN_H
diff --git a/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.qrc b/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.qrc
new file mode 100644
index 0000000..181625c
--- /dev/null
+++ b/src/designer/src/plugins/qwebengineview/qwebengineview_plugin.qrc
@@ -0,0 +1,5 @@
+<RCC>
+  <qresource prefix="/qt-project.org/qwebengineview">
+    <file>images/qwebengineview.png</file>
+  </qresource>
+</RCC>
diff --git a/sync.profile b/sync.profile
index 28a3d1b..7d60f33 100644
--- a/sync.profile
+++ b/sync.profile
@@ -31,4 +31,5 @@
     "qtxmlpatterns" => "",
     "qtdeclarative" => "",
     "qtactiveqt" => "",
+    "qtwebenginewidgets" => "",
 );
-- 
2.5.0.windows.1

