72051e5e393c91cc824295a3a9cf2124d782f817
[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_ENUMS(CameraMode);
22
23 public:
24   typedef enum {
25     ImageMode,
26     VideoMode
27   } CameraMode;
28
29   Camera(QDeclarativeItem *parent = 0);
30   ~Camera();
31
32   virtual void componentComplete();
33
34   int deviceCount() const;
35   Q_INVOKABLE QString deviceName(int index) const;
36   Q_INVOKABLE QVariant deviceId(int index) const;
37
38   void setDeviceId(const QVariant& id);
39   QVariant deviceId() const;
40
41   void setMode(const CameraMode& mode);
42   CameraMode mode();
43
44   QtCamDevice *device() const;
45
46   Q_INVOKABLE bool start();
47
48   bool isIdle();
49   bool isRunning();
50
51 public slots:
52   void stop();
53
54 signals:
55   void deviceCountChanged();
56   void deviceIdChanged();
57   void deviceChanged();
58   void modeChanged();
59   void idleStateChanged();
60   void runningStateChanged();
61
62 protected:
63   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
64
65 private:
66   void applyMode();
67
68   QtCamera *m_cam;
69   QtCamDevice *m_dev;
70   QVariant m_id;
71   QtCamGraphicsViewfinder *m_vf;
72   CameraMode m_mode;
73 };
74
75 #endif /* CAMERA_H */