From 8d6acd119da9d258e356ee6b960e2f274c203602 Mon Sep 17 00:00:00 2001 From: Mohammed Sameer Date: Mon, 4 Feb 2013 02:59:26 +0200 Subject: [PATCH] Turn stuff under declarative into a real QML extension --- declarative/declarative.pro | 2 + declarative/plugin.cpp | 77 ++++++++++++++++++++++--------------- declarative/plugin.h | 12 ++++-- src/main.cpp | 3 -- src/src.pro | 2 - 5 files changed, 57 insertions(+), 39 deletions(-) diff --git a/declarative/declarative.pro b/declarative/declarative.pro index aaaa716..3be0a33 100644 --- a/declarative/declarative.pro +++ b/declarative/declarative.pro @@ -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 +LIBS += -L../lib/ -lqtcamera + QT += declarative dbus HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \ diff --git a/declarative/plugin.cpp b/declarative/plugin.cpp index 5000a63..c2e9966 100644 --- a/declarative/plugin.cpp +++ b/declarative/plugin.cpp @@ -53,41 +53,56 @@ #define MAJOR 1 #define MINOR 0 -void Plugin::registerTypes(QDeclarativeEngine *engine) { - qmlRegisterType(URI, MAJOR, MINOR, "Camera"); - qmlRegisterType(URI, MAJOR, MINOR, "ImageMode"); - qmlRegisterType(URI, MAJOR, MINOR, "VideoMode"); - - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Zoom", QObject::tr("Cannot create separate instance of Zoom")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Flash", QObject::tr("Cannot create separate instance of Flash")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Scene", QObject::tr("Cannot create separate instance of Scene")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "EvComp", QObject::tr("Cannot create separate instance of EvComp")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "WhiteBalance", QObject::tr("Cannot create separate instance of WhiteBalance")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "ColorTone", QObject::tr("Cannot create separate instance of ColorTone")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Exposure", QObject::tr("Cannot create separate instance of Exposure")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Aperture", QObject::tr("Cannot create separate instance of Iso")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Iso", QObject::tr("Cannot create separate instance of Iso")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "NoiseReduction", QObject::tr("Cannot create separate instance of NoiseReduction")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "FlickerReduction", QObject::tr("Cannot create separate instance of FlickerReduction")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Focus", QObject::tr("Cannot create separate instance of Focus")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "AutoFocus", QObject::tr("Cannot create separate instance of AutoFocus")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "Roi", QObject::tr("Cannot create separate instance of Roi")); - - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "VideoMute", QObject::tr("Cannot create separate instance of VideoMute")); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "VideoTorch", QObject::tr("Cannot create separate instance of VideoTorch")); - - qmlRegisterType(URI, MAJOR, MINOR, "MetaData"); - qmlRegisterType(URI, MAJOR, MINOR, "ImageSettings"); - qmlRegisterType(URI, MAJOR, MINOR, "VideoSettings"); - qmlRegisterType(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(uri, MAJOR, MINOR, "Camera"); + qmlRegisterType(uri, MAJOR, MINOR, "ImageMode"); + qmlRegisterType(uri, MAJOR, MINOR, "VideoMode"); + + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Zoom", QObject::tr("Cannot create separate instance of Zoom")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Flash", QObject::tr("Cannot create separate instance of Flash")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Scene", QObject::tr("Cannot create separate instance of Scene")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "EvComp", QObject::tr("Cannot create separate instance of EvComp")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "WhiteBalance", QObject::tr("Cannot create separate instance of WhiteBalance")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "ColorTone", QObject::tr("Cannot create separate instance of ColorTone")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Exposure", QObject::tr("Cannot create separate instance of Exposure")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Aperture", QObject::tr("Cannot create separate instance of Iso")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Iso", QObject::tr("Cannot create separate instance of Iso")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "NoiseReduction", QObject::tr("Cannot create separate instance of NoiseReduction")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "FlickerReduction", QObject::tr("Cannot create separate instance of FlickerReduction")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Focus", QObject::tr("Cannot create separate instance of Focus")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "AutoFocus", QObject::tr("Cannot create separate instance of AutoFocus")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "Roi", QObject::tr("Cannot create separate instance of Roi")); + + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "VideoMute", QObject::tr("Cannot create separate instance of VideoMute")); + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "VideoTorch", QObject::tr("Cannot create separate instance of VideoTorch")); + + qmlRegisterType(uri, MAJOR, MINOR, "MetaData"); + qmlRegisterType(uri, MAJOR, MINOR, "ImageSettings"); + qmlRegisterType(uri, MAJOR, MINOR, "VideoSettings"); + qmlRegisterType(uri, MAJOR, MINOR, "Sounds"); qmlRegisterInterface("Notifications"); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "ImageResolutionModel", + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "ImageResolutionModel", "ImageResolutionModel can be obtained from ImageSettings"); - qmlRegisterUncreatableType(URI, MAJOR, MINOR, "VideoResolutionModel", + qmlRegisterUncreatableType(uri, MAJOR, MINOR, "VideoResolutionModel", "VideoResolutionModel can be obtained from VideoSettings"); qmlRegisterType(); - - engine->addImageProvider("preview", new PreviewProvider); } + +Q_EXPORT_PLUGIN2(declarativeqtcamera, Plugin); diff --git a/declarative/plugin.h b/declarative/plugin.h index dc14252..013ab67 100644 --- a/declarative/plugin.h +++ b/declarative/plugin.h @@ -23,11 +23,17 @@ #ifndef PLUGIN_H #define PLUGIN_H -class QDeclarativeEngine; +#include + +class Plugin : public QDeclarativeExtensionPlugin { + Q_OBJECT -class Plugin { 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 */ diff --git a/src/main.cpp b/src/main.cpp index 0918c8e..178c116 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,8 +26,6 @@ #include #include -#include "declarative/plugin.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); - Plugin::registerTypes(view.engine()); qmlRegisterType("CameraPlus", 1, 0, "Settings"); qmlRegisterType("CameraPlus", 1, 0, "FileNaming"); qmlRegisterType("CameraPlus", 1, 0, "QuillItem"); diff --git a/src/src.pro b/src/src.pro index 810090b..1cb76f8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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 -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 \ -- 2.25.1