2
* Copyright (C) 2013-2016 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include <QQmlExtensionPlugin>
21
#include "application.h"
22
#include "application_manager.h"
23
#include "mirsurfaceinterface.h"
24
#include "mirsurfaceitem.h"
25
#include "mirsurfacelistmodel.h"
26
#include "toplevelwindowmodel.h"
28
#include "windowmodel.h"
30
// platforms/mirserver
31
#include <mirsingleton.h>
37
#include <unity/shell/application/Mir.h>
39
using namespace qtmir;
42
QObject* applicationManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
44
Q_UNUSED(scriptEngine);
45
qCDebug(QTMIR_APPLICATIONS) << "applicationManagerSingleton - engine=" << engine << "scriptEngine=" << scriptEngine;
47
return qtmir::ApplicationManager::singleton();
50
QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) {
51
return qtmir::Mir::instance();
53
} // anonymous namespace
55
class UnityApplicationPlugin : public QQmlExtensionPlugin {
57
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
59
virtual void registerTypes(const char* uri)
61
qCDebug(QTMIR_APPLICATIONS) << "UnityApplicationPlugin::registerTypes - this=" << this << "uri=" << uri;
62
Q_ASSERT(QLatin1String(uri) == QLatin1String("Unity.Application"));
64
qRegisterMetaType<qtmir::ApplicationManager*>("ApplicationManager*"); //need for queueing signals
65
qRegisterMetaType<qtmir::Application*>("Application*");
66
qRegisterMetaType<unity::shell::application::MirSurfaceInterface*>("MirSurfaceInterface*");
67
qRegisterMetaType<unity::shell::application::MirSurfaceListInterface*>("unity::shell::application::MirSurfaceListInterface*");
68
qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib");
69
qRegisterMetaType<unity::shell::application::WindowInterface*>("unity::shell::application::WindowInterface*");
71
qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(
72
uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
73
qmlRegisterSingletonType<qtmir::ApplicationManager>(
74
uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
75
qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(
76
uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
77
qmlRegisterUncreatableType<qtmir::Application>(
78
uri, 0, 1, "ApplicationInfo", "Application can't be instantiated");
79
qmlRegisterUncreatableType<unity::shell::application::MirSurfaceInterface>(
80
uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");
81
qmlRegisterType<qtmir::MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem");
82
qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton);
84
qmlRegisterType<qtmir::WindowModel>(uri, 0, 1, "WindowModel");
85
qmlRegisterType<qtmir::TopLevelWindowModel>(uri, 0, 1, "TopLevelWindowModel");
88
virtual void initializeEngine(QQmlEngine *engine, const char *uri)
90
QQmlExtensionPlugin::initializeEngine(engine, uri);