Added resource policy support (Still needs more testing) and refactored the pipeline...
[harmattan/cameraplus] / imports / camera.h
1 // -*- c++ -*-
2
3 #ifndef CAMERA_H
4 #define CAMERA_H
5
6 #include <QDeclarativeItem>
7 #include <QVariant>
8
9 class QtCamera;
10 class QtCamDevice;
11 class QtCamGraphicsViewfinder;
12
13 class Camera : public QDeclarativeItem {
14   Q_OBJECT
15
16   Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
17   Q_PROPERTY(QVariant deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged);
18   Q_PROPERTY(CameraMode mode READ mode WRITE setMode NOTIFY modeChanged);
19   Q_PROPERTY(bool idle READ isIdle NOTIFY idleStateChanged);
20   Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
21   Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
22   Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
23   Q_ENUMS(CameraMode);
24
25 public:
26   typedef enum {
27     ImageMode,
28     VideoMode
29   } CameraMode;
30
31   Camera(QDeclarativeItem *parent = 0);
32   ~Camera();
33
34   virtual void componentComplete();
35
36   int deviceCount() const;
37   Q_INVOKABLE QString deviceName(int index) const;
38   Q_INVOKABLE QVariant deviceId(int index) const;
39
40   void setDeviceId(const QVariant& id);
41   QVariant deviceId() const;
42
43   void setMode(const CameraMode& mode);
44   CameraMode mode();
45
46   QtCamDevice *device() const;
47
48   Q_INVOKABLE bool start();
49   Q_INVOKABLE bool stop();
50
51   bool isIdle();
52   bool isRunning();
53
54   QString imageSuffix() const;
55   QString videoSuffix() const;
56
57 signals:
58   void deviceCountChanged();
59   void deviceIdChanged();
60   void deviceChanged();
61   void modeChanged();
62   void idleStateChanged();
63   void runningStateChanged();
64
65 protected:
66   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
67
68 private:
69   void applyMode();
70
71   QtCamera *m_cam;
72   QtCamDevice *m_dev;
73   QVariant m_id;
74   QtCamGraphicsViewfinder *m_vf;
75   CameraMode m_mode;
76 };
77
78 #endif /* CAMERA_H */