2 * This file is part of CameraPlus.
4 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "notificationscontainer.h"
22 #include "qtcamdevice.h"
23 #include "qtcamnotifications.h"
24 #include "declarativeqtcameranotifications.h"
26 NotificationsContainer::NotificationsContainer(QObject *parent) :
27 QObject(parent), m_dev(0), m_notifications(0) {
31 NotificationsContainer::~NotificationsContainer() {
34 QMutexLocker locker(&m_mutex);
38 void NotificationsContainer::setDevice(QtCamDevice *dev) {
40 QtCamNotifications *n = m_dev->notifications();
41 QObject::disconnect(n, SIGNAL(imageCaptureStarted()), this, SLOT(imageCaptureStarted()));
42 QObject::disconnect(n, SIGNAL(imageCaptureEnded()), this, SLOT(imageCaptureEnded()));
43 QObject::disconnect(n, SIGNAL(videoRecordingStarted()), this, SLOT(videoRecordingStarted()));
44 QObject::disconnect(n, SIGNAL(videoRecordingEnded()), this, SLOT(videoRecordingEnded()));
45 QObject::disconnect(n, SIGNAL(autoFocusAcquired()), this, SLOT(autoFocusAcquired()));
51 QtCamNotifications *n = m_dev->notifications();
52 QObject::connect(n, SIGNAL(imageCaptureStarted()),
53 this, SLOT(imageCaptureStarted()), Qt::DirectConnection);
54 QObject::connect(n, SIGNAL(imageCaptureEnded()),
55 this, SLOT(imageCaptureEnded()), Qt::DirectConnection);
56 QObject::connect(n, SIGNAL(videoRecordingStarted()),
57 this, SLOT(videoRecordingStarted()), Qt::DirectConnection);
58 QObject::connect(n, SIGNAL(videoRecordingEnded()),
59 this, SLOT(videoRecordingEnded()), Qt::DirectConnection);
60 QObject::connect(n, SIGNAL(autoFocusAcquired()),
61 this, SLOT(autoFocusAcquired()), Qt::DirectConnection);
65 DeclarativeQtCameraNotifications *NotificationsContainer::notifications() const {
66 return m_notifications;
69 bool NotificationsContainer::setNotifications(DeclarativeQtCameraNotifications *notifications) {
70 QMutexLocker lock(&m_mutex);
72 if (m_notifications != notifications) {
73 m_notifications = notifications;
80 void NotificationsContainer::imageCaptureStarted() {
81 QMutexLocker l(&m_mutex);
83 if (m_notifications) {
84 m_notifications->imageCaptureStarted();
88 void NotificationsContainer::imageCaptureEnded() {
89 QMutexLocker l(&m_mutex);
91 if (m_notifications) {
92 m_notifications->imageCaptureEnded();
96 void NotificationsContainer::videoRecordingStarted() {
97 QMutexLocker l(&m_mutex);
99 if (m_notifications) {
100 m_notifications->videoRecordingStarted();
104 void NotificationsContainer::videoRecordingEnded() {
105 QMutexLocker l(&m_mutex);
107 if (m_notifications) {
108 m_notifications->videoRecordingEnded();
112 void NotificationsContainer::autoFocusAcquired() {
113 QMutexLocker l(&m_mutex);
115 if (m_notifications) {
116 m_notifications->autoFocusAcquired();