~mterry/unity8/split

« back to all changes in this revision

Viewing changes to plugins/Utils/plugin.cpp

  • Committer: Michael Terry
  • Date: 2013-10-15 17:48:24 UTC
  • mfrom: (138.2.326 trunk)
  • Revision ID: michael.terry@canonical.com-20131015174824-x1n7rx100b0ph8v4
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
// Qt
20
20
#include <QtQml/qqml.h>
21
21
#include <QtQuick/QQuickWindow>
22
 
 
 
22
#include <QDebug>
23
23
// self
24
24
#include "plugin.h"
25
25
 
26
26
// local
 
27
#include "albumartprovider.h"
27
28
#include "applicationpaths.h"
28
29
#include "qlimitproxymodelqml.h"
29
30
#include "qsortfilterproxymodelqml.h"
30
31
#include "ubuntuwindow.h"
 
32
#include "unitymenumodelpaths.h"
31
33
 
32
34
static QObject* applicationsPathsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
33
35
  Q_UNUSED(engine);
41
43
    qmlRegisterType<QAbstractItemModel>();
42
44
    qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
43
45
    qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
 
46
    qmlRegisterType<UnityMenuModelPaths>(uri, 0, 1, "UnityMenuModelPaths");
44
47
    qmlRegisterExtendedType<QQuickWindow, UbuntuWindow>(uri, 0, 1, "Window");
45
48
    qmlRegisterSingletonType<ApplicationPaths>(uri, 0, 1, "ApplicationPaths", applicationsPathsSingleton);
46
49
}
 
50
 
 
51
void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
 
52
{
 
53
    QQmlExtensionPlugin::initializeEngine(engine, uri);
 
54
 
 
55
    try
 
56
    {
 
57
        engine->addImageProvider(QLatin1String("albumart"), new AlbumArtProvider);
 
58
    }
 
59
    catch (const std::runtime_error &e)
 
60
    {
 
61
        qWarning() << "Failed to register image provider for albumart:" << e.what();
 
62
    }
 
63
    catch (...)
 
64
    {
 
65
        qWarning() << "Failed to register image provider for albumart (unknown error)";
 
66
    }
 
67
}