Turn stuff under declarative into a real QML extension
authorMohammed Sameer <msameer@foolab.org>
Mon, 4 Feb 2013 00:59:26 +0000 (02:59 +0200)
committerMohammed Sameer <msameer@foolab.org>
Mon, 4 Feb 2013 00:59:26 +0000 (02:59 +0200)
declarative/declarative.pro
declarative/plugin.cpp
declarative/plugin.h
src/main.cpp
src/src.pro

index aaaa716..3be0a33 100644 (file)
@@ -8,6 +8,8 @@ CONFIG += link_pkgconfig
 PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-tag-0.10 \
             gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 libcanberra
 
 PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-tag-0.10 \
             gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 libcanberra
 
+LIBS += -L../lib/ -lqtcamera
+
 QT += declarative dbus
 
 HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
 QT += declarative dbus
 
 HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
index 5000a63..c2e9966 100644 (file)
 #define MAJOR 1
 #define MINOR 0
 
 #define MAJOR 1
 #define MINOR 0
 
-void Plugin::registerTypes(QDeclarativeEngine *engine) {
-  qmlRegisterType<Camera>(URI, MAJOR, MINOR, "Camera");
-  qmlRegisterType<ImageMode>(URI, MAJOR, MINOR, "ImageMode");
-  qmlRegisterType<VideoMode>(URI, MAJOR, MINOR, "VideoMode");
-
-  qmlRegisterUncreatableType<Zoom>(URI, MAJOR, MINOR, "Zoom", QObject::tr("Cannot create separate instance of Zoom"));
-  qmlRegisterUncreatableType<Flash>(URI, MAJOR, MINOR, "Flash", QObject::tr("Cannot create separate instance of Flash"));
-  qmlRegisterUncreatableType<Scene>(URI, MAJOR, MINOR, "Scene", QObject::tr("Cannot create separate instance of Scene"));
-  qmlRegisterUncreatableType<EvComp>(URI, MAJOR, MINOR, "EvComp", QObject::tr("Cannot create separate instance of EvComp"));
-  qmlRegisterUncreatableType<WhiteBalance>(URI, MAJOR, MINOR, "WhiteBalance", QObject::tr("Cannot create separate instance of WhiteBalance"));
-  qmlRegisterUncreatableType<ColorTone>(URI, MAJOR, MINOR, "ColorTone", QObject::tr("Cannot create separate instance of ColorTone"));
-  qmlRegisterUncreatableType<Exposure>(URI, MAJOR, MINOR, "Exposure", QObject::tr("Cannot create separate instance of Exposure"));
-  qmlRegisterUncreatableType<Aperture>(URI, MAJOR, MINOR, "Aperture", QObject::tr("Cannot create separate instance of Iso"));
-  qmlRegisterUncreatableType<Iso>(URI, MAJOR, MINOR, "Iso", QObject::tr("Cannot create separate instance of Iso"));
-  qmlRegisterUncreatableType<NoiseReduction>(URI, MAJOR, MINOR, "NoiseReduction", QObject::tr("Cannot create separate instance of NoiseReduction"));
-  qmlRegisterUncreatableType<FlickerReduction>(URI, MAJOR, MINOR, "FlickerReduction", QObject::tr("Cannot create separate instance of FlickerReduction"));
-  qmlRegisterUncreatableType<Focus>(URI, MAJOR, MINOR, "Focus", QObject::tr("Cannot create separate instance of Focus"));
-  qmlRegisterUncreatableType<AutoFocus>(URI, MAJOR, MINOR, "AutoFocus", QObject::tr("Cannot create separate instance of AutoFocus"));
-  qmlRegisterUncreatableType<Roi>(URI, MAJOR, MINOR, "Roi", QObject::tr("Cannot create separate instance of Roi"));
-
-  qmlRegisterUncreatableType<VideoMute>(URI, MAJOR, MINOR, "VideoMute", QObject::tr("Cannot create separate instance of VideoMute"));
-  qmlRegisterUncreatableType<VideoTorch>(URI, MAJOR, MINOR, "VideoTorch", QObject::tr("Cannot create separate instance of VideoTorch"));
-
-  qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
-  qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
-  qmlRegisterType<VideoSettings>(URI, MAJOR, MINOR, "VideoSettings");
-  qmlRegisterType<Sounds>(URI, MAJOR, MINOR, "Sounds");
+Plugin::Plugin(QObject *parent) :
+  QDeclarativeExtensionPlugin(parent) {
+
+}
+
+Plugin::~Plugin() {
+
+}
+
+void Plugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) {
+  Q_UNUSED(uri);
+
+  engine->addImageProvider("preview", new PreviewProvider);
+}
+
+void Plugin::registerTypes(const char *uri) {
+  qmlRegisterType<Camera>(uri, MAJOR, MINOR, "Camera");
+  qmlRegisterType<ImageMode>(uri, MAJOR, MINOR, "ImageMode");
+  qmlRegisterType<VideoMode>(uri, MAJOR, MINOR, "VideoMode");
+
+  qmlRegisterUncreatableType<Zoom>(uri, MAJOR, MINOR, "Zoom", QObject::tr("Cannot create separate instance of Zoom"));
+  qmlRegisterUncreatableType<Flash>(uri, MAJOR, MINOR, "Flash", QObject::tr("Cannot create separate instance of Flash"));
+  qmlRegisterUncreatableType<Scene>(uri, MAJOR, MINOR, "Scene", QObject::tr("Cannot create separate instance of Scene"));
+  qmlRegisterUncreatableType<EvComp>(uri, MAJOR, MINOR, "EvComp", QObject::tr("Cannot create separate instance of EvComp"));
+  qmlRegisterUncreatableType<WhiteBalance>(uri, MAJOR, MINOR, "WhiteBalance", QObject::tr("Cannot create separate instance of WhiteBalance"));
+  qmlRegisterUncreatableType<ColorTone>(uri, MAJOR, MINOR, "ColorTone", QObject::tr("Cannot create separate instance of ColorTone"));
+  qmlRegisterUncreatableType<Exposure>(uri, MAJOR, MINOR, "Exposure", QObject::tr("Cannot create separate instance of Exposure"));
+  qmlRegisterUncreatableType<Aperture>(uri, MAJOR, MINOR, "Aperture", QObject::tr("Cannot create separate instance of Iso"));
+  qmlRegisterUncreatableType<Iso>(uri, MAJOR, MINOR, "Iso", QObject::tr("Cannot create separate instance of Iso"));
+  qmlRegisterUncreatableType<NoiseReduction>(uri, MAJOR, MINOR, "NoiseReduction", QObject::tr("Cannot create separate instance of NoiseReduction"));
+  qmlRegisterUncreatableType<FlickerReduction>(uri, MAJOR, MINOR, "FlickerReduction", QObject::tr("Cannot create separate instance of FlickerReduction"));
+  qmlRegisterUncreatableType<Focus>(uri, MAJOR, MINOR, "Focus", QObject::tr("Cannot create separate instance of Focus"));
+  qmlRegisterUncreatableType<AutoFocus>(uri, MAJOR, MINOR, "AutoFocus", QObject::tr("Cannot create separate instance of AutoFocus"));
+  qmlRegisterUncreatableType<Roi>(uri, MAJOR, MINOR, "Roi", QObject::tr("Cannot create separate instance of Roi"));
+
+  qmlRegisterUncreatableType<VideoMute>(uri, MAJOR, MINOR, "VideoMute", QObject::tr("Cannot create separate instance of VideoMute"));
+  qmlRegisterUncreatableType<VideoTorch>(uri, MAJOR, MINOR, "VideoTorch", QObject::tr("Cannot create separate instance of VideoTorch"));
+
+  qmlRegisterType<MetaData>(uri, MAJOR, MINOR, "MetaData");
+  qmlRegisterType<ImageSettings>(uri, MAJOR, MINOR, "ImageSettings");
+  qmlRegisterType<VideoSettings>(uri, MAJOR, MINOR, "VideoSettings");
+  qmlRegisterType<Sounds>(uri, MAJOR, MINOR, "Sounds");
   qmlRegisterInterface<Notifications>("Notifications");
 
   qmlRegisterInterface<Notifications>("Notifications");
 
-  qmlRegisterUncreatableType<ImageResolutionModel>(URI, MAJOR, MINOR, "ImageResolutionModel",
+  qmlRegisterUncreatableType<ImageResolutionModel>(uri, MAJOR, MINOR, "ImageResolutionModel",
                          "ImageResolutionModel can be obtained from ImageSettings");
                          "ImageResolutionModel can be obtained from ImageSettings");
-  qmlRegisterUncreatableType<VideoResolutionModel>(URI, MAJOR, MINOR, "VideoResolutionModel",
+  qmlRegisterUncreatableType<VideoResolutionModel>(uri, MAJOR, MINOR, "VideoResolutionModel",
                          "VideoResolutionModel can be obtained from VideoSettings");
 
   qmlRegisterType<Mode>();
                          "VideoResolutionModel can be obtained from VideoSettings");
 
   qmlRegisterType<Mode>();
-
-  engine->addImageProvider("preview", new PreviewProvider);
 }
 }
+
+Q_EXPORT_PLUGIN2(declarativeqtcamera, Plugin);
index dc14252..013ab67 100644 (file)
 #ifndef PLUGIN_H
 #define PLUGIN_H
 
 #ifndef PLUGIN_H
 #define PLUGIN_H
 
-class QDeclarativeEngine;
+#include <QDeclarativeExtensionPlugin>
+
+class Plugin : public QDeclarativeExtensionPlugin {
+  Q_OBJECT
 
 
-class Plugin {
 public:
 public:
-  static void registerTypes(QDeclarativeEngine *engine);
+  Plugin(QObject *parent = 0);
+  ~Plugin();
+
+  void initializeEngine(QDeclarativeEngine *engine, const char *uri);
+  void registerTypes(const char *uri);
 };
 
 #endif /* PLUGIN_H */
 };
 
 #endif /* PLUGIN_H */
index 0918c8e..178c116 100644 (file)
@@ -26,8 +26,6 @@
 #include <QGLWidget>
 #include <QuillFile>
 
 #include <QGLWidget>
 #include <QuillFile>
 
-#include "declarative/plugin.h"
-
 #include "settings.h"
 #include "filenaming.h"
 #include "quillitem.h"
 #include "settings.h"
 #include "filenaming.h"
 #include "quillitem.h"
@@ -85,7 +83,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) {
   view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
   view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
 
   view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
   view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
 
-  Plugin::registerTypes(view.engine());
   qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
   qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
   qmlRegisterType<QuillItem>("CameraPlus", 1, 0, "QuillItem");
   qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
   qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
   qmlRegisterType<QuillItem>("CameraPlus", 1, 0, "QuillItem");
index 810090b..1cb76f8 100644 (file)
@@ -13,8 +13,6 @@ MOBILITY += location systeminfo
 PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-tag-0.10 \
             gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 quill qmsystem2 libresourceqt1
 
 PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-tag-0.10 \
             gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 quill qmsystem2 libresourceqt1
 
-LIBS +=  -L../declarative/ -ldeclarativeqtcamera -L../lib/ -lqtcamera
-
 SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp displaystate.cpp fsmonitor.cpp \
            cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
            trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \
 SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp displaystate.cpp fsmonitor.cpp \
            cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
            trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \