2 * This file is part of CameraPlus.
4 * Copyright (C) 2012-2013 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"
26 NotificationsContainer::NotificationsContainer(QObject *parent) :
27 QObject(parent), m_dev(0), m_sounds(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 Sounds *NotificationsContainer::sounds() const {
69 bool NotificationsContainer::setSounds(Sounds *sounds) {
70 QMutexLocker lock(&m_mutex);
72 if (m_sounds != sounds) {
80 void NotificationsContainer::imageCaptureStarted() {
81 QMutexLocker l(&m_mutex);
84 m_sounds->playImageCaptureStartedSound();
88 void NotificationsContainer::imageCaptureEnded() {
89 QMutexLocker l(&m_mutex);
92 m_sounds->playImageCaptureEndedSound();
96 void NotificationsContainer::videoRecordingStarted() {
97 QMutexLocker l(&m_mutex);
100 m_sounds->playVideoRecordingStartedSound();
104 void NotificationsContainer::videoRecordingEnded() {
105 QMutexLocker l(&m_mutex);
108 m_sounds->playVideoRecordingEndedSound();
112 void NotificationsContainer::autoFocusAcquired() {
113 QMutexLocker l(&m_mutex);
116 m_sounds->playAutoFocusAcquiredSound();