4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <QDeclarativeItem>
32 class QtCamGraphicsViewfinder;
33 class DeclarativeQtCameraNotifications;
34 class NotificationsContainer;
45 class FlickerReduction;
53 class Camera : public QDeclarativeItem {
56 Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
57 Q_PROPERTY(QVariant deviceId READ deviceId NOTIFY deviceIdChanged);
58 Q_PROPERTY(CameraMode mode READ mode NOTIFY modeChanged);
59 Q_PROPERTY(bool idle READ isIdle NOTIFY idleStateChanged);
60 Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
61 Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
62 Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
63 Q_PROPERTY(DeclarativeQtCameraNotifications *notifications READ notifications WRITE setNotifications NOTIFY notificationsChanged);
65 Q_PROPERTY(QRectF renderArea READ renderArea NOTIFY renderAreaChanged);
66 Q_PROPERTY(QSizeF videoResolution READ videoResolution NOTIFY videoResolutionChanged);
68 Q_PROPERTY(Zoom *zoom READ zoom NOTIFY zoomChanged);
69 Q_PROPERTY(Flash *flash READ flash NOTIFY flashChanged);
70 Q_PROPERTY(Scene *scene READ scene NOTIFY sceneChanged);
71 Q_PROPERTY(EvComp *evComp READ evComp NOTIFY evCompChanged);
72 Q_PROPERTY(WhiteBalance *whiteBalance READ whiteBalance NOTIFY whiteBalanceChanged);
73 Q_PROPERTY(ColorTone *colorTone READ colorTone NOTIFY colorToneChanged);
74 Q_PROPERTY(Iso *iso READ iso NOTIFY isoChanged);
75 Q_PROPERTY(Exposure *exposure READ exposure NOTIFY exposureChanged);
76 Q_PROPERTY(Aperture *aperture READ aperture NOTIFY apertureChanged);
77 Q_PROPERTY(NoiseReduction *noiseReduction READ noiseReduction NOTIFY noiseReductionChanged);
78 Q_PROPERTY(FlickerReduction *flickerReduction READ flickerReduction NOTIFY flickerReductionChanged);
79 Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
80 Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
81 Q_PROPERTY(Roi *roi READ roi NOTIFY roiChanged);
83 Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
84 Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
86 Q_PROPERTY(bool renderingEnabled READ isRenderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged);
87 // TODO: We need a setter here too.
88 Q_PROPERTY(CameraConfig *cameraConfig READ cameraConfig CONSTANT);
99 Camera(QDeclarativeItem *parent = 0);
102 virtual void componentComplete();
104 int deviceCount() const;
105 Q_INVOKABLE QString deviceName(int index) const;
106 Q_INVOKABLE QVariant deviceId(int index) const;
108 Q_INVOKABLE bool reset(const QVariant& deviceId, const CameraMode& mode);
110 QVariant deviceId() const;
114 QtCamDevice *device() const;
116 Q_INVOKABLE bool start();
117 Q_INVOKABLE bool stop(bool force = false);
122 QString imageSuffix() const;
123 QString videoSuffix() const;
125 DeclarativeQtCameraNotifications *notifications() const;
126 void setNotifications(DeclarativeQtCameraNotifications *notifications);
129 Flash *flash() const;
130 Scene *scene() const;
131 EvComp *evComp() const;
132 WhiteBalance *whiteBalance() const;
133 ColorTone *colorTone() const;
135 Exposure *exposure() const;
136 Aperture *aperture() const;
137 NoiseReduction *noiseReduction() const;
138 FlickerReduction *flickerReduction() const;
139 Focus *focus() const;
140 AutoFocus *autoFocus() const;
143 VideoMute *videoMute() const;
144 VideoTorch *videoTorch() const;
146 QRectF renderArea() const;
147 QSizeF videoResolution() const;
149 bool isRenderingEnabled() const;
150 void setRenderingEnabled(bool enabled);
152 CameraConfig *cameraConfig() const;
155 void deviceCountChanged();
156 void deviceIdChanged();
157 void deviceChanged();
159 void idleStateChanged();
160 void runningStateChanged();
161 void error(const QString& message, int code, const QString& debug);
162 void notificationsChanged();
163 void renderAreaChanged();
164 void videoResolutionChanged();
169 void evCompChanged();
170 void whiteBalanceChanged();
171 void colorToneChanged();
173 void exposureChanged();
174 void apertureChanged();
175 void noiseReductionChanged();
176 void flickerReductionChanged();
178 void autoFocusChanged();
181 void videoMuteChanged();
182 void videoTorchChanged();
183 void renderingEnabledChanged();
185 void cameraConfigChanged();
188 void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
192 bool setDeviceId(const QVariant& deviceId);
193 bool setMode(const CameraMode& mode);
195 void resetCapabilities();
200 QtCamGraphicsViewfinder *m_vf;
202 NotificationsContainer *m_notifications;
208 WhiteBalance *m_whiteBalance;
209 ColorTone *m_colorTone;
211 Exposure *m_exposure;
212 Aperture *m_aperture;
213 NoiseReduction *m_noiseReduction;
214 FlickerReduction *m_flickerReduction;
216 AutoFocus *m_autoFocus;
219 VideoMute *m_videoMute;
220 VideoTorch *m_videoTorch;
221 CameraConfig *m_config;
224 #endif /* CAMERA_H */