Sounds class will handle all sound playback.
Location of audio files will be part of PlatformSettings instead of QtCamConfig
interface = com.nokia.maemo.meegotouch.ShareUiInterface
dest = com.nokia.ShareUi
method = share:share
+
+[sounds]
+imageCaptureStarted = /usr/share/sounds/ui-tones//snd_camera_shutter.wav
+imageCaptureEnded =
+videoRecordingStarted = /usr/share/sounds/ui-tones//snd_camera_video_record_start.wav
+videoRecordingEnded = /usr/share/sounds/ui-tones//snd_camera_video_record_stop.wav
+autoFocusAcquired = /usr/share/sounds/ui-tones//snd_camera_af.wav
aspectratio=16:9
resolution=720p
-
-[sounds]
-imageCaptureStarted = /usr/share/sounds/ui-tones//snd_camera_shutter.wav
-imageCaptureEnded =
-videoRecordingStarted = /usr/share/sounds/ui-tones//snd_camera_video_record_start.wav
-videoRecordingEnded = /usr/share/sounds/ui-tones//snd_camera_video_record_stop.wav
-autoFocusAcquired = /usr/share/sounds/ui-tones//snd_camera_af.wav
-
[viewfinder-filters]
elements = facetracking, motiondetect
#include "qtcamvideomode.h"
#include "qtcamgraphicsviewfinder.h"
#include "qtcamconfig.h"
-#include "declarativeqtcameranotifications.h"
+#include "sounds.h"
#include "notificationscontainer.h"
#include "sounds.h"
#include <QDeclarativeInfo>
return m_cam->config()->videoSuffix();
}
-DeclarativeQtCameraNotifications *Camera::notifications() const {
- return m_notifications->notifications();
+Sounds *Camera::sounds() const {
+ return m_notifications->sounds();
}
-
-void Camera::setNotifications(DeclarativeQtCameraNotifications *notifications) {
- if (m_notifications->setNotifications(notifications)) {
-
- if (Sounds *s = dynamic_cast<Sounds *>(notifications)) {
- s->setConfig(m_cam->config());
- s->reload();
- }
-
- emit notificationsChanged();
+void Camera::setSounds(Sounds *sounds) {
+ if (m_notifications->setSounds(sounds)) {
+ sounds->reload();
+ emit soundsChanged();
}
}
class QtCamera;
class QtCamDevice;
class QtCamGraphicsViewfinder;
-class DeclarativeQtCameraNotifications;
+class Sounds;
class NotificationsContainer;
class Zoom;
class Flash;
Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
- Q_PROPERTY(DeclarativeQtCameraNotifications *notifications READ notifications WRITE setNotifications NOTIFY notificationsChanged);
+ Q_PROPERTY(Sounds *sounds READ sounds WRITE setSounds NOTIFY soundsChanged);
Q_PROPERTY(QRectF renderArea READ renderArea NOTIFY renderAreaChanged);
Q_PROPERTY(QSizeF videoResolution READ videoResolution NOTIFY videoResolutionChanged);
QString imageSuffix() const;
QString videoSuffix() const;
- DeclarativeQtCameraNotifications *notifications() const;
- void setNotifications(DeclarativeQtCameraNotifications *notifications);
+ Sounds *sounds() const;
+ void setSounds(Sounds *sounds);
Zoom *zoom() const;
Flash *flash() const;
void idleStateChanged();
void runningStateChanged();
void error(const QString& message, int code, const QString& debug);
- void notificationsChanged();
+ void soundsChanged();
void renderAreaChanged();
void videoResolutionChanged();
notificationscontainer.cpp sounds.cpp focus.cpp autofocus.cpp \
roi.cpp cameraconfig.cpp videoplayer.cpp
-HEADERS += declarativeqtcameranotifications.h
-
PLUGIN_IMPORT_PATH = QtCamera
target.path = $$[QT_INSTALL_IMPORTS]/$$PLUGIN_IMPORT_PATH
+++ /dev/null
-// -*- c++ -*-
-
-/*!
- * This file is part of CameraPlus.
- *
- * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef DECLARATIVE_QT_CAMERA_NOTIFICATIONS_H
-#define DECLARATIVE_QT_CAMERA_NOTIFICATIONS_H
-
-#include <QObject>
-
-class DeclarativeQtCameraNotifications {
-public:
- DeclarativeQtCameraNotifications() {}
- virtual ~DeclarativeQtCameraNotifications() {}
-
- virtual void imageCaptureStarted() = 0;
- virtual void imageCaptureEnded() = 0;
- virtual void videoRecordingStarted() = 0;
- virtual void videoRecordingEnded() = 0;
- virtual void autoFocusAcquired() = 0;
-};
-Q_DECLARE_INTERFACE(DeclarativeQtCameraNotifications, "org.foolab.qml.CameraPlus.Notifications/1.0");
-
-#endif /* DECLARATIVE_QT_CAMERA_NOTIFICATIONS_H */
#include "notificationscontainer.h"
#include "qtcamdevice.h"
#include "qtcamnotifications.h"
-#include "declarativeqtcameranotifications.h"
+#include "sounds.h"
NotificationsContainer::NotificationsContainer(QObject *parent) :
- QObject(parent), m_dev(0), m_notifications(0) {
+ QObject(parent), m_dev(0), m_sounds(0) {
}
setDevice(0);
QMutexLocker locker(&m_mutex);
- m_notifications = 0;
+ m_sounds = 0;
}
void NotificationsContainer::setDevice(QtCamDevice *dev) {
}
}
-DeclarativeQtCameraNotifications *NotificationsContainer::notifications() const {
- return m_notifications;
+Sounds *NotificationsContainer::sounds() const {
+ return m_sounds;
}
-bool NotificationsContainer::setNotifications(DeclarativeQtCameraNotifications *notifications) {
+bool NotificationsContainer::setSounds(Sounds *sounds) {
QMutexLocker lock(&m_mutex);
- if (m_notifications != notifications) {
- m_notifications = notifications;
+ if (m_sounds != sounds) {
+ m_sounds = sounds;
return true;
}
void NotificationsContainer::imageCaptureStarted() {
QMutexLocker l(&m_mutex);
- if (m_notifications) {
- m_notifications->imageCaptureStarted();
+ if (m_sounds) {
+ m_sounds->playImageCaptureStartedSound();
}
}
void NotificationsContainer::imageCaptureEnded() {
QMutexLocker l(&m_mutex);
- if (m_notifications) {
- m_notifications->imageCaptureEnded();
+ if (m_sounds) {
+ m_sounds->playImageCaptureEndedSound();
}
}
void NotificationsContainer::videoRecordingStarted() {
QMutexLocker l(&m_mutex);
- if (m_notifications) {
- m_notifications->videoRecordingStarted();
+ if (m_sounds) {
+ m_sounds->playVideoRecordingStartedSound();
}
}
void NotificationsContainer::videoRecordingEnded() {
QMutexLocker l(&m_mutex);
- if (m_notifications) {
- m_notifications->videoRecordingEnded();
+ if (m_sounds) {
+ m_sounds->playVideoRecordingEndedSound();
}
}
void NotificationsContainer::autoFocusAcquired() {
QMutexLocker l(&m_mutex);
- if (m_notifications) {
- m_notifications->autoFocusAcquired();
+ if (m_sounds) {
+ m_sounds->playAutoFocusAcquiredSound();
}
}
#include <QMutex>
class QtCamDevice;
-class DeclarativeQtCameraNotifications;
+class Sounds;
class NotificationsContainer : public QObject {
Q_OBJECT
~NotificationsContainer();
void setDevice(QtCamDevice *dev);
- DeclarativeQtCameraNotifications *notifications() const;
- bool setNotifications(DeclarativeQtCameraNotifications *notifications);
+ Sounds *sounds() const;
+ bool setSounds(Sounds *sounds);
private slots:
void imageCaptureStarted();
private:
QPointer<QtCamDevice> m_dev;
- DeclarativeQtCameraNotifications *m_notifications;
+ Sounds *m_sounds;
QMutex m_mutex;
};
#include "imageresolutionmodel.h"
#include "videosettings.h"
#include "videoresolutionmodel.h"
-#include "declarativeqtcameranotifications.h"
#include "sounds.h"
#include "cameraconfig.h"
#include "videoplayer.h"
qmlRegisterType<ImageSettings>(uri, MAJOR, MINOR, "ImageSettings");
qmlRegisterType<VideoSettings>(uri, MAJOR, MINOR, "VideoSettings");
qmlRegisterType<Sounds>(uri, MAJOR, MINOR, "Sounds");
- qmlRegisterInterface<DeclarativeQtCameraNotifications>("DeclarativeQtCameraNotifications");
qmlRegisterUncreatableType<ImageResolutionModel>(uri, MAJOR, MINOR, "ImageResolutionModel",
"ImageResolutionModel can be obtained from ImageSettings");
QObject(parent),
m_muted(false),
m_ctx(0),
- m_conf(0),
m_watcher(new QDBusServiceWatcher("org.pulseaudio.Server",
QDBusConnection::systemBus(),
QDBusServiceWatcher::WatchForOwnerChange)) {
}
}
-void Sounds::setConfig(QtCamConfig *conf) {
- m_conf = conf;
-}
-
void Sounds::serviceOwnerChanged(const QString& serviceName, const QString& oldOwner,
const QString& newOwner) {
Q_UNUSED(serviceName);
}
}
-void Sounds::imageCaptureStarted() {
+void Sounds::playImageCaptureStartedSound() {
if (isMuted() || !m_ctx) {
return;
}
play(CAMERA_IMAGE_START_SOUND_ID);
}
-void Sounds::imageCaptureEnded() {
+void Sounds::playImageCaptureEndedSound() {
if (isMuted() || !m_ctx) {
return;
}
play(CAMERA_IMAGE_END_SOUND_ID);
}
-void Sounds::videoRecordingStarted() {
+void Sounds::playVideoRecordingStartedSound() {
if (isMuted() || !m_ctx) {
return;
}
playAndBlock(CAMERA_VIDEO_START_SOUND_ID);
}
-void Sounds::videoRecordingEnded() {
+void Sounds::playVideoRecordingEndedSound() {
if (isMuted() || !m_ctx) {
return;
}
play(CAMERA_VIDEO_STOP_SOUND_ID);
}
-void Sounds::autoFocusAcquired() {
+void Sounds::playAutoFocusAcquiredSound() {
if (isMuted() || !m_ctx) {
return;
}
return;
}
- cache(m_conf->imageCaptureStartedSound(), CAMERA_IMAGE_START_SOUND_ID);
- cache(m_conf->imageCaptureEndedSound(), CAMERA_IMAGE_END_SOUND_ID);
- cache(m_conf->videoRecordingStartedSound(), CAMERA_VIDEO_START_SOUND_ID);
- cache(m_conf->videoRecordingEndedSound(), CAMERA_VIDEO_STOP_SOUND_ID);
- cache(m_conf->autoFocusAcquiredSound(), CAMERA_FOCUS_SOUND_ID);
+ cache(m_imageCaptureStart, CAMERA_IMAGE_START_SOUND_ID);
+ cache(m_imageCaptureEnd, CAMERA_IMAGE_END_SOUND_ID);
+ cache(m_videoRecordingStart, CAMERA_VIDEO_START_SOUND_ID);
+ cache(m_videoRecordingEnd, CAMERA_VIDEO_STOP_SOUND_ID);
+ cache(m_autoFocusAcquired, CAMERA_FOCUS_SOUND_ID);
}
void Sounds::cache(const QString& path, const char *id) {
m_volume = CANBERRA_FULL_VOLUME;
}
}
+
+QString Sounds::imageCaptureStart() const {
+ return m_imageCaptureStart;
+}
+
+void Sounds::setImageCaptureStart(const QString& path) {
+ if (path != m_imageCaptureStart) {
+ m_imageCaptureStart = path;
+ cache(m_imageCaptureStart, CAMERA_IMAGE_START_SOUND_ID);
+ emit imageCaptureStartChanged();
+ }
+}
+
+QString Sounds::imageCaptureEnd() const {
+ return m_imageCaptureEnd;
+}
+
+void Sounds::setImageCaptureEnd(const QString& path) {
+ if (path != m_imageCaptureEnd) {
+ m_imageCaptureEnd = path;
+ cache(m_imageCaptureEnd, CAMERA_IMAGE_END_SOUND_ID);
+ emit imageCaptureEndChanged();
+ }
+}
+
+QString Sounds::videoRecordingStart() const {
+ return m_videoRecordingStart;
+}
+
+void Sounds::setVideoRecordingStart(const QString& path) {
+ if (path != m_videoRecordingStart) {
+ m_videoRecordingStart = path;
+ cache(m_videoRecordingStart, CAMERA_VIDEO_START_SOUND_ID);
+ emit videoRecordingStartChanged();
+ }
+}
+
+QString Sounds::videoRecordingEnd() const {
+ return m_videoRecordingEnd;
+}
+
+void Sounds::setVideoRecordingEnd(const QString& path) {
+ if (path != m_videoRecordingEnd) {
+ m_videoRecordingEnd = path;
+ cache(m_videoRecordingEnd, CAMERA_VIDEO_STOP_SOUND_ID);
+ emit videoRecordingEndChanged();
+ }
+}
+
+QString Sounds::autoFocusAcquired() const {
+ return m_autoFocusAcquired;
+}
+
+void Sounds::setAutoFocusAcquired(const QString& path) {
+ if (path != m_autoFocusAcquired) {
+ m_autoFocusAcquired = path;
+ cache(m_autoFocusAcquired, CAMERA_FOCUS_SOUND_ID);
+ emit autoFocusAcquiredChanged();
+ }
+}
#define SOUNDS_H
#include <QObject>
-#include "declarativeqtcameranotifications.h"
#include <canberra.h>
-class QtCamConfig;
class QDBusServiceWatcher;
class ContextProperty;
-class Sounds : public QObject, public DeclarativeQtCameraNotifications {
+class Sounds : public QObject {
Q_OBJECT
- Q_INTERFACES(DeclarativeQtCameraNotifications);
Q_PROPERTY(bool mute READ isMuted WRITE setMuted NOTIFY muteChanged);
+ Q_PROPERTY(QString imageCaptureStart READ imageCaptureStart WRITE setImageCaptureStart NOTIFY imageCaptureStartChanged);
+ Q_PROPERTY(QString imageCaptureEnd READ imageCaptureEnd WRITE setImageCaptureEnd NOTIFY imageCaptureEndChanged);
+ Q_PROPERTY(QString videoRecordingStart READ videoRecordingStart WRITE setVideoRecordingStart NOTIFY videoRecordingStartChanged);
+ Q_PROPERTY(QString videoRecordingEnd READ videoRecordingEnd WRITE setVideoRecordingEnd NOTIFY videoRecordingEndChanged);
+ Q_PROPERTY(QString autoFocusAcquired READ autoFocusAcquired WRITE setAutoFocusAcquired NOTIFY autoFocusAcquiredChanged);
+ Q_PROPERTY(Volume volume READ volume WRITE setVolume NOTIFY volumeChanged);
+ Q_ENUMS(Volume);
public:
Sounds(QObject *parent = 0);
~Sounds();
- void imageCaptureStarted();
- void imageCaptureEnded();
- void videoRecordingStarted();
- void videoRecordingEnded();
- void autoFocusAcquired();
+ typedef enum {
+ VolumeLow,
+ VolumeHigh,
+ } Volume;
+
+ void playImageCaptureStartedSound();
+ void playImageCaptureEndedSound();
+ void playVideoRecordingStartedSound();
+ void playVideoRecordingEndedSound();
+ void playAutoFocusAcquiredSound();
bool isMuted() const;
void setMuted(bool mute);
- void setConfig(QtCamConfig *conf);
+ Volume volume() const;
+ void setVolume(const Volume& volume);
+
void reload();
+ QString imageCaptureStart() const;
+ void setImageCaptureStart(const QString& path);
+
+ QString imageCaptureEnd() const;
+ void setImageCaptureEnd(const QString& path);
+
+ QString videoRecordingStart() const;
+ void setVideoRecordingStart(const QString& path);
+
+ QString videoRecordingEnd() const;
+ void setVideoRecordingEnd(const QString& path);
+
+ QString autoFocusAcquired() const;
+ void setAutoFocusAcquired(const QString& path);
+
signals:
void muteChanged();
+ void volumeChanged();
+ void imageCaptureStartChanged();
+ void imageCaptureEndChanged();
+ void videoRecordingStartChanged();
+ void videoRecordingEndChanged();
+ void autoFocusAcquiredChanged();
private slots:
void serviceOwnerChanged(const QString& serviceName, const QString& oldOwner,
bool m_muted;
ca_context *m_ctx;
- QtCamConfig *m_conf;
QDBusServiceWatcher *m_watcher;
ContextProperty *m_audioRoute;
QString m_volume;
+ QString m_imageCaptureStart;
+ QString m_imageCaptureEnd;
+ QString m_videoRecordingStart;
+ QString m_videoRecordingEnd;
+ QString m_autoFocusAcquired;
};
#endif /* SOUNDS_H */
return d_ptr->conf->value("video/extension").toString();
}
-QString QtCamConfig::imageCaptureStartedSound() const {
- return d_ptr->conf->value("sounds/imageCaptureStarted").toString();
-}
-
-QString QtCamConfig::imageCaptureEndedSound() const {
- return d_ptr->conf->value("sounds/imageCaptureEnded").toString();
-}
-
-QString QtCamConfig::videoRecordingStartedSound() const {
- return d_ptr->conf->value("sounds/videoRecordingStarted").toString();
-}
-
-QString QtCamConfig::videoRecordingEndedSound() const {
- return d_ptr->conf->value("sounds/videoRecordingEnded").toString();
-}
-
-QString QtCamConfig::autoFocusAcquiredSound() const {
- return d_ptr->conf->value("sounds/autoFocusAcquired").toString();
-}
-
QStringList QtCamConfig::viewfinderFilters() const {
return d_ptr->conf->value("viewfinder-filters/elements").toStringList();
}
QString audioCaptureCaps() const;
- QString imageCaptureStartedSound() const;
- QString imageCaptureEndedSound() const;
- QString videoRecordingStartedSound() const;
- QString videoRecordingEndedSound() const;
- QString autoFocusAcquiredSound() const;
-
QStringList viewfinderFilters() const;
QString roiElement() const;
}
}
- notifications: Sounds {
+ sounds: Sounds {
id: sounds
mute: !settings.soundEnabled
+ imageCaptureStart: platformSettings.imageCaptureStartedSound
+ imageCaptureEnd: platformSettings.imageCaptureEndedSound
+ videoRecordingStart: platformSettings.videoRecordingStartedSound
+ videoRecordingEnd: platformSettings.videoRecordingEndedSound
+ autoFocusAcquired: platformSettings.autoFocusAcquiredSound
}
BatteryInfo {
return service;
}
+
+QString PlatformSettings::imageCaptureStartedSound() const {
+ return m_settings->value("sounds/imageCaptureStarted").toString();
+}
+
+QString PlatformSettings::imageCaptureEndedSound() const {
+ return m_settings->value("sounds/imageCaptureEnded").toString();
+}
+
+QString PlatformSettings::videoRecordingStartedSound() const {
+ return m_settings->value("sounds/videoRecordingStarted").toString();
+}
+
+QString PlatformSettings::videoRecordingEndedSound() const {
+ return m_settings->value("sounds/videoRecordingEnded").toString();
+}
+
+QString PlatformSettings::autoFocusAcquiredSound() const {
+ return m_settings->value("sounds/autoFocusAcquired").toString();
+}
class PlatformSettings : public QObject {
Q_OBJECT
+ Q_PROPERTY(QString imageCaptureStartedSound READ imageCaptureStartedSound CONSTANT);
+ Q_PROPERTY(QString imageCaptureEndedSound READ imageCaptureEndedSound CONSTANT);
+ Q_PROPERTY(QString videoRecordingStartedSound READ videoRecordingStartedSound CONSTANT);
+ Q_PROPERTY(QString videoRecordingEndedSound READ videoRecordingEndedSound CONSTANT);
+ Q_PROPERTY(QString autoFocusAcquiredSound READ autoFocusAcquiredSound CONSTANT);
+
public:
PlatformSettings(QObject *parent = 0);
~PlatformSettings();
Service service(const QString& id);
+ QString imageCaptureStartedSound() const;
+ QString imageCaptureEndedSound() const;
+ QString videoRecordingStartedSound() const;
+ QString videoRecordingEndedSound() const;
+ QString autoFocusAcquiredSound() const;
+
public slots:
void init();