Bind checked property to the corresponding setting value for CameraTextSwitch
[harmattan/cameraplus] / declarative / plugin.cpp
1 /*!
2  * This file is part of CameraPlus.
3  *
4  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #include "plugin.h"
22 #include "imagemode.h"
23 #include "videomode.h"
24 #include "camera.h"
25 #include "previewprovider.h"
26 #include "zoom.h"
27 #include "flash.h"
28 #include "scene.h"
29 #include "evcomp.h"
30 #include "videotorch.h"
31 #include "whitebalance.h"
32 #include "colortone.h"
33 #include "exposure.h"
34 #include "aperture.h"
35 #include "iso.h"
36 #include "noisereduction.h"
37 #include "flickerreduction.h"
38 #include "focus.h"
39 #include "autofocus.h"
40 #include "roi.h"
41 #include "videomute.h"
42 #include "metadata.h"
43 #include "imagesettings.h"
44 #include "imageresolutionmodel.h"
45 #include "videosettings.h"
46 #include "videoresolutionmodel.h"
47 #include "sounds.h"
48 #include "cameraconfig.h"
49 #include "videoplayer.h"
50 #include "viewfinder.h"
51 #include "capability.h"
52 #include "imageresolution.h"
53 #include "videoresolution.h"
54 #include "quirks.h"
55 #if defined(QT4)
56 #include <QDeclarativeEngine>
57 #elif defined(QT5)
58 #include <QQmlEngine>
59 #endif
60
61 #define MAJOR 1
62 #define MINOR 0
63
64 Plugin::Plugin(QObject *parent) :
65 #if defined(QT4)
66   QDeclarativeExtensionPlugin(parent) {
67 #elif defined(QT5)
68   QQmlExtensionPlugin(parent) {
69 #endif
70
71 }
72
73 Plugin::~Plugin() {
74
75 }
76
77 #if defined(QT4)
78 void Plugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) {
79 #elif defined(QT5)
80 void Plugin::initializeEngine(QQmlEngine *engine, const char *uri) {
81 #endif
82   Q_UNUSED(uri);
83
84   engine->addImageProvider("preview", new PreviewProvider);
85 }
86
87 void Plugin::registerTypes(const char *uri) {
88   Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCamera"));
89
90   qmlRegisterType<Camera>(uri, MAJOR, MINOR, "Camera");
91   qmlRegisterType<ImageMode>(uri, MAJOR, MINOR, "ImageMode");
92   qmlRegisterType<VideoMode>(uri, MAJOR, MINOR, "VideoMode");
93
94   qmlRegisterUncreatableType<Zoom>(uri, MAJOR, MINOR, "Zoom", QObject::tr("Cannot create separate instance of Zoom"));
95   qmlRegisterUncreatableType<Flash>(uri, MAJOR, MINOR, "Flash", QObject::tr("Cannot create separate instance of Flash"));
96   qmlRegisterUncreatableType<Scene>(uri, MAJOR, MINOR, "Scene", QObject::tr("Cannot create separate instance of Scene"));
97   qmlRegisterUncreatableType<EvComp>(uri, MAJOR, MINOR, "EvComp", QObject::tr("Cannot create separate instance of EvComp"));
98   qmlRegisterUncreatableType<WhiteBalance>(uri, MAJOR, MINOR, "WhiteBalance", QObject::tr("Cannot create separate instance of WhiteBalance"));
99   qmlRegisterUncreatableType<ColorTone>(uri, MAJOR, MINOR, "ColorTone", QObject::tr("Cannot create separate instance of ColorTone"));
100   qmlRegisterUncreatableType<Exposure>(uri, MAJOR, MINOR, "Exposure", QObject::tr("Cannot create separate instance of Exposure"));
101   qmlRegisterUncreatableType<Aperture>(uri, MAJOR, MINOR, "Aperture", QObject::tr("Cannot create separate instance of Aperture"));
102   qmlRegisterUncreatableType<Iso>(uri, MAJOR, MINOR, "Iso", QObject::tr("Cannot create separate instance of Iso"));
103   qmlRegisterUncreatableType<NoiseReduction>(uri, MAJOR, MINOR, "NoiseReduction", QObject::tr("Cannot create separate instance of NoiseReduction"));
104   qmlRegisterUncreatableType<FlickerReduction>(uri, MAJOR, MINOR, "FlickerReduction", QObject::tr("Cannot create separate instance of FlickerReduction"));
105   qmlRegisterUncreatableType<Focus>(uri, MAJOR, MINOR, "Focus", QObject::tr("Cannot create separate instance of Focus"));
106   qmlRegisterUncreatableType<AutoFocus>(uri, MAJOR, MINOR, "AutoFocus", QObject::tr("Cannot create separate instance of AutoFocus"));
107   qmlRegisterUncreatableType<Roi>(uri, MAJOR, MINOR, "Roi", QObject::tr("Cannot create separate instance of Roi"));
108
109   qmlRegisterUncreatableType<VideoMute>(uri, MAJOR, MINOR, "VideoMute", QObject::tr("Cannot create separate instance of VideoMute"));
110   qmlRegisterUncreatableType<VideoTorch>(uri, MAJOR, MINOR, "VideoTorch", QObject::tr("Cannot create separate instance of VideoTorch"));
111
112   qmlRegisterType<MetaData>(uri, MAJOR, MINOR, "MetaData");
113   qmlRegisterType<ImageSettings>(uri, MAJOR, MINOR, "ImageSettings");
114   qmlRegisterType<VideoSettings>(uri, MAJOR, MINOR, "VideoSettings");
115   qmlRegisterType<Sounds>(uri, MAJOR, MINOR, "Sounds");
116
117   qmlRegisterUncreatableType<ImageResolutionModel>(uri, MAJOR, MINOR, "ImageResolutionModel",
118                           "ImageResolutionModel can be obtained from ImageSettings");
119   qmlRegisterUncreatableType<VideoResolutionModel>(uri, MAJOR, MINOR, "VideoResolutionModel",
120                           "VideoResolutionModel can be obtained from VideoSettings");
121
122   qmlRegisterType<Mode>();
123   qmlRegisterType<CameraConfig>(uri, MAJOR, MINOR, "CameraConfig");
124
125   qmlRegisterType<VideoPlayer>("QtCameraExtras", MAJOR, MINOR, "VideoPlayer");
126   qmlRegisterType<Viewfinder>(uri, MAJOR, MINOR, "Viewfinder");
127   qmlRegisterType<Capability>();
128
129   qmlRegisterType<ImageResolution>(uri, MAJOR, MINOR, "ImageResolution");
130   qmlRegisterType<VideoResolution>(uri, MAJOR, MINOR, "VideoResolution");
131
132   qmlRegisterUncreatableType<Quirks>(uri, MAJOR, MINOR, "Quirks",
133                           "Quirks can be obtained from Camera");
134 }
135
136 #if defined(QT4)
137 Q_EXPORT_PLUGIN2(declarativeqtcamera, Plugin);
138 #endif