]> rtime.felk.cvut.cz Git - coffee/qtwebbrowser.git/blob - src/imports/plugin.cpp
ebd59c10a51b2295c35b8af54f5bcda3df08b1e0
[coffee/qtwebbrowser.git] / src / imports / plugin.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtBrowser project.
7 **
8 ** $QT_BEGIN_LICENSE:GPL$
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 http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://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 2 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.GPLv2 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU General Public License version 2 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 3.0 as published by the Free Software
28 ** Foundation and appearing in the file LICENSE.GPL included in the
29 ** packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 3.0 requirements will be
31 ** met: http://www.gnu.org/copyleft/gpl.html.
32 **
33 **
34 ** $QT_END_LICENSE$
35 **
36 ****************************************************************************/
37
38 #include <QQmlExtensionPlugin>
39 #include "../app/touchtracker.h"
40 #include "../app/navigationhistoryproxymodel.h"
41
42 #include <qqml.h>
43 #include "../app/engine.cpp"
44 #include <QQmlEngine>
45 #include <QQmlContext>
46 #include <QtQml/qqmlextensionplugin.h>
47 #include <qqml.h>
48
49 QT_BEGIN_NAMESPACE
50
51 static QObject *engine_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
52 {
53     Q_UNUSED(engine);
54     Q_UNUSED(scriptEngine);
55     Engine *eng = new Engine();
56     return eng;
57 }
58
59 class WebBrowser : public QQmlExtensionPlugin
60 {
61     Q_OBJECT
62     Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
63 public:
64     virtual void registerTypes(const char *uri)
65     {
66         Q_ASSERT(QLatin1String(uri) == QLatin1String("WebBrowser"));
67         qmlRegisterType<TouchTracker>(uri, 1, 0, "TouchTracker");
68         qmlRegisterType<NavigationHistoryProxyModel>(uri, 1, 0, "SearchProxyModel");
69         qmlRegisterSingletonType<Engine>(uri, 1, 0, "WebEngine", engine_factory);
70     }
71
72     virtual void initializeEngine(QQmlEngine *engine, const char *uri)
73     {
74         Q_UNUSED(uri);
75     }
76 };
77
78 QT_END_NAMESPACE
79
80 #include "plugin.moc"
81