summaryrefslogtreecommitdiffstats
path: root/src/imports/bluetoothsettings
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/bluetoothsettings')
-rw-r--r--src/imports/bluetoothsettings/plugin.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/imports/bluetoothsettings/plugin.cpp b/src/imports/bluetoothsettings/plugin.cpp
index d0a25c3..20f5b28 100644
--- a/src/imports/bluetoothsettings/plugin.cpp
+++ b/src/imports/bluetoothsettings/plugin.cpp
@@ -43,6 +43,13 @@
#include "bluetoothdevice.h"
#include "discoverymodel.h"
+template <typename T>
+QObject *instance(QQmlEngine *engine, QJSEngine *) {
+ T *t = new T(engine);
+ t->setObjectName(T::staticMetaObject.className());
+ return t;
+}
+
class BluetoothSettingsQmlPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
@@ -53,14 +60,7 @@ public:
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("com.theqtcompany.settings.bluetooth"));
qmlRegisterUncreatableType<BtDeviceItem>(uri, 1, 0, "BtDeviceItem", "Cannot be instantiated directly.");
-
- }
-
- void initializeEngine(QQmlEngine * engine, const char * uri)
- {
- Q_ASSERT(QLatin1String(uri) == QLatin1String("com.theqtcompany.settings.bluetooth"));
- BluetoothDevice *device = new BluetoothDevice(engine);
- engine->rootContext()->setContextProperty("BtDevice", device);
+ qmlRegisterSingletonType<BluetoothDevice>(uri, 1, 0, "BtDevice", &instance<BluetoothDevice>);
}
};