~alan-griffiths/miral/fix-1645284

« back to all changes in this revision

Viewing changes to miral-qt/src/modules/Unity/Application/plugin.cpp

  • Committer: Alan Griffiths
  • Date: 2016-11-07 17:59:19 UTC
  • mfrom: (436.1.1 miral2)
  • Revision ID: alan@octopull.co.uk-20161107175919-stbb64i7j1htgog2
[miral-qt] delete all as qtmir work on MirAL has shifted to lp:~unity-team/qtmir/miral-qt-integration and this is a needless distration

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013-2016 Canonical, Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>.
15
 
 */
16
 
 
17
 
// Qt
18
 
#include <QQmlExtensionPlugin>
19
 
 
20
 
// local
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"
27
 
#include "window.h"
28
 
#include "windowmodel.h"
29
 
 
30
 
// platforms/mirserver
31
 
#include <mirsingleton.h>
32
 
 
33
 
// qtmir
34
 
#include "logging.h"
35
 
 
36
 
// unity-api
37
 
#include <unity/shell/application/Mir.h>
38
 
 
39
 
using namespace qtmir;
40
 
 
41
 
namespace {
42
 
QObject* applicationManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
43
 
    Q_UNUSED(engine);
44
 
    Q_UNUSED(scriptEngine);
45
 
    qCDebug(QTMIR_APPLICATIONS) << "applicationManagerSingleton - engine=" << engine << "scriptEngine=" << scriptEngine;
46
 
 
47
 
    return qtmir::ApplicationManager::singleton();
48
 
}
49
 
 
50
 
QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) {
51
 
    return qtmir::Mir::instance();
52
 
}
53
 
} // anonymous namespace
54
 
 
55
 
class UnityApplicationPlugin : public QQmlExtensionPlugin {
56
 
    Q_OBJECT
57
 
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
58
 
 
59
 
    virtual void registerTypes(const char* uri)
60
 
    {
61
 
        qCDebug(QTMIR_APPLICATIONS) << "UnityApplicationPlugin::registerTypes - this=" << this << "uri=" << uri;
62
 
        Q_ASSERT(QLatin1String(uri) == QLatin1String("Unity.Application"));
63
 
 
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*");
70
 
 
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);
83
 
 
84
 
        qmlRegisterType<qtmir::WindowModel>(uri, 0, 1, "WindowModel");
85
 
        qmlRegisterType<qtmir::TopLevelWindowModel>(uri, 0, 1, "TopLevelWindowModel");
86
 
    }
87
 
 
88
 
    virtual void initializeEngine(QQmlEngine *engine, const char *uri)
89
 
    {
90
 
        QQmlExtensionPlugin::initializeEngine(engine, uri);
91
 
    }
92
 
};
93
 
 
94
 
#include "plugin.moc"