summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2011-09-26 14:17:32 +1000
committerMichael Goddard <michael.goddard@nokia.com>2011-09-26 14:17:32 +1000
commitbe98375f90179be242a5d2fdcde043512f072462 (patch)
treeea1cc76773e0ae385c53f32019da6150677e47b6
parent247dcc770b7ff7d214ea889b83fd346d067278e8 (diff)
parent1913f164dcb59b31d9a7be93311390410437eabb (diff)
Merge branch 'camera' of ssh://codereview.qt-project.org:29418/qt/qtmultimediakit
Conflicts: src/imports/multimedia/multimedia.cpp src/imports/multimedia/multimedia.pro Change-Id: I9d4bc1aa65f89ac24dd12c1e2c21a02f49913e13
-rw-r--r--src/imports/multimedia/multimedia.cpp23
-rw-r--r--src/imports/multimedia/multimedia.pro26
-rw-r--r--src/imports/multimedia/qdeclarativecamera.cpp890
-rw-r--r--src/imports/multimedia/qdeclarativecamera_p.h229
-rw-r--r--src/imports/multimedia/qdeclarativecameracapture.cpp233
-rw-r--r--src/imports/multimedia/qdeclarativecameracapture_p.h126
-rw-r--r--src/imports/multimedia/qdeclarativecameraexposure.cpp260
-rw-r--r--src/imports/multimedia/qdeclarativecameraexposure_p.h135
-rw-r--r--src/imports/multimedia/qdeclarativecameraflash.cpp148
-rw-r--r--src/imports/multimedia/qdeclarativecameraflash_p.h96
-rw-r--r--src/imports/multimedia/qdeclarativecamerafocus.cpp259
-rw-r--r--src/imports/multimedia/qdeclarativecamerafocus_p.h136
-rw-r--r--src/imports/multimedia/qdeclarativecameraimageprocessing.cpp204
-rw-r--r--src/imports/multimedia/qdeclarativecameraimageprocessing_p.h132
-rw-r--r--src/imports/multimedia/qdeclarativecamerarecorder.cpp226
-rw-r--r--src/imports/multimedia/qdeclarativecamerarecorder_p.h162
16 files changed, 2322 insertions, 963 deletions
diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp
index 6aebb7482..2de7401c9 100644
--- a/src/imports/multimedia/multimedia.cpp
+++ b/src/imports/multimedia/multimedia.cpp
@@ -50,10 +50,13 @@
#include "qdeclarativevideooutput_p.h"
#include "qdeclarativeradio_p.h"
#include "qdeclarativebackgroundaudio_p.h"
-#if 0
#include "qdeclarativecamera_p.h"
#include "qdeclarativecamerapreviewprovider_p.h"
-#endif
+#include "qdeclarativecameraexposure_p.h"
+#include "qdeclarativecameraflash_p.h"
+#include "qdeclarativecamerafocus_p.h"
+#include "qdeclarativecameraimageprocessing_p.h"
+
QML_DECLARE_TYPE(QSoundEffect)
@@ -73,20 +76,24 @@ public:
qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput");
qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio");
qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio");
- /* Disabled until ported to scenegraph */
-#if 0
qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera");
-#endif
+ qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 4, 0, "CameraCapture",
+ trUtf8("CameraCapture is only provided by Camera element"));
+ qmlRegisterUncreatableType<QDeclarativeCameraRecorder>(uri, 4, 0, "CameraRecorder",
+ trUtf8("CameraRecorder is only provided by Camera element"));
+ qmlRegisterUncreatableType<QDeclarativeCameraExposure>(uri, 4, 0, "CameraExposure",
+ trUtf8("CameraExposure is only provided by Camera element"));
+ qmlRegisterUncreatableType<QDeclarativeCameraFocus>(uri, 4, 0, "CameraFocus",
+ trUtf8("CameraFocus is only provided by Camera element"));
+ qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing>(uri, 4, 0, "CameraImageProcessing",
+ trUtf8("CameraImageProcessing is only provided by Camera element"));
qmlRegisterType<QDeclarativeMediaMetaData>();
}
void initializeEngine(QDeclarativeEngine *engine, const char *uri)
{
Q_UNUSED(uri);
- Q_UNUSED(engine);
-#if 0
engine->addImageProvider("camera", new QDeclarativeCameraPreviewProvider);
-#endif
}
};
diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
index 609e0394a..4574d0247 100644
--- a/src/imports/multimedia/multimedia.pro
+++ b/src/imports/multimedia/multimedia.pro
@@ -17,7 +17,15 @@ HEADERS += \
qsgvideonode_i420.h \
qsgvideonode_rgb32.h \
qdeclarativeradio_p.h \
- qdeclarativebackgroundaudio_p.h
+ qdeclarativebackgroundaudio_p.h \
+ qdeclarativecamera_p.h \
+ qdeclarativecameracapture_p.h \
+ qdeclarativecamerarecorder_p.h \
+ qdeclarativecameraexposure_p.h \
+ qdeclarativecameraflash_p.h \
+ qdeclarativecamerafocus_p.h \
+ qdeclarativecameraimageprocessing_p.h \
+ qdeclarativecamerapreviewprovider_p.h
SOURCES += \
multimedia.cpp \
@@ -28,18 +36,24 @@ SOURCES += \
qsgvideonode_i420.cpp \
qsgvideonode_rgb32.cpp \
qdeclarativeradio.cpp \
- qdeclarativebackgroundaudio.cpp
+ qdeclarativebackgroundaudio.cpp \
+ qdeclarativecamera.cpp \
+ qdeclarativecameracapture.cpp \
+ qdeclarativecamerarecorder.cpp \
+ qdeclarativecameraexposure.cpp \
+ qdeclarativecameraflash.cpp \
+ qdeclarativecamerafocus.cpp \
+ qdeclarativecameraimageprocessing.cpp \
+ qdeclarativecamerapreviewprovider.cpp
disabled {
HEADERS += \
qdeclarativevideo_p.h \
- qdeclarativecamera_p.h \
- qdeclarativecamerapreviewprovider_p.h
+
SOURCES += \
qdeclarativevideo.cpp \
- qdeclarativecamera.cpp \
- qdeclarativecamerapreviewprovider.cpp
+
}
qmldir.files += $$PWD/qmldir
diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp
index a6b619c92..b8fab3661 100644
--- a/src/imports/multimedia/qdeclarativecamera.cpp
+++ b/src/imports/multimedia/qdeclarativecamera.cpp
@@ -42,176 +42,32 @@
#include "qdeclarativecamera_p.h"
#include "qdeclarativecamerapreviewprovider_p.h"
+#include "qdeclarativecameraexposure_p.h"
+#include "qdeclarativecameraflash_p.h"
+#include "qdeclarativecamerafocus_p.h"
+#include "qdeclarativecameraimageprocessing_p.h"
+
#include <qmediaplayercontrol.h>
#include <qmediaservice.h>
-#include <private/qpaintervideosurface_p.h>
#include <qvideorenderercontrol.h>
#include <QtDeclarative/qdeclarativeinfo.h>
#include <QtCore/QTimer>
#include <QtGui/qevent.h>
-
QT_BEGIN_NAMESPACE
-class FocusZoneItem : public QGraphicsItem {
-public:
- FocusZoneItem(const QCameraFocusZone & zone, const QColor &color, QGraphicsItem *parent = 0)
- :QGraphicsItem(parent),m_zone(zone), m_color(color)
- {}
-
- virtual ~FocusZoneItem() {}
- void paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option,
- QWidget *widget = 0)
- {
- Q_UNUSED(widget);
- Q_UNUSED(option);
-
- painter->setPen(QPen(QBrush(m_color), 2.5));
- QRectF r = boundingRect();
- QPointF dw(r.width()/10, 0);
- QPointF dh(0, r.width()/10);
-
- painter->drawLine(r.topLeft(), r.topLeft()+dw);
- painter->drawLine(r.topLeft(), r.topLeft()+dh);
-
- painter->drawLine(r.topRight(), r.topRight()-dw);
- painter->drawLine(r.topRight(), r.topRight()+dh);
-
- painter->drawLine(r.bottomLeft(), r.bottomLeft()+dw);
- painter->drawLine(r.bottomLeft(), r.bottomLeft()-dh);
-
- painter->drawLine(r.bottomRight(), r.bottomRight()-dw);
- painter->drawLine(r.bottomRight(), r.bottomRight()-dh);
- }
-
- QRectF boundingRect() const {
- if (!parentItem())
- return QRectF();
-
- QRectF p = parentItem()->boundingRect();
- QRectF zone = m_zone.area();
-
- return QRectF(p.left() + zone.left()*p.width(),
- p.top() + zone.top()*p.height(),
- p.width()*zone.width(),
- p.height()*zone.height());
- }
-
-
- QCameraFocusZone m_zone;
- QColor m_color;
-};
-
-
-void QDeclarativeCamera::_q_nativeSizeChanged(const QSizeF &size)
-{
- setImplicitWidth(size.width());
- setImplicitHeight(size.height());
-}
-
void QDeclarativeCamera::_q_error(int errorCode, const QString &errorString)
{
emit error(Error(errorCode), errorString);
emit errorChanged();
}
-void QDeclarativeCamera::_q_imageCaptured(int id, const QImage &preview)
-{
- m_capturedImagePreview = preview;
- QString previewId = QString("preview_%1").arg(id);
- QDeclarativeCameraPreviewProvider::registerPreview(previewId, preview);
-
- emit imageCaptured(QLatin1String("image://camera/")+previewId);
-}
-
-void QDeclarativeCamera::_q_imageSaved(int id, const QString &fileName)
-{
- Q_UNUSED(id);
- m_capturedImagePath = fileName;
- emit imageSaved(fileName);
-}
-
void QDeclarativeCamera::_q_updateState(QCamera::State state)
{
emit cameraStateChanged(QDeclarativeCamera::State(state));
}
-void QDeclarativeCamera::_q_updateLockStatus(QCamera::LockType type,
- QCamera::LockStatus status,
- QCamera::LockChangeReason reason)
-{
- if (type == QCamera::LockFocus) {
- if (status == QCamera::Unlocked && reason == QCamera::LockFailed) {
- //display failed focus points in red for 1 second
- m_focusFailedTime = QTime::currentTime();
- QTimer::singleShot(1000, this, SLOT(_q_updateFocusZones()));
- } else {
- m_focusFailedTime = QTime();
- }
- _q_updateFocusZones();
- }
-}
-
-void QDeclarativeCamera::_q_updateFocusZones()
-{
- qDeleteAll(m_focusZones);
- m_focusZones.clear();
-
- foreach(const QCameraFocusZone &zone, m_camera->focus()->focusZones()) {
- QColor c;
- QCamera::LockStatus lockStatus = m_camera->lockStatus(QCamera::LockFocus);
-
- if (lockStatus == QCamera::Unlocked) {
- //display failed focus points in red for 1 second
- if (zone.status() == QCameraFocusZone::Selected &&
- m_focusFailedTime.msecsTo(QTime::currentTime()) < 500) {
- c = Qt::red;
- }
- } else {
- switch (zone.status()) {
- case QCameraFocusZone::Focused:
- c = Qt::green;
- break;
- case QCameraFocusZone::Selected:
- c = lockStatus == QCamera::Searching ? Qt::yellow : Qt::black;
- break;
- default:
- c= QColor::Invalid;
- break;
- }
- }
-
- if (c.isValid())
- m_focusZones.append(new FocusZoneItem(zone, c, m_viewfinderItem));
- }
-}
-
-void QDeclarativeCamera::_q_updateImageSettings()
-{
- if (m_imageSettingsChanged) {
- m_imageSettingsChanged = false;
- m_capture->setEncodingSettings(m_imageSettings);
- }
-}
-
-void QDeclarativeCamera::_q_applyPendingState()
-{
- if (!m_isStateSet) {
- m_isStateSet = true;
- setCameraState(m_pendingState);
- }
-}
-
-void QDeclarativeCamera::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message)
-{
- Q_UNUSED(id);
- Q_UNUSED(error);
- emit captureFailed(message);
-}
-
-
/*!
\qmlclass Camera QDeclarativeCamera
\since 4.7
@@ -226,16 +82,29 @@ void QDeclarativeCamera::_q_captureFailed(int id, QCameraImageCapture::Error err
import QtMultimediaKit 1.1
Camera {
- focus : visible // to receive focus and capture key events when visible
+ id: camera
+
+ imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
+
+ exposure {
+ exposureCompensation: -1.0
+ exposureMode: Camera.ExposurePortrait
+ }
- flashMode: Camera.FlashRedEyeReduction
- whiteBalanceMode: Camera.WhiteBalanceFlash
- exposureCompensation: -1.0
+ flash.mode: Camera.FlashRedEyeReduction
onImageCaptured : {
photoPreview.source = preview // Show the preview in an Image element
}
+ }
+ VideoOutput {
+ source: camera
+ focus : visible // to receive focus and capture key events when visible
+ }
+
+ Image {
+ id: photoPreview
}
\endqml
@@ -251,66 +120,45 @@ void QDeclarativeCamera::_q_captureFailed(int id, QCameraImageCapture::Error err
/*!
Construct a declarative camera object using \a parent object.
*/
-QDeclarativeCamera::QDeclarativeCamera(QDeclarativeItem *parent) :
- QDeclarativeItem(parent),
+QDeclarativeCamera::QDeclarativeCamera(QObject *parent) :
+ QObject(parent),
m_camera(0),
- m_viewfinderItem(0),
- m_imageSettingsChanged(false),
m_pendingState(ActiveState),
- m_isStateSet(false),
- m_isValid(true)
+ m_componentComplete(false)
{
m_camera = new QCamera(this);
- m_viewfinderItem = new QGraphicsVideoItem(this);
- m_camera->setViewfinder(m_viewfinderItem);
- m_exposure = m_camera->exposure();
- m_focus = m_camera->focus();
- connect(m_viewfinderItem, SIGNAL(nativeSizeChanged(QSizeF)),
- this, SLOT(_q_nativeSizeChanged(QSizeF)));
+ m_imageCapture = new QDeclarativeCameraCapture(m_camera, this);
+ m_videoRecorder = new QDeclarativeCameraRecorder(m_camera, this);
+ m_exposure = new QDeclarativeCameraExposure(m_camera, this);
+ m_flash = new QDeclarativeCameraFlash(m_camera, this);
+ m_focus = new QDeclarativeCameraFocus(m_camera, this);
+ m_imageProcessing = new QDeclarativeCameraImageProcessing(m_camera, this);
+ connect(m_camera, SIGNAL(captureModeChanged(QCamera::CaptureMode)), this, SIGNAL(captureModeChanged()));
connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), this, SIGNAL(lockStatusChanged()));
connect(m_camera, SIGNAL(stateChanged(QCamera::State)), this, SLOT(_q_updateState(QCamera::State)));
- m_capture = new QCameraImageCapture(m_camera, this);
-
- connect(m_capture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(_q_imageCaptured(int, QImage)));
- connect(m_capture, SIGNAL(imageSaved(int,QString)), this, SLOT(_q_imageSaved(int, QString)));
- connect(m_capture, SIGNAL(error(int,QCameraImageCapture::Error,QString)),
- this, SLOT(_q_captureFailed(int,QCameraImageCapture::Error,QString)));
-
- connect(m_focus, SIGNAL(focusZonesChanged()), this, SLOT(_q_updateFocusZones()));
- connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)),
- this, SLOT(_q_updateLockStatus(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
-
- connect(m_exposure, SIGNAL(isoSensitivityChanged(int)), this, SIGNAL(isoSensitivityChanged(int)));
- connect(m_exposure, SIGNAL(apertureChanged(qreal)), this, SIGNAL(apertureChanged(qreal)));
- connect(m_exposure, SIGNAL(shutterSpeedChanged(qreal)), this, SIGNAL(shutterSpeedChanged(qreal)));
-
- //connect(m_exposure, SIGNAL(exposureCompensationChanged(qreal)), this, SIGNAL(exposureCompensationChanged(qreal)));
-
- connect(m_focus, SIGNAL(opticalZoomChanged(qreal)), this, SIGNAL(opticalZoomChanged(qreal)));
- connect(m_focus, SIGNAL(digitalZoomChanged(qreal)), this, SIGNAL(digitalZoomChanged(qreal)));
- connect(m_focus, SIGNAL(maximumOpticalZoomChanged(qreal)), this, SIGNAL(maximumOpticalZoomChanged(qreal)));
- connect(m_focus, SIGNAL(maximumDigitalZoomChanged(qreal)), this, SIGNAL(maximumDigitalZoomChanged(qreal)));
-
- //delayed start to evoid stopping the cammera immediately if
- //stop() is called after constructor,
- //or to set the rest of camera settings before starting the camera
- QMetaObject::invokeMethod(this, "_q_applyPendingState", Qt::QueuedConnection);
-
+ connect(m_camera->focus(), SIGNAL(opticalZoomChanged(qreal)), this, SIGNAL(opticalZoomChanged(qreal)));
+ connect(m_camera->focus(), SIGNAL(digitalZoomChanged(qreal)), this, SIGNAL(digitalZoomChanged(qreal)));
+ connect(m_camera->focus(), SIGNAL(maximumOpticalZoomChanged(qreal)), this, SIGNAL(maximumOpticalZoomChanged(qreal)));
+ connect(m_camera->focus(), SIGNAL(maximumDigitalZoomChanged(qreal)), this, SIGNAL(maximumDigitalZoomChanged(qreal)));
}
/*! Destructor, clean up memory */
QDeclarativeCamera::~QDeclarativeCamera()
{
- if (m_isValid) {
- m_camera->unload();
+ m_camera->unload();
+}
- delete m_viewfinderItem;
- delete m_capture;
- delete m_camera;
- }
+void QDeclarativeCamera::classBegin()
+{
+}
+
+void QDeclarativeCamera::componentComplete()
+{
+ m_componentComplete = true;
+ setCameraState(m_pendingState);
}
/*!
@@ -319,9 +167,6 @@ QDeclarativeCamera::~QDeclarativeCamera()
*/
QDeclarativeCamera::Error QDeclarativeCamera::error() const
{
- if (!m_isValid)
- return QDeclarativeCamera::CameraError;
-
return QDeclarativeCamera::Error(m_camera->error());
}
@@ -330,50 +175,24 @@ QDeclarativeCamera::Error QDeclarativeCamera::error() const
A description of the current error, if any.
*/
-/*!
- \property QDeclarativeCamera::errorString
-
- A description of the current error, if any.
-*/
QString QDeclarativeCamera::errorString() const
{
- if (!m_isValid)
- return QString();
-
return m_camera->errorString();
}
-/*!
- \qmlproperty enumeration Camera::cameraState
-
- The current state of the camera object.
-
- \table
- \header \o Value \o Description
- \row \o UnloadedState
- \o The initial camera state, with camera not loaded,
- the camera capabilities except of supported capture modes
- are unknown.
- While the supported settings are unknown in this state,
- it's allowed to set the camera capture settings like codec,
- resolution, or frame rate.
-
- \row \o LoadedState
- \o The camera is loaded and ready to be configured.
+QDeclarativeCamera::CaptureMode QDeclarativeCamera::captureMode() const
+{
+ return QDeclarativeCamera::CaptureMode(m_camera->captureMode());
+}
- In the Idle state it's allowed to query camera capabilities,
- set capture resolution, codecs, etc.
+void QDeclarativeCamera::setCaptureMode(QDeclarativeCamera::CaptureMode mode)
+{
+ m_camera->setCaptureMode(QCamera::CaptureMode(mode));
+}
- The viewfinder is not active in the loaded state.
- \row \o ActiveState
- \o In the active state as soon as camera is started
- the viewfinder displays video frames and the
- camera is ready for capture.
- \endtable
-*/
/*!
- \property QDeclarativeCamera::cameraState
+ \qmlproperty enumeration Camera::cameraState
The current state of the camera object.
@@ -400,6 +219,8 @@ QString QDeclarativeCamera::errorString() const
the viewfinder displays video frames and the
camera is ready for capture.
\endtable
+
+ The default camera state is ActiveState.
*/
/*!
\enum QDeclarativeCamera::State
@@ -421,25 +242,16 @@ QString QDeclarativeCamera::errorString() const
In the active state as soon as camera is started
the viewfinder displays video frames and the
camera is ready for capture.
-
-
- The default camera state is ActiveState.
*/
QDeclarativeCamera::State QDeclarativeCamera::cameraState() const
{
- if (!m_isValid)
- return QDeclarativeCamera::UnloadedState;
-
- return m_isStateSet ? QDeclarativeCamera::State(m_camera->state()) : m_pendingState;
+ return m_componentComplete ? QDeclarativeCamera::State(m_camera->state()) : m_pendingState;
}
void QDeclarativeCamera::setCameraState(QDeclarativeCamera::State state)
{
- if (!m_isValid)
- return;
-
- if (!m_isStateSet) {
+ if (!m_componentComplete) {
m_pendingState = state;
return;
}
@@ -465,8 +277,7 @@ void QDeclarativeCamera::setCameraState(QDeclarativeCamera::State state)
*/
void QDeclarativeCamera::start()
{
- if (m_isValid)
- m_camera->start();
+ setCameraState(QDeclarativeCamera::ActiveState);
}
/*!
@@ -477,8 +288,7 @@ void QDeclarativeCamera::start()
*/
void QDeclarativeCamera::stop()
{
- if (m_isValid)
- m_camera->stop();
+ setCameraState(QDeclarativeCamera::LoadedState);
}
@@ -556,9 +366,6 @@ void QDeclarativeCamera::stop()
*/
QDeclarativeCamera::LockStatus QDeclarativeCamera::lockStatus() const
{
- if (!m_isValid)
- return QDeclarativeCamera::Unlocked;
-
return QDeclarativeCamera::LockStatus(m_camera->lockStatus());
}
@@ -572,8 +379,7 @@ QDeclarativeCamera::LockStatus QDeclarativeCamera::lockStatus() const
*/
void QDeclarativeCamera::searchAndLock()
{
- if (m_isValid)
- m_camera->searchAndLock();
+ m_camera->searchAndLock();
}
/*!
@@ -587,533 +393,63 @@ void QDeclarativeCamera::searchAndLock()
*/
void QDeclarativeCamera::unlock()
{
- if (m_isValid)
- m_camera->unlock();
-}
-
-/*!
- \qmlmethod Camera::captureImage()
- \fn QDeclarativeCamera::captureImage()
-
- Start image capture. The \l onImageCaptured() and \l onImageSaved() signals will
- be emitted when the capture is complete.
-*/
-void QDeclarativeCamera::captureImage()
-{
- if (m_isValid)
- m_capture->capture();
-}
-
-// XXX this doesn't seem to be used
-/*!
- \fn QDeclarativeCamera::capturedImagePreview() const
-*/
-QImage QDeclarativeCamera::capturedImagePreview() const
-{
- return m_capturedImagePreview;
-}
-
-/*!
- \qmlproperty string Camera::capturedImagePath
-
- The path to the captured image.
-*/
-/*!
- \property QDeclarativeCamera::capturedImagePath
-
- The path to the captured image.
-*/
-QString QDeclarativeCamera::capturedImagePath() const
-{
- return m_capturedImagePath;
-}
-
-/*!
- Paint method.
-*/
-void QDeclarativeCamera::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
-{
-}
-
-/*!
- Change viewfinder size to \a newGeometry and returning the \a oldGeometry
-*/
-void QDeclarativeCamera::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- m_viewfinderItem->setSize(newGeometry.size());
- _q_updateFocusZones();
-
- QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-void QDeclarativeCamera::keyPressEvent(QKeyEvent * event)
-{
- if (!m_isValid || event->isAutoRepeat())
- return;
-
- switch (event->key()) {
- case Qt::Key_CameraFocus:
- m_camera->searchAndLock();
- event->accept();
- break;
- case Qt::Key_Camera:
- if (m_camera->captureMode() == QCamera::CaptureStillImage)
- captureImage();
- //else
- // m_recorder->record();
- event->accept();
- break;
- default:
- QDeclarativeItem::keyPressEvent(event);
- }
-}
-
-/*!
- Handle the release of a key in \a event and take action if needed.
-*/
-void QDeclarativeCamera::keyReleaseEvent(QKeyEvent * event)
-{
- if (!m_isValid || event->isAutoRepeat())
- return;
-
- switch (event->key()) {
- case Qt::Key_CameraFocus:
- m_camera->unlock();
- event->accept();
- break;
- case Qt::Key_Camera:
- //if (m_camera->captureMode() == QCamera::CaptureVideo)
- // m_recorder->stop();
- event->accept();
- break;
- default:
- QDeclarativeItem::keyReleaseEvent(event);
- }
-}
-
-
-/*!
- \qmlproperty enumeration Camera::flashMode
-
- \table
- \header \o Value \o Description
- \row \o FlashOff \o Flash is Off.
- \row \o FlashOn \o Flash is On.
- \row \o FlashAuto \o Automatic flash.
- \row \o FlashRedEyeReduction \o Red eye reduction flash.
- \row \o FlashFill \o Use flash to fillin shadows.
- \row \o FlashTorch \o Constant light source, useful for focusing and video capture.
- \row \o FlashSlowSyncFrontCurtain
- \o Use the flash in conjunction with a slow shutter speed.
- This mode allows better exposure of distant objects and/or motion blur effect.
- \row \o FlashSlowSyncRearCurtain
- \o The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
- \row \o FlashManual \o Flash power is manually set.
- \endtable
-
-*/
-/*!
- \property QDeclarativeCamera::flashMode
-
- \table
- \header \o Value \o Description
- \row \o FlashOff \o Flash is Off.
- \row \o FlashOn \o Flash is On.
- \row \o FlashAuto \o Automatic flash.
- \row \o FlashRedEyeReduction \o Red eye reduction flash.
- \row \o FlashFill \o Use flash to fillin shadows.
- \row \o FlashTorch \o Constant light source, useful for focusing and video capture.
- \row \o FlashSlowSyncFrontCurtain
- \o Use the flash in conjunction with a slow shutter speed.
- This mode allows better exposure of distant objects and/or motion blur effect.
- \row \o FlashSlowSyncRearCurtain
- \o The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
- \row \o FlashManual \o Flash power is manually set.
- \endtable
-
-*/
-/*!
- \enum QDeclarativeCamera::FlashMode
- \value FlashOff Flash is Off.
- \value FlashOn Flash is On.
- \value FlashAuto Automatic flash.
- \value FlashRedEyeReduction Red eye reduction flash.
- \value FlashFill Use flash to fillin shadows.
- \value FlashTorch Constant light source, useful for focusing and video capture.
- \value FlashSlowSyncFrontCurtain
- Use the flash in conjunction with a slow shutter speed.
- This mode allows better exposure of distant objects and/or motion blur effect.
- \value FlashSlowSyncRearCurtain
- The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
- \value FlashManual Flash power is manually set.
-
-*/
-int QDeclarativeCamera::flashMode() const
-{
- if (!m_isValid)
- return 0;
-
- return m_exposure->flashMode();
-}
-
-void QDeclarativeCamera::setFlashMode(int mode)
-{
- if (m_isValid && m_exposure->flashMode() != mode) {
- m_exposure->setFlashMode(QCameraExposure::FlashModes(mode));
- emit flashModeChanged(mode);
- }
-}
-
-/*!
- \qmlproperty real Camera::exposureCompensation
-
- Adjustment for the automatically calculated exposure. The value is
- in EV units.
- */
-/*!
- \property QDeclarativeCamera::exposureCompensation
-
- Adjustment for the automatically calculated exposure. The value is
- in EV units.
- */
-qreal QDeclarativeCamera::exposureCompensation() const
-{
- if (!m_isValid)
- return 0.0;
-
- return m_exposure->exposureCompensation();
-}
-
-void QDeclarativeCamera::setExposureCompensation(qreal ev)
-{
- if (m_isValid)
- m_exposure->setExposureCompensation(ev);
-}
-
-/*!
- \qmlproperty real Camera::isoSensitivity
-
- The sensor's ISO sensitivity.
- */
-/*!
- \property QDeclarativeCamera::iso
-
- The sensor's ISO sensitivity.
- */
-int QDeclarativeCamera::isoSensitivity() const
-{
- if (!m_isValid)
- return 0;
-
- return m_exposure->isoSensitivity();
-}
-
-void QDeclarativeCamera::setManualIsoSensitivity(int iso)
-{
- if (!m_isValid)
- return;
-
- m_exposure->setManualIsoSensitivity(iso);
-}
-
-/*!
- \qmlproperty real Camera::shutterSpeed
-
- The camera's shutter speed, in seconds.
-*/
-/*!
- \property QDeclarativeCamera::shutterSpeed
-
- The camera's shutter speed, in seconds.
-*/
-qreal QDeclarativeCamera::shutterSpeed() const
-{
- if (!m_isValid)
- return 0.0;
-
- return m_exposure->shutterSpeed();
-}
-
-/*!
- \qmlproperty real Camera::aperture
-
- The lens aperture as an F number (the ratio of the focal length to effective aperture diameter).
-*/
-/*!
- \property QDeclarativeCamera::aperture
-
- The lens aperture as an F number (the ratio of the focal length to effective aperture diameter).
-*/
-qreal QDeclarativeCamera::aperture() const
-{
- if (!m_isValid)
- return 0.0;
-
- return m_exposure->aperture();
-}
-
-/*!
- \qmlproperty enumeration Camera::exposureMode
-
- \table
- \header \o Value \o Description
- \row \o ExposureManual \o Manual mode.
- \row \o ExposureAuto \o Automatic mode.
- \row \o ExposureNight \o Night mode.
- \row \o ExposureBacklight \o Backlight exposure mode.
- \row \o ExposureSpotlight \o Spotlight exposure mode.
- \row \o ExposureSports \o Spots exposure mode.
- \row \o ExposureSnow \o Snow exposure mode.
- \row \o ExposureBeach \o Beach exposure mode.
- \row \o ExposureLargeAperture \o Use larger aperture with small depth of field.
- \row \o ExposureSmallAperture \o Use smaller aperture.
- \row \o ExposurePortrait \o Portrait exposure mode.
- \row \o ExposureModeVendor \o The base value for device specific exposure modes.
- \endtable
-
-*/
-/*!
- \enum QDeclarativeCamera::ExposureMode
- \value ExposureManual Manual mode.
- \value ExposureAuto Automatic mode.
- \value ExposureNight Night mode.
- \value ExposureBacklight Backlight exposure mode.
- \value ExposureSpotlight Spotlight exposure mode.
- \value ExposureSports Spots exposure mode.
- \value ExposureSnow Snow exposure mode.
- \value ExposureBeach Beach exposure mode.
- \value ExposureLargeAperture Use larger aperture with small depth of field.
- \value ExposureSmallAperture Use smaller aperture.
- \value ExposurePortrait Portrait exposure mode.
- \value ExposureModeVendor The base value for device specific exposure modes.
-
-*/
-/*!
- \property QDeclarativeCamera::exposureMode
-
- Camera exposure modes.
-*/
-QDeclarativeCamera::ExposureMode QDeclarativeCamera::exposureMode() const
-{
- if (!m_isValid)
- return QDeclarativeCamera::ExposureAuto;
-
- return ExposureMode(m_exposure->exposureMode());
-}
-
-void QDeclarativeCamera::setExposureMode(QDeclarativeCamera::ExposureMode mode)
-{
- if (!m_isValid)
- return;
-
- if (exposureMode() != mode) {
- m_exposure->setExposureMode(QCameraExposure::ExposureMode(mode));
- emit exposureModeChanged(exposureMode());
- }
-}
-
-/*!
- \qmlproperty size Camera::captureResolution
-
- The resolution to capture the image at. If empty, the system will pick
- a good size.
-*/
-/*!
- \property QDeclarativeCamera::captureResolution
-
- The resolution to capture the image at. If empty, the system will pick
- a good size.
-*/
-QSize QDeclarativeCamera::captureResolution() const
-{
- if (!m_isValid)
- return QSize();
-
- return m_imageSettings.resolution();
-}
-
-void QDeclarativeCamera::setCaptureResolution(const QSize &resolution)
-{
- if (m_isValid && m_imageSettings.resolution() != resolution) {
- m_imageSettings.setResolution(resolution);
-
- if (!m_imageSettingsChanged) {
- m_imageSettingsChanged = true;
- QMetaObject::invokeMethod(this, "_q_updateImageSettings", Qt::QueuedConnection);
- }
-
- emit captureResolutionChanged(resolution);
- }
+ m_camera->unlock();
}
/*!
\qmlproperty real Camera::maximumOpticalZoom
-
- The maximum optical zoom factor, or 1.0 if optical zoom is not supported.
-*/
-/*!
\property QDeclarativeCamera::maximumOpticalZoom
The maximum optical zoom factor, or 1.0 if optical zoom is not supported.
*/
qreal QDeclarativeCamera::maximumOpticalZoom() const
{
- if (!m_isValid)
- return 0.0;
-
- return m_focus->maximumOpticalZoom();
+ return m_camera->focus()->maximumOpticalZoom();
}
/*!
\qmlproperty real Camera::maximumDigitalZoom
-
- The maximum digital zoom factor, or 1.0 if digital zoom is not supported.
-*/
-/*!
\property QDeclarativeCamera::maximumDigitalZoom
The maximum digital zoom factor, or 1.0 if digital zoom is not supported.
*/
qreal QDeclarativeCamera::maximumDigitalZoom() const
{
- if (!m_isValid)
- return 0.0;
-
- return m_focus->maximumDigitalZoom();
+ return m_camera->focus()->maximumDigitalZoom();
}
/*!
\qmlproperty real Camera::opticalZoom
-
- The current optical zoom factor.
-*/
-/*!
\property QDeclarativeCamera::opticalZoom
The current optical zoom factor.
*/
qreal QDeclarativeCamera::opticalZoom() const
{
- if (!m_isValid)
- return 0.0;
-
- return m_focus->opticalZoom();
+ return m_camera->focus()->opticalZoom();
}
void QDeclarativeCamera::setOpticalZoom(qreal value)
{
- if (m_isValid)
- m_focus->zoomTo(value, digitalZoom());
+ m_camera->focus()->zoomTo(value, digitalZoom());
}
/*!
\qmlproperty real Camera::digitalZoom
-
- The current digital zoom factor.
-*/
-/*!
\property QDeclarativeCamera::digitalZoom
The current digital zoom factor.
*/
qreal QDeclarativeCamera::digitalZoom() const
{
- if (!m_isValid)
- return 0.0;
-
- return m_focus->digitalZoom();
+ return m_camera->focus()->digitalZoom();
}
void QDeclarativeCamera::setDigitalZoom(qreal value)
{
- if (m_isValid)
- m_focus->zoomTo(opticalZoom(), value);
+ m_camera->focus()->zoomTo(opticalZoom(), value);
}
-/*!
- \enum QDeclarativeCamera::WhiteBalanceMode
- \value WhiteBalanceManual Manual white balance. In this mode the manual white balance property value is used.
- \value WhiteBalanceAuto Auto white balance mode.
- \value WhiteBalanceSunlight Sunlight white balance mode.
- \value WhiteBalanceCloudy Cloudy white balance mode.
- \value WhiteBalanceShade Shade white balance mode.
- \value WhiteBalanceTungsten Tungsten white balance mode.
- \value WhiteBalanceFluorescent Fluorescent white balance mode.
- \value WhiteBalanceIncandescent Incandescent white balance mode.
- \value WhiteBalanceFlash Flash white balance mode.
- \value WhiteBalanceSunset Sunset white balance mode.
- \value WhiteBalanceVendor Vendor defined white balance mode.
-*/
-/*!
- \qmlproperty enumeration Camera::whiteBalanceMode
-
- \table
- \header \o Value \o Description
- \row \o WhiteBalanceManual \o Manual white balance. In this mode the manual white balance property value is used.
- \row \o WhiteBalanceAuto \o Auto white balance mode.
- \row \o WhiteBalanceSunlight \o Sunlight white balance mode.
- \row \o WhiteBalanceCloudy \o Cloudy white balance mode.
- \row \o WhiteBalanceShade \o Shade white balance mode.
- \row \o WhiteBalanceTungsten \o Tungsten white balance mode.
- \row \o WhiteBalanceFluorescent \o Fluorescent white balance mode.
- \row \o WhiteBalanceIncandescent \o Incandescent white balance mode.
- \row \o WhiteBalanceFlash \o Flash white balance mode.
- \row \o WhiteBalanceSunset \o Sunset white balance mode.
- \row \o WhiteBalanceVendor \o Vendor defined white balance mode.
- \endtable
-
- \sa manualWhiteBalance
-*/
-/*!
- \property QDeclarativeCamera::whiteBalanceMode
-
- \sa WhiteBalanceMode
-*/
-QDeclarativeCamera::WhiteBalanceMode QDeclarativeCamera::whiteBalanceMode() const
-{
- if (!m_isValid)
- return QDeclarativeCamera::WhiteBalanceAuto;
-
- return WhiteBalanceMode(m_camera->imageProcessing()->whiteBalanceMode());
-}
-
-void QDeclarativeCamera::setWhiteBalanceMode(QDeclarativeCamera::WhiteBalanceMode mode) const
-{
- if (m_isValid && whiteBalanceMode() != mode) {
- m_camera->imageProcessing()->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode(mode));
- emit whiteBalanceModeChanged(whiteBalanceMode());
- }
-}
-
-/*!
- \qmlproperty int Camera::manualWhiteBalance
-
- The color temperature used when in manual white balance mode (WhiteBalanceManual).
-
- \sa whiteBalanceMode
-*/
-/*!
- \property QDeclarativeCamera::manualWhiteBalance
-
- The color temperature used when in manual white balance mode (WhiteBalanceManual).
-
- \sa whiteBalanceMode
-*/
-int QDeclarativeCamera::manualWhiteBalance() const
-{
- if (!m_isValid)
- return 0;
-
- return m_camera->imageProcessing()->manualWhiteBalance();
-}
-
-void QDeclarativeCamera::setManualWhiteBalance(int colorTemp) const
-{
- if (m_isValid && manualWhiteBalance() != colorTemp) {
- m_camera->imageProcessing()->setManualWhiteBalance(colorTemp);
- emit manualWhiteBalanceChanged(manualWhiteBalance());
- }
-}
/*!
\qmlsignal Camera::onError(error, errorString)
@@ -1131,66 +467,6 @@ void QDeclarativeCamera::setManualWhiteBalance(int colorTemp) const
\row \o NotSupportedFeatureError \o The feature is not supported.
\endtable
*/
-/*!
- \qmlsignal Camera::onError(error, errorString)
-
-
- This handler is called when an error occurs. The enumeration value \a error is one of the
- values defined below, and a descriptive string value is available in \a errorString.
-*/
-/*!
- \enum QDeclarativeCamera::Error
- \value NoError No errors have occurred.
- \value CameraError An error has occurred.
- \value InvalidRequestError System resource doesn't support requested functionality.
- \value ServiceMissingError No camera service available.
- \value NotSupportedFeatureError The feature is not supported.
-*/
-
-
-/*!
- \qmlsignal Camera::onCaptureFailed(message)
-
- This handler is called when an error occurs during capture. A descriptive message is available in \a message.
-*/
-/*!
- \fn QDeclarativeCamera::captureFailed(const QString &message)
-
- This handler is called when an error occurs during capture. A descriptive message is available in \a message.
-*/
-
-/*!
- \qmlsignal Camera::onImageCaptured(preview)
-
- This handler is called when an image has been captured but not yet saved to the filesystem. The \a preview
- parameter can be used as the URL supplied to an Image element.
-
- \sa onImageSaved
-*/
-/*!
- \fn QDeclarativeCamera::imageCaptured(const QString &preview)
-
- This handler is called when an image has been captured but not yet saved to the filesystem. The \a preview
- parameter can be used as the URL supplied to an Image element.
-
- \sa imageSaved()
-*/
-
-/*!
- \qmlsignal Camera::onImageSaved(path)
-
- This handler is called after the image has been written to the filesystem. The \a path is a local file path, not a URL.
-
- \sa onImageCaptured
-*/
-/*!
- \fn QDeclarativeCamera::imageSaved(const QString &path)
-
- This handler is called after the image has been written to the filesystem. The \a path is a local file path, not a URL.
-
- \sa imageCaptured()
-*/
-
/*!
\fn void QDeclarativeCamera::lockStatusChanged()
@@ -1288,34 +564,6 @@ void QDeclarativeCamera::setManualWhiteBalance(int colorTemp) const
/*!
- \fn void QDeclarativeCamera::exposureModeChanged(QDeclarativeCamera::ExposureMode)
-
- \qmlsignal Camera::exposureModeChanged(Camera::ExposureMode)
-*/
-
-/*!
- \fn void QDeclarativeCamera::flashModeChanged(int)
-*/
-/*!
- \qmlsignal Camera::flashModeChanged(int)
-*/
-
-/*!
- \fn void QDeclarativeCamera::whiteBalanceModeChanged(QDeclarativeCamera::WhiteBalanceMode) const
-
-*/
-/*!
- \qmlsignal Camera::whiteBalanceModeChanged(Camera::WhiteBalanceMode)
-*/
-
-/*!
- \fn void QDeclarativeCamera::manualWhiteBalanceChanged(int) const
-*/
-/*!
- \qmlsignal Camera::manualWhiteBalanceChanged(int)
-*/
-
-/*!
\fn void QDeclarativeCamera::captureResolutionChanged(const QSize &)
\qmlsignal Camera::captureResolutionChanged(Item)
diff --git a/src/imports/multimedia/qdeclarativecamera_p.h b/src/imports/multimedia/qdeclarativecamera_p.h
index 07ebb1a32..a96dd6e67 100644
--- a/src/imports/multimedia/qdeclarativecamera_p.h
+++ b/src/imports/multimedia/qdeclarativecamera_p.h
@@ -53,57 +53,66 @@
// We mean it.
//
-#include "qgraphicsvideoitem.h"
#include <QtCore/qbasictimer.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtCore/QTime>
+#include <QtCore/qdatetime.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativeparserstatus.h>
#include <qcamera.h>
#include <qcameraimageprocessing.h>
#include <qcameraimagecapture.h>
-
+#include <qdeclarativecameracapture_p.h>
+#include <qdeclarativecamerarecorder_p.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QTimerEvent;
-class QVideoSurfaceFormat;
-
+class QDeclarativeCameraExposure;
+class QDeclarativeCameraFocus;
+class QDeclarativeCameraFlash;
+class QDeclarativeCameraImageProcessing;
-class QDeclarativeCamera : public QDeclarativeItem
+class QDeclarativeCamera : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+
+ Q_PROPERTY(CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged)
Q_PROPERTY(State cameraState READ cameraState WRITE setCameraState NOTIFY cameraStateChanged)
Q_PROPERTY(LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
- Q_PROPERTY(QString capturedImagePath READ capturedImagePath NOTIFY imageSaved)
-
- Q_PROPERTY(int iso READ isoSensitivity WRITE setManualIsoSensitivity NOTIFY isoSensitivityChanged)
- Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged)
- Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged)
- Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged)
-
- Q_PROPERTY(ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
- Q_PROPERTY(int flashMode READ flashMode WRITE setFlashMode NOTIFY flashModeChanged)
- Q_PROPERTY(WhiteBalanceMode whiteBalanceMode READ whiteBalanceMode WRITE setWhiteBalanceMode NOTIFY whiteBalanceModeChanged)
- Q_PROPERTY(int manualWhiteBalance READ manualWhiteBalance WRITE setManualWhiteBalance NOTIFY manualWhiteBalanceChanged)
-
- Q_PROPERTY(QSize captureResolution READ captureResolution WRITE setCaptureResolution NOTIFY captureResolutionChanged)
-
Q_PROPERTY(qreal opticalZoom READ opticalZoom WRITE setOpticalZoom NOTIFY opticalZoomChanged)
Q_PROPERTY(qreal maximumOpticalZoom READ maximumOpticalZoom NOTIFY maximumOpticalZoomChanged)
Q_PROPERTY(qreal digitalZoom READ digitalZoom WRITE setDigitalZoom NOTIFY digitalZoomChanged)
Q_PROPERTY(qreal maximumDigitalZoom READ maximumDigitalZoom NOTIFY maximumDigitalZoomChanged)
+ Q_PROPERTY(QObject *mediaObject READ mediaObject NOTIFY mediaObjectChanged SCRIPTABLE false DESIGNABLE false)
+ Q_PROPERTY(QDeclarativeCameraCapture* imageCapture READ imageCapture CONSTANT)
+ Q_PROPERTY(QDeclarativeCameraRecorder* videoRecorder READ videoRecorder CONSTANT)
+ Q_PROPERTY(QDeclarativeCameraExposure* exposure READ exposure CONSTANT)
+ Q_PROPERTY(QDeclarativeCameraFlash* flash READ flash CONSTANT)
+ Q_PROPERTY(QDeclarativeCameraFocus* focus READ focus CONSTANT)
+ Q_PROPERTY(QDeclarativeCameraImageProcessing* imageProcessing READ imageProcessing CONSTANT)
+
+ Q_ENUMS(CaptureMode)
Q_ENUMS(State)
Q_ENUMS(LockStatus)
Q_ENUMS(Error)
+
Q_ENUMS(FlashMode)
Q_ENUMS(ExposureMode)
- Q_ENUMS(WhiteBalanceMode)
+
+ Q_ENUMS(FocusMode)
+ Q_ENUMS(FocusPointMode)
+ Q_ENUMS(FocusAreaStatus)
public:
+ enum CaptureMode {
+ CaptureStillImage = QCamera::CaptureStillImage,
+ CaptureVideo = QCamera::CaptureVideo
+ };
+
enum State
{
ActiveState = QCamera::ActiveState,
@@ -128,72 +137,75 @@ public:
};
enum FlashMode {
- FlashAuto = 0x1,
- FlashOff = 0x2,
- FlashOn = 0x4,
- FlashRedEyeReduction = 0x8,
- FlashFill = 0x10,
- FlashTorch = 0x20,
- FlashSlowSyncFrontCurtain = 0x40,
- FlashSlowSyncRearCurtain = 0x80,
- FlashManual = 0x100
+ FlashAuto = QCameraExposure::FlashAuto,
+ FlashOff = QCameraExposure::FlashOff,
+ FlashOn = QCameraExposure::FlashOn,
+ FlashRedEyeReduction = QCameraExposure::FlashRedEyeReduction,
+ FlashFill = QCameraExposure::FlashFill,
+ FlashTorch = QCameraExposure::FlashTorch,
+ FlashSlowSyncFrontCurtain = QCameraExposure::FlashSlowSyncFrontCurtain,
+ FlashSlowSyncRearCurtain = QCameraExposure::FlashSlowSyncRearCurtain,
+ FlashManual = QCameraExposure::FlashManual
};
enum ExposureMode {
- ExposureAuto = 0,
- ExposureManual = 1,
- ExposurePortrait = 2,
- ExposureNight = 3,
- ExposureBacklight = 4,
- ExposureSpotlight = 5,
- ExposureSports = 6,
- ExposureSnow = 7,
- ExposureBeach = 8,
- ExposureLargeAperture = 9,
- ExposureSmallAperture = 10,
- ExposureModeVendor = 1000
+ ExposureAuto = QCameraExposure::ExposureAuto,
+ ExposureManual = QCameraExposure::ExposureManual,
+ ExposurePortrait = QCameraExposure::ExposurePortrait,
+ ExposureNight = QCameraExposure::ExposureNight,
+ ExposureBacklight = QCameraExposure::ExposureBacklight,
+ ExposureSpotlight = QCameraExposure::ExposureSpotlight,
+ ExposureSports = QCameraExposure::ExposureSports,
+ ExposureSnow = QCameraExposure::ExposureSnow,
+ ExposureBeach = QCameraExposure::ExposureBeach,
+ ExposureLargeAperture = QCameraExposure::ExposureLargeAperture,
+ ExposureSmallAperture = QCameraExposure::ExposureSmallAperture,
+ ExposureModeVendor = QCameraExposure::ExposureModeVendor
};
- enum WhiteBalanceMode {
- WhiteBalanceAuto = 0,
- WhiteBalanceManual = 1,
- WhiteBalanceSunlight = 2,
- WhiteBalanceCloudy = 3,
- WhiteBalanceShade = 4,
- WhiteBalanceTungsten = 5,
- WhiteBalanceFluorescent = 6,
- WhiteBalanceIncandescent = 7,
- WhiteBalanceFlash = 8,
- WhiteBalanceSunset = 9,
- WhiteBalanceVendor = 1000
+ enum FocusMode {
+ FocusManual = QCameraFocus::ManualFocus,
+ FocusHyperfocal = QCameraFocus::HyperfocalFocus,
+ FocusInfinity = QCameraFocus::InfinityFocus,
+ FocusAuto = QCameraFocus::AutoFocus,
+ FocusContinuous = QCameraFocus::ContinuousFocus,
+ FocusMacro = QCameraFocus::MacroFocus
};
+ Q_DECLARE_FLAGS(FocusModes, FocusMode)
- QDeclarativeCamera(QDeclarativeItem *parent = 0);
- ~QDeclarativeCamera();
+ enum FocusPointMode {
+ FocusPointAuto = QCameraFocus::FocusPointAuto,
+ FocusPointCenter = QCameraFocus::FocusPointCenter,
+ FocusPointFaceDetection = QCameraFocus::FocusPointFaceDetection,
+ FocusPointCustom = QCameraFocus::FocusPointCustom
+ };
- State cameraState() const;
+ enum FocusAreaStatus {
+ FocusAreaUnused = QCameraFocusZone::Unused,
+ FocusAreaSelected = QCameraFocusZone::Selected,
+ FocusAreaFocused = QCameraFocusZone::Focused
+ };
- Error error() const;
- QString errorString() const;
- LockStatus lockStatus() const;
+ QDeclarativeCamera(QObject *parent = 0);
+ ~QDeclarativeCamera();
- QImage capturedImagePreview() const;
- QString capturedImagePath() const;
+ QObject *mediaObject() { return m_camera; }
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ QDeclarativeCameraCapture *imageCapture() { return m_imageCapture; }
+ QDeclarativeCameraRecorder *videoRecorder() { return m_videoRecorder; }
+ QDeclarativeCameraExposure *exposure() { return m_exposure; }
+ QDeclarativeCameraFlash *flash() { return m_flash; }
+ QDeclarativeCameraFocus *focus() { return m_focus; }
+ QDeclarativeCameraImageProcessing *imageProcessing() { return m_imageProcessing; }
- int flashMode() const;
- ExposureMode exposureMode() const;
- qreal exposureCompensation() const;
- int isoSensitivity() const;
- qreal shutterSpeed() const;
- qreal aperture() const;
+ CaptureMode captureMode() const;
+ State cameraState() const;
- WhiteBalanceMode whiteBalanceMode() const;
- int manualWhiteBalance() const;
+ Error error() const;
+ QString errorString() const;
- QSize captureResolution() const;
+ LockStatus lockStatus() const;
qreal maximumOpticalZoom() const;
qreal maximumDigitalZoom() const;
@@ -202,6 +214,8 @@ public:
qreal digitalZoom() const;
public Q_SLOTS:
+ void setCaptureMode(CaptureMode mode);
+
void start();
void stop();
@@ -210,18 +224,6 @@ public Q_SLOTS:
void searchAndLock();
void unlock();
- void captureImage();
-
- void setFlashMode(int);
- void setExposureMode(QDeclarativeCamera::ExposureMode);
- void setExposureCompensation(qreal ev);
- void setManualIsoSensitivity(int iso);
-
- void setWhiteBalanceMode(QDeclarativeCamera::WhiteBalanceMode mode) const;
- void setManualWhiteBalance(int colorTemp) const;
-
- void setCaptureResolution(const QSize &size);
-
void setOpticalZoom(qreal);
void setDigitalZoom(qreal);
@@ -229,68 +231,39 @@ Q_SIGNALS:
void errorChanged();
void error(QDeclarativeCamera::Error error, const QString &errorString);
+ void captureModeChanged();
void cameraStateChanged(QDeclarativeCamera::State);
void lockStatusChanged();
- void imageCaptured(const QString &preview);
- void imageSaved(const QString &path);
- void captureFailed(const QString &message);
-
- void isoSensitivityChanged(int);
- void apertureChanged(qreal);
- void shutterSpeedChanged(qreal);
- void exposureCompensationChanged(qreal);
- void exposureModeChanged(QDeclarativeCamera::ExposureMode);
- void flashModeChanged(int);
-
- void whiteBalanceModeChanged(QDeclarativeCamera::WhiteBalanceMode) const;
- void manualWhiteBalanceChanged(int) const;
-
- void captureResolutionChanged(const QSize&);
-
void opticalZoomChanged(qreal);
void digitalZoomChanged(qreal);
void maximumOpticalZoomChanged(qreal);
void maximumDigitalZoomChanged(qreal);
-protected:
- void geometryChanged(const QRectF &geometry, const QRectF &);
- void keyPressEvent(QKeyEvent * event);
- void keyReleaseEvent(QKeyEvent * event);
+ void mediaObjectChanged();
private Q_SLOTS:
void _q_updateState(QCamera::State);
- void _q_nativeSizeChanged(const QSizeF &size);
void _q_error(int, const QString &);
- void _q_imageCaptured(int, const QImage&);
- void _q_imageSaved(int, const QString&);
- void _q_captureFailed(int, QCameraImageCapture::Error, const QString&);
- void _q_updateFocusZones();
- void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason);
- void _q_updateImageSettings();
- void _q_applyPendingState();
+
+protected:
+ void classBegin();
+ void componentComplete();
private:
Q_DISABLE_COPY(QDeclarativeCamera)
QCamera *m_camera;
- QGraphicsVideoItem *m_viewfinderItem;
-
- QCameraExposure *m_exposure;
- QCameraFocus *m_focus;
- QCameraImageCapture *m_capture;
-
- QImage m_capturedImagePreview;
- QString m_capturedImagePath;
- QList <QGraphicsItem*> m_focusZones;
- QTime m_focusFailedTime;
- QImageEncoderSettings m_imageSettings;
- bool m_imageSettingsChanged;
+ QDeclarativeCameraCapture *m_imageCapture;
+ QDeclarativeCameraRecorder *m_videoRecorder;
+ QDeclarativeCameraExposure *m_exposure;
+ QDeclarativeCameraFlash *m_flash;
+ QDeclarativeCameraFocus *m_focus;
+ QDeclarativeCameraImageProcessing *m_imageProcessing;
State m_pendingState;
- bool m_isStateSet;
- bool m_isValid;
+ bool m_componentComplete;
};
QT_END_NAMESPACE
diff --git a/src/imports/multimedia/qdeclarativecameracapture.cpp b/src/imports/multimedia/qdeclarativecameracapture.cpp
new file mode 100644
index 000000000..c3d16bbbe
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameracapture.cpp
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecameracapture_p.h"
+#include "qdeclarativecamerapreviewprovider_p.h"
+
+#include <QtCore/qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeCameraCapture::QDeclarativeCameraCapture(QCamera *camera, QObject *parent) :
+ QObject(parent),
+ m_camera(camera)
+{
+ m_capture = new QCameraImageCapture(camera, this);
+
+ connect(m_capture, SIGNAL(readyForCaptureChanged(bool)), this, SIGNAL(readyForCaptureChanged(bool)));
+ connect(m_capture, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed()));
+ connect(m_capture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(_q_imageCaptured(int, QImage)));
+ connect(m_capture, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), this,
+ SLOT(_q_imageMetadataAvailable(int,QString,QVariant)));
+ connect(m_capture, SIGNAL(imageSaved(int,QString)), this, SLOT(_q_imageSaved(int, QString)));
+ connect(m_capture, SIGNAL(error(int,QCameraImageCapture::Error,QString)),
+ this, SLOT(_q_captureFailed(int,QCameraImageCapture::Error,QString)));
+}
+
+QDeclarativeCameraCapture::~QDeclarativeCameraCapture()
+{
+}
+
+/*!
+ \qmlproperty string CameraCapture::ready
+ \property QDeclarativeCameraCapture::ready
+
+ Indicates camera is ready to capture photo.
+*/
+bool QDeclarativeCameraCapture::isReadyForCapture() const
+{
+ return m_capture->isReadyForCapture();
+}
+
+/*!
+ \qmlmethod CameraCapture::capture()
+ \fn QDeclarativeCameraCapture::capture()
+
+ Start image capture. The \l onImageCaptured() and \l onImageSaved() signals will
+ be emitted when the capture is complete.
+*/
+void QDeclarativeCameraCapture::capture()
+{
+ m_capture->capture();
+}
+
+/*!
+ \qmlmethod CameraCapture::captureToLocation()
+ \fn QDeclarativeCameraCapture::captureToLocation()
+
+ Start image capture to specified \a location. The \l onImageCaptured() and \l onImageSaved() signals will
+ be emitted when the capture is complete.
+*/
+void QDeclarativeCameraCapture::captureToLocation(const QString &location)
+{
+ m_capture->capture(location);
+}
+
+/*!
+ \qmlmethod CameraCapture::cancelCapture()
+ \fn QDeclarativeCameraCapture::cancelCapture()
+
+ Cancel pendig image capture requests.
+*/
+
+void QDeclarativeCameraCapture::cancelCapture()
+{
+ m_capture->cancelCapture();
+}
+
+/*!
+ \qmlproperty string CameraCapture::capturedImagePath
+ \property QDeclarativeCameraCapture::capturedImagePath
+
+ The path to the captured image.
+*/
+QString QDeclarativeCameraCapture::capturedImagePath() const
+{
+ return m_capturedImagePath;
+}
+
+void QDeclarativeCameraCapture::_q_imageCaptured(int id, const QImage &preview)
+{
+ QString previewId = QString("preview_%1").arg(id);
+ QDeclarativeCameraPreviewProvider::registerPreview(previewId, preview);
+
+ emit imageCaptured(QLatin1String("image://camera/")+previewId);
+}
+
+void QDeclarativeCameraCapture::_q_imageSaved(int id, const QString &fileName)
+{
+ Q_UNUSED(id);
+ m_capturedImagePath = fileName;
+ emit imageSaved(fileName);
+}
+
+void QDeclarativeCameraCapture::_q_imageMetadataAvailable(int id, const QString &key, const QVariant &value)
+{
+ Q_UNUSED(id);
+ emit imageMetadataAvailable(key, value);
+}
+
+
+void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(error);
+ qWarning() << "QCameraImageCapture error:" << message;
+ emit captureFailed(message);
+}
+
+/*!
+ \qmlproperty size CameraCapture::resolution
+ \property QDeclarativeCameraCapture::resolution
+
+ The resolution to capture the image at. If empty, the system will pick
+ a good size.
+*/
+
+QSize QDeclarativeCameraCapture::resolution()
+{
+ return m_imageSettings.resolution();
+}
+
+void QDeclarativeCameraCapture::setResolution(const QSize &captureResolution)
+{
+ if (captureResolution != resolution()) {
+ m_imageSettings.setResolution(captureResolution);
+ m_capture->setEncodingSettings(m_imageSettings);
+ emit resolutionChanged(captureResolution);
+ }
+}
+
+QCameraImageCapture::Error QDeclarativeCameraCapture::error() const
+{
+ return m_capture->error();
+}
+
+
+/*!
+ \qmlproperty size CameraCapture::errorString
+ \property QDeclarativeCameraCapture::errorString
+
+ The last capture related error message.
+*/
+QString QDeclarativeCameraCapture::errorString() const
+{
+ return m_capture->errorString();
+}
+
+void QDeclarativeCameraCapture::setMetadata(const QString &key, const QVariant &value)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(value);
+ //m_capture->setExtendedMetaData(key, value);
+}
+
+/*!
+ \qmlsignal CameraCapture::onCaptureFailed(message)
+ \fn QDeclarativeCameraCapture::captureFailed(const QString &message)
+
+ This handler is called when an error occurs during capture. A descriptive message is available in \a message.
+*/
+
+/*!
+ \qmlsignal CameraCapture::onImageCaptured(preview)
+ \fn QDeclarativeCameraCapture::imageCaptured(const QString &preview)
+
+ This handler is called when an image has been captured but not yet saved to the filesystem. The \a preview
+ parameter can be used as the URL supplied to an Image element.
+
+ \sa onImageSaved
+*/
+
+/*!
+ \qmlsignal CameraCapture::onImageSaved(path)
+ \fn QDeclarativeCameraCapture::imageSaved(const QString &path)
+
+ This handler is called after the image has been written to the filesystem. The \a path is a local file path, not a URL.
+
+ \sa onImageCaptured
+*/
+
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativecameracapture_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecameracapture_p.h b/src/imports/multimedia/qdeclarativecameracapture_p.h
new file mode 100644
index 000000000..ec464a098
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameracapture_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERACAPTURE_H
+#define QDECLARATIVECAMERACAPTURE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qcamera.h>
+#include <qcameraimagecapture.h>
+#include <qmediaencodersettings.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCamera;
+
+class QDeclarativeCameraCapture : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool ready READ isReadyForCapture NOTIFY readyForCaptureChanged)
+ Q_PROPERTY(QString capturedImagePath READ capturedImagePath NOTIFY imageSaved)
+ Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY captureFailed)
+
+public:
+ ~QDeclarativeCameraCapture();
+
+ bool isReadyForCapture() const;
+
+ QSize resolution();
+
+ QString capturedImagePath() const;
+ QCameraImageCapture::Error error() const;
+ QString errorString() const;
+
+public Q_SLOTS:
+ void capture();
+ void captureToLocation(const QString &location);
+ void cancelCapture();
+
+ void setResolution(const QSize &resolution);
+ void setMetadata(const QString &key, const QVariant &value);
+
+Q_SIGNALS:
+ void readyForCaptureChanged(bool);
+
+ void imageExposed();
+ void imageCaptured(const QString &preview);
+ void imageMetadataAvailable(const QString &key, const QVariant &value);
+ void imageSaved(const QString &path);
+ void captureFailed(const QString &message);
+
+ void resolutionChanged(const QSize &);
+
+private slots:
+ void _q_imageCaptured(int, const QImage&);
+ void _q_imageSaved(int, const QString&);
+ void _q_imageMetadataAvailable(int, const QString &, const QVariant &);
+ void _q_captureFailed(int, QCameraImageCapture::Error, const QString&);
+
+private:
+ friend class QDeclarativeCamera;
+ QDeclarativeCameraCapture(QCamera *camera, QObject *parent = 0);
+
+ QCamera *m_camera;
+ QCameraImageCapture *m_capture;
+ QImageEncoderSettings m_imageSettings;
+ QString m_capturedImagePath;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraCapture))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativecameraexposure.cpp b/src/imports/multimedia/qdeclarativecameraexposure.cpp
new file mode 100644
index 000000000..c7a8335b0
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameraexposure.cpp
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecameraexposure_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass CameraExposure QDeclarativeCameraExposure
+ \since 4.0
+ \brief The CameraExposure element provides interface for exposure related camera settings.
+ \ingroup qml-multimedia
+
+ This element is part of the \bold{Qt.multimediakit 4.0} module.
+
+ It should not be constructed separately but provided by Camera.exposure.
+
+ \qml
+ import QtQuick 2.0
+ import Qt.multimediakit 4.0
+
+ Camera {
+ id: camera
+
+ exposure.exposureCompensation: -1.0
+ exposure.exposureMode: Camera.ExposurePortrait
+ }
+
+ \endqml
+*/
+
+/*!
+ \class QDeclarativeCameraExposure
+ \brief The CameraExposure element provides interface for exposure related camera settings.
+*/
+
+/*!
+ Construct a declarative camera exposure object using \a parent object.
+ */
+QDeclarativeCameraExposure::QDeclarativeCameraExposure(QCamera *camera, QObject *parent) :
+ QObject(parent)
+{
+ m_exposure = camera->exposure();
+
+ connect(m_exposure, SIGNAL(isoSensitivityChanged(int)), this, SIGNAL(isoSensitivityChanged(int)));
+ connect(m_exposure, SIGNAL(apertureChanged(qreal)), this, SIGNAL(apertureChanged(qreal)));
+ connect(m_exposure, SIGNAL(shutterSpeedChanged(qreal)), this, SIGNAL(shutterSpeedChanged(qreal)));
+
+ connect(m_exposure, SIGNAL(exposureCompensationChanged(qreal)), this, SIGNAL(exposureCompensationChanged(qreal)));
+}
+
+QDeclarativeCameraExposure::~QDeclarativeCameraExposure()
+{
+}
+
+/*!
+ \qmlproperty real CameraExposure::exposureCompensation
+ \property QDeclarativeCameraExposure::exposureCompensation
+
+ Adjustment for the automatically calculated exposure. The value is
+ in EV units.
+ */
+qreal QDeclarativeCameraExposure::exposureCompensation() const
+{
+ return m_exposure->exposureCompensation();
+}
+
+void QDeclarativeCameraExposure::setExposureCompensation(qreal ev)
+{
+ m_exposure->setExposureCompensation(ev);
+}
+
+/*!
+ \qmlproperty real CameraExposure::isoSensitivity
+ \property QDeclarativeCameraExposure::iso
+
+ The sensor's ISO sensitivity.
+ */
+int QDeclarativeCameraExposure::isoSensitivity() const
+{
+ return m_exposure->isoSensitivity();
+}
+
+/*!
+ \qmlproperty real CameraExposure::shutterSpeed
+ \property QDeclarativeCameraExposure::shutterSpeed
+
+ The camera's shutter speed, in seconds.
+*/
+qreal QDeclarativeCameraExposure::shutterSpeed() const
+{
+ return m_exposure->shutterSpeed();
+}
+
+/*!
+ \qmlproperty real CameraExposure::aperture
+ \property QDeclarativeCameraExposure::aperture
+
+ The lens aperture as an F number (the ratio of the focal length to effective aperture diameter).
+*/
+qreal QDeclarativeCameraExposure::aperture() const
+{
+ return m_exposure->aperture();
+}
+
+int QDeclarativeCameraExposure::manualIsoSensitivity() const
+{
+ return m_manualIso;
+}
+
+void QDeclarativeCameraExposure::setManualIsoSensitivity(int iso)
+{
+ m_manualIso = iso;
+ if (iso > 0)
+ m_exposure->setManualIsoSensitivity(iso);
+ else
+ m_exposure->setAutoIsoSensitivity();
+
+ emit manualIsoSensitivityChanged(iso);
+}
+
+qreal QDeclarativeCameraExposure::manualShutterSpeed() const
+{
+ return m_manualShutterSpeed;
+}
+
+void QDeclarativeCameraExposure::setManualShutterSpeed(qreal speed)
+{
+ m_manualShutterSpeed = speed;
+ if (speed > 0)
+ m_exposure->setManualShutterSpeed(speed);
+ else
+ m_exposure->setAutoShutterSpeed();
+
+ emit manualShutterSpeedChanged(speed);
+}
+
+qreal QDeclarativeCameraExposure::manualAperture() const
+{
+ return m_manualAperture;
+}
+
+void QDeclarativeCameraExposure::setManualAperture(qreal aperture)
+{
+ m_manualAperture = aperture;
+ if (aperture > 0)
+ m_exposure->setManualAperture(aperture);
+ else
+ m_exposure->setAutoAperture();
+
+ emit manualApertureChanged(aperture);
+}
+
+/*!
+ Turn on auto aperture. The manual aperture value is reset to -1.0
+ */
+void QDeclarativeCameraExposure::setAutoAperture()
+{
+ setManualAperture(-1.0);
+}
+
+/*!
+ Turn on auto shutter speed. The manual shutter speed value is reset to -1.0
+ */
+void QDeclarativeCameraExposure::setAutoShutterSpeed()
+{
+ setManualShutterSpeed(-1.0);
+}
+
+/*!
+ Turn on auto ISO sensitivity. The manual ISO value is reset to -1.
+ */
+void QDeclarativeCameraExposure::setAutoIsoSensitivity()
+{
+ setManualIsoSensitivity(-1);
+}
+
+/*!
+ \qmlproperty enumeration CameraExposure::exposureMode
+ \property QDeclarativeCameraExposure::exposureMode
+
+ \table
+ \header \o Value \o Description
+ \row \o Camera.ExposureManual \o Manual mode.
+ \row \o Camera.ExposureAuto \o Automatic mode.
+ \row \o Camera.ExposureNight \o Night mode.
+ \row \o Camera.ExposureBacklight \o Backlight exposure mode.
+ \row \o Camera.ExposureSpotlight \o Spotlight exposure mode.
+ \row \o Camera.ExposureSports \o Spots exposure mode.
+ \row \o Camera.ExposureSnow \o Snow exposure mode.
+ \row \o Camera.ExposureBeach \o Beach exposure mode.
+ \row \o Camera.ExposureLargeAperture \o Use larger aperture with small depth of field.
+ \row \o Camera.ExposureSmallAperture \o Use smaller aperture.
+ \row \o Camera.ExposurePortrait \o Portrait exposure mode.
+ \row \o Camera.ExposureModeVendor \o The base value for device specific exposure modes.
+ \endtable
+*/
+
+QDeclarativeCamera::ExposureMode QDeclarativeCameraExposure::exposureMode() const
+{
+ return QDeclarativeCamera::ExposureMode(m_exposure->exposureMode());
+}
+
+void QDeclarativeCameraExposure::setExposureMode(QDeclarativeCamera::ExposureMode mode)
+{
+ if (exposureMode() != mode) {
+ m_exposure->setExposureMode(QCameraExposure::ExposureMode(mode));
+ emit exposureModeChanged(exposureMode());
+ }
+}
+
+/*!
+ \qmlsignal CameraExposure::exposureModeChanged(CameraExposure::ExposureMode)
+ \fn void QDeclarativeCameraExposure::exposureModeChanged(QDeclarativeCamera::ExposureMode)
+*/
+
+
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativecameraexposure_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecameraexposure_p.h b/src/imports/multimedia/qdeclarativecameraexposure_p.h
new file mode 100644
index 000000000..d4411ad54
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameraexposure_p.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERAEXPOSURE_H
+#define QDECLARATIVECAMERAEXPOSURE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qcamera.h>
+#include <qcameraexposure.h>
+#include <qdeclarativecamera_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCamera;
+
+class QDeclarativeCameraExposure : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged)
+
+ Q_PROPERTY(int iso READ isoSensitivity NOTIFY isoSensitivityChanged)
+ Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged)
+ Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged)
+
+ Q_PROPERTY(qreal manualShutterSpeed READ manualShutterSpeed WRITE setManualShutterSpeed NOTIFY manualShutterSpeedChanged)
+ Q_PROPERTY(qreal manualAperture READ manualAperture WRITE setManualAperture NOTIFY manualApertureChanged)
+ Q_PROPERTY(qreal manualIso READ manualIsoSensitivity WRITE setManualIsoSensitivity NOTIFY manualIsoSensitivityChanged)
+
+ Q_PROPERTY(QDeclarativeCamera::ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
+
+public:
+ ~QDeclarativeCameraExposure();
+
+ QDeclarativeCamera::ExposureMode exposureMode() const;
+ qreal exposureCompensation() const;
+
+ int isoSensitivity() const;
+ qreal shutterSpeed() const;
+ qreal aperture() const;
+
+ int manualIsoSensitivity() const;
+ qreal manualShutterSpeed() const;
+ qreal manualAperture() const;
+
+public Q_SLOTS:
+ void setExposureMode(QDeclarativeCamera::ExposureMode);
+ void setExposureCompensation(qreal ev);
+
+ void setManualAperture(qreal);
+ void setManualShutterSpeed(qreal);
+ void setManualIsoSensitivity(int iso);
+
+ void setAutoAperture();
+ void setAutoShutterSpeed();
+ void setAutoIsoSensitivity();
+
+Q_SIGNALS:
+ void isoSensitivityChanged(int);
+ void apertureChanged(qreal);
+ void shutterSpeedChanged(qreal);
+
+ void manualIsoSensitivityChanged(int);
+ void manualApertureChanged(qreal);
+ void manualShutterSpeedChanged(qreal);
+
+ void exposureCompensationChanged(qreal);
+ void exposureModeChanged(QDeclarativeCamera::ExposureMode);
+
+private:
+ friend class QDeclarativeCamera;
+ QDeclarativeCameraExposure(QCamera *camera, QObject *parent = 0);
+
+ QCameraExposure *m_exposure;
+ int m_manualIso;
+ qreal m_manualAperture;
+ qreal m_manualShutterSpeed;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraExposure))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativecameraflash.cpp b/src/imports/multimedia/qdeclarativecameraflash.cpp
new file mode 100644
index 000000000..6150c6f5b
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameraflash.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecameraflash_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass CameraFlash QDeclarativeCameraFlash
+ \since 4.0
+ \brief The CameraFlash element provides interface for flash related camera settings.
+ \ingroup qml-multimedia
+
+ This element is part of the \bold{Qt.multimediakit 4.0} module.
+
+ It should not be constructed separately but provided by Camera.flash.
+
+ \qml
+ import QtQuick 2.0
+ import Qt.multimediakit 4.0
+
+ Camera {
+ id: camera
+
+ exposure.exposureCompensation: -1.0
+ flash.mode: Camera.FlashRedEyeReduction
+ }
+
+ \endqml
+*/
+
+/*!
+ \class QDeclarativeCameraFlash
+ \internal
+ \brief The CameraFlash element provides interface for flash related camera settings.
+*/
+
+/*!
+ Construct a declarative camera flash object using \a parent object.
+ */
+QDeclarativeCameraFlash::QDeclarativeCameraFlash(QCamera *camera, QObject *parent) :
+ QObject(parent)
+{
+ m_exposure = camera->exposure();
+ connect(m_exposure, SIGNAL(flashReady(bool)), this, SIGNAL(flashReady(bool)));
+}
+
+QDeclarativeCameraFlash::~QDeclarativeCameraFlash()
+{
+}
+
+/*!
+ \qmlproperty bool QDeclarativeCameraFlash::ready
+ \property bool QDeclarativeCameraFlash::ready
+
+ Indicates flash is charged.
+*/
+bool QDeclarativeCameraFlash::isFlashReady() const
+{
+ return m_exposure->isFlashReady();
+}
+
+/*!
+ \qmlproperty enumeration CameraExposure::flashMode
+ \property QDeclarativeCameraFlash::flashMode
+
+ \table
+ \header \o Value \o Description
+ \row \o Camera.FlashOff \o Flash is Off.
+ \row \o Camera.FlashOn \o Flash is On.
+ \row \o Camera.FlashAuto \o Automatic flash.
+ \row \o Camera.FlashRedEyeReduction \o Red eye reduction flash.
+ \row \o Camera.FlashFill \o Use flash to fillin shadows.
+ \row \o Camera.FlashTorch \o Constant light source, useful for focusing and video capture.
+ \row \o Camera.FlashSlowSyncFrontCurtain
+ \o Use the flash in conjunction with a slow shutter speed.
+ This mode allows better exposure of distant objects and/or motion blur effect.
+ \row \o Camera.FlashSlowSyncRearCurtain
+ \o The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
+ \row \o Camera.FlashManual \o Flash power is manually set.
+ \endtable
+
+*/
+int QDeclarativeCameraFlash::flashMode() const
+{
+ return m_exposure->flashMode();
+}
+
+void QDeclarativeCameraFlash::setFlashMode(int mode)
+{
+ if (m_exposure->flashMode() != mode) {
+ m_exposure->setFlashMode(QCameraExposure::FlashModes(mode));
+ emit flashModeChanged(mode);
+ }
+}
+
+/*!
+ \qmlsignal CameraExposure::flashModeChanged(int)
+ \fn void QDeclarativeCameraFlash::flashModeChanged(int)
+*/
+
+/*!
+ \qmlsignal CameraExposure::flashReady(bool)
+ \fn void QDeclarativeCameraFlash::flashReady(bool)
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativecameraflash_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecameraflash_p.h b/src/imports/multimedia/qdeclarativecameraflash_p.h
new file mode 100644
index 000000000..893c77d29
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameraflash_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERAFLASH_H
+#define QDECLARATIVECAMERAFLASH_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qcamera.h>
+#include <qcameraexposure.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCamera;
+
+class QDeclarativeCameraFlash : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool ready READ isFlashReady NOTIFY flashReady)
+ Q_PROPERTY(int mode READ flashMode WRITE setFlashMode NOTIFY flashModeChanged)
+public:
+ ~QDeclarativeCameraFlash();
+
+ int flashMode() const;
+ bool isFlashReady() const;
+
+public Q_SLOTS:
+ void setFlashMode(int);
+
+Q_SIGNALS:
+ void flashReady(bool status);
+ void flashModeChanged(int);
+
+private:
+ friend class QDeclarativeCamera;
+ QDeclarativeCameraFlash(QCamera *camera, QObject *parent = 0);
+
+ QCameraExposure *m_exposure;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraFlash))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativecamerafocus.cpp b/src/imports/multimedia/qdeclarativecamerafocus.cpp
new file mode 100644
index 000000000..c356d4fd6
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamerafocus.cpp
@@ -0,0 +1,259 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecamerafocus_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass CameraFocus QDeclarativeCameraFocus
+ \since 4.0
+ \brief The CameraFocus element provides interface for focus related camera settings.
+ \ingroup qml-multimedia
+
+ This element is part of the \bold{Qt.multimediakit 4.0} module.
+
+ It should not be constructed separately but provided by Camera.focus.
+
+ \qml
+ import QtQuick 2.0
+ import Qt.multimediakit 4.0
+
+ Camera {
+ id: camera
+
+ focus {
+ focusMode: Camera.FocusMacro
+ focusPointMode: Camera.FocusPointCustom
+ customFocusPoint: Qt.point(0.2, 0.2) //focus to top-left corner
+ }
+ }
+
+ \endqml
+*/
+
+/*!
+ \class QDeclarativeCameraFocus
+ \brief The CameraFocus element provides interface for focus related camera settings.
+*/
+
+/*!
+ Construct a declarative camera focus object using \a parent object.
+ */
+
+QDeclarativeCameraFocus::QDeclarativeCameraFocus(QCamera *camera, QObject *parent) :
+ QObject(parent)
+{
+ m_focus = camera->focus();
+ m_focusZones = new FocusZonesModel(this);
+
+ updateFocusZones();
+
+ connect(m_focus, SIGNAL(focusZonesChanged()), SLOT(updateFocusZones()));
+}
+
+QDeclarativeCameraFocus::~QDeclarativeCameraFocus()
+{
+}
+
+
+/*!
+ \qmlproperty Camera::FocusModes CameraFocus::focusMode
+ \property QDeclarativeCameraFocus::focusMode
+
+ The current camera focus mode.
+
+ It's possible to combine multiple Camera::FocusMode values,
+ for example Camera.FocusMacro + Camera.FocusContinuous.
+*/
+QDeclarativeCamera::FocusModes QDeclarativeCameraFocus::focusMode() const
+{
+ return QDeclarativeCamera::FocusModes(m_focus->focusMode());
+}
+
+bool QDeclarativeCameraFocus::isFocusModeSupported(QDeclarativeCamera::FocusModes mode) const
+{
+ return m_focus->isFocusModeSupported(QCameraFocus::FocusMode(int(mode)));
+}
+
+void QDeclarativeCameraFocus::setFocusMode(QDeclarativeCamera::FocusModes mode)
+{
+ m_focus->setFocusMode(QCameraFocus::FocusMode(int(mode)));
+}
+
+/*!
+ \qmlproperty CameraFocus::FocusPointMode CameraFocus::focusPointMode
+ \property QDeclarativeCameraFocus::focusPointMode
+
+ The current camera focus point mode.
+*/
+QDeclarativeCamera::FocusPointMode QDeclarativeCameraFocus::focusPointMode() const
+{
+ return QDeclarativeCamera::FocusPointMode(m_focus->focusPointMode());
+}
+
+void QDeclarativeCameraFocus::setFocusPointMode(QDeclarativeCamera::FocusPointMode mode)
+{
+ if (mode != focusPointMode()) {
+ m_focus->setFocusPointMode(QCameraFocus::FocusPointMode(mode));
+ emit focusPointModeChanged(focusPointMode());
+ }
+}
+
+bool QDeclarativeCameraFocus::isFocusPointModeSupported(QDeclarativeCamera::FocusPointMode mode) const
+{
+ return m_focus->isFocusPointModeSupported(QCameraFocus::FocusPointMode(mode));
+}
+
+/*!
+ \qmlproperty QPointF CameraFocus::customFocusPoint
+ \property QDeclarativeCameraFocus::customFocusPoint
+
+ Position of custom focus point, in relative frame coordinates:
+ QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center.
+
+ Custom focus point is used only in FocusPointCustom focus mode.
+*/
+
+QPointF QDeclarativeCameraFocus::customFocusPoint() const
+{
+ return m_focus->customFocusPoint();
+}
+
+void QDeclarativeCameraFocus::setCustomFocusPoint(const QPointF &point)
+{
+ if (point != customFocusPoint()) {
+ m_focus->setCustomFocusPoint(point);
+ emit customFocusPointChanged(customFocusPoint());
+ }
+}
+
+/*!
+ \qmlproperty QPointF CameraFocus::focusZones
+ \property QDeclarativeCameraFocus::focusZones
+
+ List of current camera focus zones,
+ each including area specified in the same coordinates as \l customFocusPoint
+ and zone status.
+
+ \qml
+
+ VideoOutput {
+ id: viewfinder
+ source: camera
+
+ //display focus areas on camera viewfinder:
+ Repeater {
+ model: camera.focus.focusZones
+
+ Rectangle {
+ border {
+ width: 2
+ color: status == CameraFocus.Focused ? "green" : "white"
+ }
+ color: "transparent"
+
+ x: area.x * viewfinder.width
+ y: area.y * viewfinder.height
+ width: area.width * viewfinder.width
+ height: area.height * viewfinder.height
+ }
+ }
+ }
+ \endqml
+*/
+
+QAbstractListModel *QDeclarativeCameraFocus::focusZones() const
+{
+ return m_focusZones;
+}
+
+/*! \internal */
+void QDeclarativeCameraFocus::updateFocusZones()
+{
+ m_focusZones->setFocusZones(m_focus->focusZones());
+}
+
+
+FocusZonesModel::FocusZonesModel(QObject *parent)
+ :QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[StatusRole] = "status";
+ roles[AreaRole] = "area";
+ setRoleNames(roles);
+}
+
+int FocusZonesModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent == QModelIndex())
+ return m_focusZones.count();
+
+ return 0;
+}
+
+QVariant FocusZonesModel::data(const QModelIndex &index, int role) const
+{
+ if (index.row() < 0 || index.row() > m_focusZones.count())
+ return QVariant();
+
+ QCameraFocusZone zone = m_focusZones.value(index.row());
+
+ if (role == StatusRole)
+ return zone.status();
+
+ if (role == AreaRole)
+ return zone.area();
+
+ return QVariant();
+}
+
+void FocusZonesModel::setFocusZones(const QCameraFocusZoneList &zones)
+{
+ beginResetModel();
+ m_focusZones = zones;
+ endResetModel();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativecamerafocus_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecamerafocus_p.h b/src/imports/multimedia/qdeclarativecamerafocus_p.h
new file mode 100644
index 000000000..f6dd872f6
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamerafocus_p.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERAFOCUS_H
+#define QDECLARATIVECAMERAFOCUS_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qabstractitemmodel.h>
+#include <qcamera.h>
+#include <qcamerafocus.h>
+#include "qdeclarativecamera_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class FocusZonesModel;
+class QDeclarativeCamera;
+
+class QDeclarativeCameraFocus : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeCamera::FocusModes focusMode READ focusMode WRITE setFocusMode NOTIFY focusModeChanged)
+ Q_PROPERTY(QDeclarativeCamera::FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode NOTIFY focusPointModeChanged)
+ Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint NOTIFY customFocusPointChanged)
+ Q_PROPERTY(QObject *focusZones READ focusZones CONSTANT)
+public:
+ ~QDeclarativeCameraFocus();
+
+ QDeclarativeCamera::FocusModes focusMode() const;
+ QDeclarativeCamera::FocusPointMode focusPointMode() const;
+ QPointF customFocusPoint() const;
+
+ QAbstractListModel *focusZones() const;
+
+ Q_INVOKABLE bool isFocusModeSupported(QDeclarativeCamera::FocusModes mode) const;
+ Q_INVOKABLE bool isFocusPointModeSupported(QDeclarativeCamera::FocusPointMode) const;
+
+public Q_SLOTS:
+ void setFocusMode(QDeclarativeCamera::FocusModes);
+ void setFocusPointMode(QDeclarativeCamera::FocusPointMode mode);
+ void setCustomFocusPoint(const QPointF &point);
+
+Q_SIGNALS:
+ void focusModeChanged(QDeclarativeCamera::FocusModes);
+ void focusPointModeChanged(QDeclarativeCamera::FocusPointMode);
+ void customFocusPointChanged(const QPointF &);
+
+private Q_SLOTS:
+ void updateFocusZones();
+
+private:
+ friend class QDeclarativeCamera;
+ QDeclarativeCameraFocus(QCamera *camera, QObject *parent = 0);
+
+ QCameraFocus *m_focus;
+ FocusZonesModel *m_focusZones;
+};
+
+class FocusZonesModel : public QAbstractListModel
+{
+Q_OBJECT
+public:
+ enum FocusZoneRoles {
+ StatusRole = Qt::UserRole + 1,
+ AreaRole
+ };
+
+ FocusZonesModel(QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+public slots:
+ void setFocusZones(const QCameraFocusZoneList &zones);
+
+private:
+ QCameraFocusZoneList m_focusZones;
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraFocus))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativecameraimageprocessing.cpp b/src/imports/multimedia/qdeclarativecameraimageprocessing.cpp
new file mode 100644
index 000000000..75e942d72
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameraimageprocessing.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecameraimageprocessing_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeCameraImageProcessing::QDeclarativeCameraImageProcessing(QCamera *camera, QObject *parent) :
+ QObject(parent)
+{
+ m_imageProcessing = camera->imageProcessing();
+}
+
+QDeclarativeCameraImageProcessing::~QDeclarativeCameraImageProcessing()
+{
+}
+
+/*!
+ \qmlproperty enumeration CameraImageProcessing::whiteBalanceMode
+
+ \table
+ \header \o Value \o Description
+ \row \o WhiteBalanceManual \o Manual white balance. In this mode the manual white balance property value is used.
+ \row \o WhiteBalanceAuto \o Auto white balance mode.
+ \row \o WhiteBalanceSunlight \o Sunlight white balance mode.
+ \row \o WhiteBalanceCloudy \o Cloudy white balance mode.
+ \row \o WhiteBalanceShade \o Shade white balance mode.
+ \row \o WhiteBalanceTungsten \o Tungsten white balance mode.
+ \row \o WhiteBalanceFluorescent \o Fluorescent white balance mode.
+ \row \o WhiteBalanceFlash \o Flash white balance mode.
+ \row \o WhiteBalanceSunset \o Sunset white balance mode.
+ \row \o WhiteBalanceVendor \o Vendor defined white balance mode.
+ \endtable
+
+ \sa manualWhiteBalance
+*/
+/*!
+ \property QDeclarativeCameraImageProcessing::whiteBalanceMode
+
+ \sa WhiteBalanceMode
+*/
+QDeclarativeCameraImageProcessing::WhiteBalanceMode QDeclarativeCameraImageProcessing::whiteBalanceMode() const
+{
+ return WhiteBalanceMode(m_imageProcessing->whiteBalanceMode());
+}
+
+void QDeclarativeCameraImageProcessing::setWhiteBalanceMode(QDeclarativeCameraImageProcessing::WhiteBalanceMode mode) const
+{
+ if (whiteBalanceMode() != mode) {
+ m_imageProcessing->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode(mode));
+ emit whiteBalanceModeChanged(whiteBalanceMode());
+ }
+}
+
+/*!
+ \qmlproperty int CameraImageProcessing::manualWhiteBalance
+
+ The color temperature used when in manual white balance mode (WhiteBalanceManual).
+
+ \sa whiteBalanceMode
+*/
+int QDeclarativeCameraImageProcessing::manualWhiteBalance() const
+{
+ return m_imageProcessing->manualWhiteBalance();
+}
+
+void QDeclarativeCameraImageProcessing::setManualWhiteBalance(int colorTemp) const
+{
+ if (manualWhiteBalance() != colorTemp) {
+ m_imageProcessing->setManualWhiteBalance(colorTemp);
+ emit manualWhiteBalanceChanged(manualWhiteBalance());
+ }
+}
+
+/*!
+ \qmlproperty int CameraImageProcessing::contrast
+
+ Image contrast.
+ Valid contrast values range between -100 and 100, the default is 0.
+*/
+int QDeclarativeCameraImageProcessing::contrast() const
+{
+ return m_imageProcessing->contrast();
+}
+
+void QDeclarativeCameraImageProcessing::setContrast(int value)
+{
+ if (value != contrast()) {
+ m_imageProcessing->setContrast(value);
+ emit contrastChanged(contrast());
+ }
+}
+
+/*!
+ \qmlproperty int CameraImageProcessing::saturation
+
+ Image saturation.
+ Valid saturation values range between -100 and 100, the default is 0.
+*/
+int QDeclarativeCameraImageProcessing::saturation() const
+{
+ return m_imageProcessing->saturation();
+}
+
+void QDeclarativeCameraImageProcessing::setSaturation(int value)
+{
+ if (value != saturation()) {
+ m_imageProcessing->setSaturation(value);
+ emit saturationChanged(saturation());
+ }
+}
+
+/*!
+ \qmlproperty int CameraImageProcessing::sharpeningLevel
+
+ Level of sharpening applied to image.
+
+ Valid sharpening level values range between -1 for default sharpening level,
+ 0 for sharpening disabled and 100 for maximum sharpening applied.
+*/
+int QDeclarativeCameraImageProcessing::sharpeningLevel() const
+{
+ return m_imageProcessing->sharpeningLevel();
+}
+
+void QDeclarativeCameraImageProcessing::setSharpeningLevel(int value)
+{
+ if (value != sharpeningLevel()) {
+ m_imageProcessing->setSharpeningLevel(value);
+ emit sharpeningLevelChanged(sharpeningLevel());
+ }
+}
+
+/*!
+ \qmlproperty int CameraImageProcessing::denoisingLevel
+
+ Level of denoising applied to image.
+
+ Valid denoising level values range between -1 for default denoising level,
+ 0 for denoising disabled and 100 for maximum denoising applied.
+*/
+int QDeclarativeCameraImageProcessing::denoisingLevel() const
+{
+ return m_imageProcessing->denoisingLevel();
+}
+
+void QDeclarativeCameraImageProcessing::setDenoisingLevel(int value)
+{
+ if (value != denoisingLevel()) {
+ m_imageProcessing->setDenoisingLevel(value);
+ emit denoisingLevelChanged(denoisingLevel());
+ }
+}
+
+/*!
+ \qmlsignal Camera::whiteBalanceModeChanged(Camera::WhiteBalanceMode)
+*/
+
+/*!
+ \qmlsignal Camera::manualWhiteBalanceChanged(int)
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativecameraimageprocessing_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecameraimageprocessing_p.h b/src/imports/multimedia/qdeclarativecameraimageprocessing_p.h
new file mode 100644
index 000000000..b86183551
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecameraimageprocessing_p.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERAIMAGEPROCESSING_H
+#define QDECLARATIVECAMERAIMAGEPROCESSING_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qcamera.h>
+#include <qcameraimageprocessing.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCamera;
+
+class QDeclarativeCameraImageProcessing : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(WhiteBalanceMode)
+
+ Q_PROPERTY(WhiteBalanceMode whiteBalanceMode READ whiteBalanceMode WRITE setWhiteBalanceMode NOTIFY whiteBalanceModeChanged)
+ Q_PROPERTY(int manualWhiteBalance READ manualWhiteBalance WRITE setManualWhiteBalance NOTIFY manualWhiteBalanceChanged)
+ Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged)
+ Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
+ Q_PROPERTY(int sharpeningLevel READ sharpeningLevel WRITE setSharpeningLevel NOTIFY sharpeningLevelChanged)
+ Q_PROPERTY(int denoisingLevel READ denoisingLevel WRITE setDenoisingLevel NOTIFY denoisingLevelChanged)
+
+public:
+ enum WhiteBalanceMode {
+ WhiteBalanceAuto = QCameraImageProcessing::WhiteBalanceAuto,
+ WhiteBalanceManual = QCameraImageProcessing::WhiteBalanceManual,
+ WhiteBalanceSunlight = QCameraImageProcessing::WhiteBalanceSunlight,
+ WhiteBalanceCloudy = QCameraImageProcessing::WhiteBalanceCloudy,
+ WhiteBalanceShade = QCameraImageProcessing::WhiteBalanceShade,
+ WhiteBalanceTungsten = QCameraImageProcessing::WhiteBalanceTungsten,
+ WhiteBalanceFluorescent = QCameraImageProcessing::WhiteBalanceFluorescent,
+ WhiteBalanceFlash = QCameraImageProcessing::WhiteBalanceFlash,
+ WhiteBalanceSunset = QCameraImageProcessing::WhiteBalanceSunset,
+ WhiteBalanceVendor = QCameraImageProcessing::WhiteBalanceVendor
+ };
+
+ ~QDeclarativeCameraImageProcessing();
+
+ WhiteBalanceMode whiteBalanceMode() const;
+ int manualWhiteBalance() const;
+
+ int contrast() const;
+ int saturation() const;
+ int sharpeningLevel() const;
+ int denoisingLevel() const;
+
+public Q_SLOTS:
+ void setWhiteBalanceMode(QDeclarativeCameraImageProcessing::WhiteBalanceMode mode) const;
+ void setManualWhiteBalance(int colorTemp) const;
+
+ void setContrast(int value);
+ void setSaturation(int value);
+ void setSharpeningLevel(int value);
+ void setDenoisingLevel(int value);
+
+Q_SIGNALS:
+ void whiteBalanceModeChanged(QDeclarativeCameraImageProcessing::WhiteBalanceMode) const;
+ void manualWhiteBalanceChanged(int) const;
+
+ void contrastChanged(int);
+ void saturationChanged(int);
+ void sharpeningLevelChanged(int);
+ void denoisingLevelChanged(int);
+
+private:
+ friend class QDeclarativeCamera;
+ QDeclarativeCameraImageProcessing(QCamera *camera, QObject *parent = 0);
+
+ QCameraImageProcessing *m_imageProcessing;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraImageProcessing))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativecamerarecorder.cpp b/src/imports/multimedia/qdeclarativecamerarecorder.cpp
new file mode 100644
index 000000000..7328b0492
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamerarecorder.cpp
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecamerarecorder_p.h"
+
+#include <QtCore/qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeCameraRecorder::QDeclarativeCameraRecorder(QCamera *camera, QObject *parent) :
+ QObject(parent)
+{
+ m_recorder = new QMediaRecorder(camera, this);
+ connect(m_recorder, SIGNAL(stateChanged(QMediaRecorder::State)),
+ SLOT(updateRecorderState(QMediaRecorder::State)));
+ connect(m_recorder, SIGNAL(error(QMediaRecorder::Error)),
+ SLOT(updateRecorderError(QMediaRecorder::Error)));
+ connect(m_recorder, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool)));
+ connect(m_recorder, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64)));
+}
+
+QDeclarativeCameraRecorder::~QDeclarativeCameraRecorder()
+{
+}
+
+QSize QDeclarativeCameraRecorder::captureResolution()
+{
+ return m_videoSettings.resolution();
+}
+
+QString QDeclarativeCameraRecorder::audioCodec() const
+{
+ return m_audioSettings.codec();
+}
+
+QString QDeclarativeCameraRecorder::videoCodec() const
+{
+ return m_videoSettings.codec();
+}
+
+QString QDeclarativeCameraRecorder::mediaContainer() const
+{
+ return m_mediaContainer;
+}
+
+void QDeclarativeCameraRecorder::setCaptureResolution(const QSize &resolution)
+{
+ if (resolution != captureResolution()) {
+ m_videoSettings.setResolution(resolution);
+ applySettings();
+ emit captureResolutionChanged(resolution);
+ }
+}
+
+void QDeclarativeCameraRecorder::setAudioCodec(const QString &codec)
+{
+ if (codec != audioCodec()) {
+ m_audioSettings.setCodec(codec);
+ applySettings();
+ emit audioCodecChanged(codec);
+ }
+}
+
+void QDeclarativeCameraRecorder::setVideoCodec(const QString &codec)
+{
+ if (codec != videoCodec()) {
+ m_videoSettings.setCodec(codec);
+ applySettings();
+ emit videoCodecChanged(codec);
+ }
+}
+
+void QDeclarativeCameraRecorder::setMediaContainer(const QString &container)
+{
+ if (container != m_mediaContainer) {
+ m_mediaContainer = container;
+ applySettings();
+ emit mediaContainerChanged(container);
+ }
+}
+
+void QDeclarativeCameraRecorder::applySettings()
+{
+ m_recorder->setEncodingSettings(m_audioSettings,
+ m_videoSettings,
+ m_mediaContainer);
+}
+
+QMediaRecorder::Error QDeclarativeCameraRecorder::error() const
+{
+ return m_recorder->error();
+}
+
+QString QDeclarativeCameraRecorder::errorString() const
+{
+ return m_recorder->errorString();
+}
+
+QDeclarativeCameraRecorder::RecorderState QDeclarativeCameraRecorder::recorderState() const
+{
+ //paused state is not supported for camera
+ QMediaRecorder::State state = m_recorder->state();
+
+ if (state == QMediaRecorder::PausedState)
+ state = QMediaRecorder::StoppedState;
+
+ return RecorderState(state);
+}
+
+void QDeclarativeCameraRecorder::record()
+{
+ setRecorderState(RecordingState);
+}
+
+void QDeclarativeCameraRecorder::stop()
+{
+ setRecorderState(StoppedState);
+}
+
+void QDeclarativeCameraRecorder::setRecorderState(QDeclarativeCameraRecorder::RecorderState state)
+{
+ if (!m_recorder)
+ return;
+
+ switch (state) {
+ case QDeclarativeCameraRecorder::RecordingState:
+ m_recorder->record();
+ break;
+ case QDeclarativeCameraRecorder::StoppedState:
+ m_recorder->stop();
+ break;
+ }
+}
+
+QString QDeclarativeCameraRecorder::outputLocation() const
+{
+ return m_recorder->outputLocation().toString();
+}
+
+void QDeclarativeCameraRecorder::setOutputLocation(const QUrl &location)
+{
+ m_recorder->setOutputLocation(location);
+}
+
+qint64 QDeclarativeCameraRecorder::duration() const
+{
+ return m_recorder->duration();
+}
+
+bool QDeclarativeCameraRecorder::isMuted() const
+{
+ return m_recorder->isMuted();
+}
+
+void QDeclarativeCameraRecorder::setMuted(bool muted)
+{
+ m_recorder->setMuted(muted);
+}
+
+void QDeclarativeCameraRecorder::setMetadata(const QString &key, const QVariant &value)
+{
+ m_recorder->setExtendedMetaData(key, value);
+}
+
+void QDeclarativeCameraRecorder::updateRecorderState(QMediaRecorder::State state)
+{
+ if (state == QMediaRecorder::PausedState)
+ state = QMediaRecorder::StoppedState;
+
+ if (state == QMediaRecorder::StoppedState) {
+ QString location = outputLocation();
+ if (!location.isEmpty())
+ emit outputLocationChanged(location);
+ }
+
+ emit recorderStateChanged(RecorderState(state));
+}
+
+void QDeclarativeCameraRecorder::updateRecorderError(QMediaRecorder::Error errorCode)
+{
+ qWarning() << "QMediaRecorder error:" << errorString();
+ emit error(errorCode);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativecamerarecorder_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecamerarecorder_p.h b/src/imports/multimedia/qdeclarativecamerarecorder_p.h
new file mode 100644
index 000000000..9164af990
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamerarecorder_p.h
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERARECORDER_H
+#define QDECLARATIVECAMERARECORDER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qcamera.h>
+#include <qmediarecorder.h>
+#include <qmediaencodersettings.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCamera;
+
+class QDeclarativeCameraRecorder : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(RecorderState)
+
+ Q_PROPERTY(RecorderState recorderState READ recorderState WRITE setRecorderState NOTIFY recorderStateChanged)
+ Q_PROPERTY(QSize resolution READ captureResolution WRITE setCaptureResolution NOTIFY captureResolutionChanged)
+
+ Q_PROPERTY(QString videoCodec READ videoCodec WRITE setVideoCodec NOTIFY videoCodecChanged)
+ Q_PROPERTY(QString audioCodec READ audioCodec WRITE setAudioCodec NOTIFY audioCodecChanged)
+ Q_PROPERTY(QString mediaContainer READ mediaContainer WRITE setMediaContainer NOTIFY mediaContainerChanged)
+
+ Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
+ Q_PROPERTY(QString outputLocation READ outputLocation WRITE setOutputLocation NOTIFY outputLocationChanged)
+ Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY error)
+
+public:
+ enum RecorderState
+ {
+ StoppedState = QMediaRecorder::StoppedState,
+ RecordingState = QMediaRecorder::RecordingState
+ };
+
+ ~QDeclarativeCameraRecorder();
+
+ RecorderState recorderState() const;
+
+ QSize captureResolution();
+
+ QString outputLocation() const;
+ qint64 duration() const;
+ bool isMuted() const;
+
+ QString audioCodec() const;
+ QString videoCodec() const;
+ QString mediaContainer() const;
+
+ QMediaRecorder::Error error() const;
+ QString errorString() const;
+
+public Q_SLOTS:
+ void setOutputLocation(const QUrl &location);
+
+ void record();
+ void stop();
+ void setRecorderState(QDeclarativeCameraRecorder::RecorderState state);
+
+ void setMuted(bool muted);
+ void setMetadata(const QString &key, const QVariant &value);
+
+ void setCaptureResolution(const QSize &resolution);
+ void setAudioCodec(const QString &codec);
+ void setVideoCodec(const QString &codec);
+ void setMediaContainer(const QString &container);
+
+Q_SIGNALS:
+ void recorderStateChanged(QDeclarativeCameraRecorder::RecorderState state);
+ void durationChanged(qint64 duration);
+ void mutedChanged(bool muted);
+ void outputLocationChanged(const QString &location);
+
+ void error(QMediaRecorder::Error errorCode);
+
+ void metaDataAvailableChanged(bool available);
+ void metaDataWritableChanged(bool writable);
+ void metaDataChanged();
+
+ void captureResolutionChanged(const QSize &);
+ void audioCodecChanged(const QString &codec);
+ void videoCodecChanged(const QString &codec);
+ void mediaContainerChanged(const QString &container);
+
+private slots:
+ void updateRecorderState(QMediaRecorder::State);
+ void updateRecorderError(QMediaRecorder::Error);
+
+private:
+ friend class QDeclarativeCamera;
+ QDeclarativeCameraRecorder(QCamera *camera, QObject *parent = 0);
+
+ void applySettings();
+
+ QMediaRecorder *m_recorder;
+
+ QAudioEncoderSettings m_audioSettings;
+ QVideoEncoderSettings m_videoSettings;
+ QString m_mediaContainer;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraRecorder))
+
+QT_END_HEADER
+
+#endif