-
Notifications
You must be signed in to change notification settings - Fork 477
/
Copy pathplugin.cpp
40 lines (32 loc) · 1.19 KB
/
plugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* QML Material - An application framework implementing Material Design.
*
* Copyright (C) 2016 Michael Spencer <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "plugin.h"
#include <QtQml>
#include "core/device.h"
#include "core/units.h"
#include "core/iconhelper.h"
class MaterialRegisterHelper {
public:
MaterialRegisterHelper(const char *uri) {
qmlRegisterSingletonType<Device>(uri, 0, 1, "Device", Device::qmlSingleton);
qmlRegisterType<IconHelper>(uri, 0, 1, "IconHelper"/*, IconHelper::qmlSingleton*/);
qmlRegisterUncreatableType<Units>(uri, 0, 3, "Units", QStringLiteral("Units can only be used via the attached property."));
}
};
void MaterialPlugin::registerTypes(const char *uri)
{
// @uri Material
Q_ASSERT(uri == QStringLiteral("Material"));
MaterialRegisterHelper helper(uri);
}
// When using QPM, the C++ plugin is not used and the QML types must be registered manually
#ifdef QPM_INIT
static MaterialRegisterHelper registerHelper("Material");
#endif