Added classes for Notifications (Sound playback use case)
[harmattan/cameraplus] / imports / 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
36 class Camera : public QDeclarativeItem {
37   Q_OBJECT
38
39   Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
40   Q_PROPERTY(QVariant deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged);
41   Q_PROPERTY(CameraMode mode READ mode WRITE setMode NOTIFY modeChanged);
42   Q_PROPERTY(bool idle READ isIdle NOTIFY idleStateChanged);
43   Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
44   Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
45   Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
46   Q_PROPERTY(Notifications *notifications READ notifications WRITE setNotifications NOTIFY notificationsChanged);
47
48   Q_ENUMS(CameraMode);
49
50 public:
51   typedef enum {
52     ImageMode,
53     VideoMode
54   } CameraMode;
55
56   Camera(QDeclarativeItem *parent = 0);
57   ~Camera();
58
59   virtual void componentComplete();
60
61   int deviceCount() const;
62   Q_INVOKABLE QString deviceName(int index) const;
63   Q_INVOKABLE QVariant deviceId(int index) const;
64
65   void setDeviceId(const QVariant& id);
66   QVariant deviceId() const;
67
68   void setMode(const CameraMode& mode);
69   CameraMode mode();
70
71   QtCamDevice *device() const;
72
73   Q_INVOKABLE bool start();
74   Q_INVOKABLE bool stop();
75
76   bool isIdle();
77   bool isRunning();
78
79   QString imageSuffix() const;
80   QString videoSuffix() const;
81
82   Notifications *notifications() const;
83   void setNotifications(Notifications *notifications);
84
85 signals:
86   void deviceCountChanged();
87   void deviceIdChanged();
88   void deviceChanged();
89   void modeChanged();
90   void idleStateChanged();
91   void runningStateChanged();
92   void error(const QString& message, int code, const QString& debug);
93   void notificationsChanged();
94
95 protected:
96   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
97
98 private:
99   void applyMode();
100
101   QtCamera *m_cam;
102   QtCamDevice *m_dev;
103   QVariant m_id;
104   QtCamGraphicsViewfinder *m_vf;
105   CameraMode m_mode;
106   NotificationsContainer *m_notifications;
107 };
108
109 #endif /* CAMERA_H */