Autohide video player toolbar after 3 seconds of inactivity
[harmattan/cameraplus] / declarative / camera.h
1 // -*- c++ -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #ifndef CAMERA_H
24 #define CAMERA_H
25
26 #include <QDeclarativeItem>
27 #include <QVariant>
28 #include <QPointer>
29
30 class QtCamera;
31 class QtCamDevice;
32 class QtCamGraphicsViewfinder;
33 class Notifications;
34 class NotificationsContainer;
35 class Zoom;
36 class Flash;
37 class Scene;
38 class EvComp;
39 class WhiteBalance;
40 class ColorTone;
41 class Iso;
42 class Exposure;
43 class Aperture;
44 class NoiseReduction;
45 class FlickerReduction;
46 class Focus;
47 class AutoFocus;
48 class VideoMute;
49 class VideoTorch;
50
51 class Camera : public QDeclarativeItem {
52   Q_OBJECT
53
54   Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
55   Q_PROPERTY(QVariant deviceId READ deviceId NOTIFY deviceIdChanged);
56   Q_PROPERTY(CameraMode mode READ mode NOTIFY modeChanged);
57   Q_PROPERTY(bool idle READ isIdle NOTIFY idleStateChanged);
58   Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
59   Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
60   Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
61   Q_PROPERTY(Notifications *notifications READ notifications WRITE setNotifications NOTIFY notificationsChanged);
62
63   Q_PROPERTY(QRectF renderArea READ renderArea NOTIFY renderAreaChanged);
64   Q_PROPERTY(QSizeF videoResolution READ videoResolution NOTIFY videoResolutionChanged);
65
66   Q_PROPERTY(Zoom *zoom READ zoom NOTIFY zoomChanged);
67   Q_PROPERTY(Flash *flash READ flash NOTIFY flashChanged);
68   Q_PROPERTY(Scene *scene READ scene NOTIFY sceneChanged);
69   Q_PROPERTY(EvComp *evComp READ evComp NOTIFY evCompChanged);
70   Q_PROPERTY(WhiteBalance *whiteBalance READ whiteBalance NOTIFY whiteBalanceChanged);
71   Q_PROPERTY(ColorTone *colorTone READ colorTone NOTIFY colorToneChanged);
72   Q_PROPERTY(Iso *iso READ iso NOTIFY isoChanged);
73   Q_PROPERTY(Exposure *exposure READ exposure NOTIFY exposureChanged);
74   Q_PROPERTY(Aperture *aperture READ aperture NOTIFY apertureChanged);
75   Q_PROPERTY(NoiseReduction *noiseReduction READ noiseReduction NOTIFY noiseReductionChanged);
76   Q_PROPERTY(FlickerReduction *flickerReduction READ flickerReduction NOTIFY flickerReductionChanged);
77   Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
78   Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
79
80   Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
81   Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
82
83   Q_PROPERTY(bool renderingEnabled READ isRenderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged);
84
85   Q_ENUMS(CameraMode);
86
87 public:
88   typedef enum {
89     UnknownMode,
90     ImageMode,
91     VideoMode
92   } CameraMode;
93
94   Camera(QDeclarativeItem *parent = 0);
95   ~Camera();
96
97   virtual void componentComplete();
98
99   int deviceCount() const;
100   Q_INVOKABLE QString deviceName(int index) const;
101   Q_INVOKABLE QVariant deviceId(int index) const;
102
103   Q_INVOKABLE bool reset(const QVariant& deviceId, const CameraMode& mode);
104
105   QVariant deviceId() const;
106
107   CameraMode mode();
108
109   QtCamDevice *device() const;
110
111   Q_INVOKABLE bool start();
112   Q_INVOKABLE bool stop(bool force = false);
113
114   bool isIdle();
115   bool isRunning();
116
117   QString imageSuffix() const;
118   QString videoSuffix() const;
119
120   Notifications *notifications() const;
121   void setNotifications(Notifications *notifications);
122
123   Zoom *zoom() const;
124   Flash *flash() const;
125   Scene *scene() const;
126   EvComp *evComp() const;
127   WhiteBalance *whiteBalance() const;
128   ColorTone *colorTone() const;
129   Iso *iso() const;
130   Exposure *exposure() const;
131   Aperture *aperture() const;
132   NoiseReduction *noiseReduction() const;
133   FlickerReduction *flickerReduction() const;
134   Focus *focus() const;
135   AutoFocus *autoFocus() const;
136
137   VideoMute *videoMute() const;
138   VideoTorch *videoTorch() const;
139
140   QRectF renderArea() const;
141   QSizeF videoResolution() const;
142
143   bool isRenderingEnabled() const;
144   void setRenderingEnabled(bool enabled);
145
146 signals:
147   void deviceCountChanged();
148   void deviceIdChanged();
149   void deviceChanged();
150   void modeChanged();
151   void idleStateChanged();
152   void runningStateChanged();
153   void error(const QString& message, int code, const QString& debug);
154   void notificationsChanged();
155   void renderAreaChanged();
156   void videoResolutionChanged();
157
158   void zoomChanged();
159   void flashChanged();
160   void sceneChanged();
161   void evCompChanged();
162   void whiteBalanceChanged();
163   void colorToneChanged();
164   void isoChanged();
165   void exposureChanged();
166   void apertureChanged();
167   void noiseReductionChanged();
168   void flickerReductionChanged();
169   void focusChanged();
170   void autoFocusChanged();
171
172   void videoMuteChanged();
173   void videoTorchChanged();
174   void renderingEnabledChanged();
175
176 protected:
177   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
178
179 private:
180   bool applyMode();
181   bool setDeviceId(const QVariant& deviceId);
182   bool setMode(const CameraMode& mode);
183
184   void resetCapabilities();
185
186   QtCamera *m_cam;
187   QtCamDevice *m_dev;
188   QVariant m_id;
189   QtCamGraphicsViewfinder *m_vf;
190   CameraMode m_mode;
191   NotificationsContainer *m_notifications;
192
193   Zoom *m_zoom;
194   Flash *m_flash;
195   Scene *m_scene;
196   EvComp *m_evComp;
197   WhiteBalance *m_whiteBalance;
198   ColorTone *m_colorTone;
199   Iso *m_iso;
200   Exposure *m_exposure;
201   Aperture *m_aperture;
202   NoiseReduction *m_noiseReduction;
203   FlickerReduction *m_flickerReduction;
204   Focus *m_focus;
205   AutoFocus *m_autoFocus;
206
207   VideoMute *m_videoMute;
208   VideoTorch *m_videoTorch;
209 };
210
211 #endif /* CAMERA_H */