summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJochen Seemann <seemann.jochen@gmail.com>2016-08-22 23:19:14 +0200
committerYoann Lopes <yoann.lopes@qt.io>2016-08-31 08:51:05 +0000
commit2d1c728c4c4522d0e405da514b6ce1a3580239f5 (patch)
treeec67a88eb57c1e40f37d34a65e4fcfc44cc12609
parent338078153449374e07d33c312ef1a9d093acf279 (diff)
adding property CameraCapture::supportedResolutions
This change adds the new property supportedResolutions to expose the same functionality to QML as QCameraImageCapture::supportedResolutions provides for C++. Exposing as QML property allows us to easily display the resolutions in list-based elements like ListView. Task-number: QTBUG-45289 Change-Id: Ica7206ec1daa36298a761d659d1c0b05d13562ec Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
-rw-r--r--src/imports/multimedia/multimedia.cpp4
-rw-r--r--src/imports/multimedia/qdeclarativecameracapture.cpp32
-rw-r--r--src/imports/multimedia/qdeclarativecameracapture_p.h4
3 files changed, 40 insertions, 0 deletions
diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp
index 872b2ae61..d249747b7 100644
--- a/src/imports/multimedia/multimedia.cpp
+++ b/src/imports/multimedia/multimedia.cpp
@@ -140,6 +140,10 @@ public:
qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 2>(uri, 5, 7, "CameraImageProcessing",
trUtf8("CameraImageProcessing is provided by Camera"));
+ // 5.9 types
+ qmlRegisterUncreatableType<QDeclarativeCameraCapture, 1>(uri, 5, 9, "CameraCapture",
+ trUtf8("CameraCapture is provided by Camera"));
+
qmlRegisterType<QDeclarativeMediaMetaData>();
qmlRegisterType<QAbstractVideoFilter>();
}
diff --git a/src/imports/multimedia/qdeclarativecameracapture.cpp b/src/imports/multimedia/qdeclarativecameracapture.cpp
index 32f3cfc37..22d87ec22 100644
--- a/src/imports/multimedia/qdeclarativecameracapture.cpp
+++ b/src/imports/multimedia/qdeclarativecameracapture.cpp
@@ -112,6 +112,9 @@ QDeclarativeCameraCapture::QDeclarativeCameraCapture(QCamera *camera, QObject *p
connect(m_capture, SIGNAL(error(int,QCameraImageCapture::Error,QString)),
this, SLOT(_q_captureFailed(int,QCameraImageCapture::Error,QString)));
+ connect(m_camera, SIGNAL(statusChanged(QCamera::Status)),
+ this, SLOT(_q_cameraStatusChanged(QCamera::Status)));
+
QMediaService *service = camera->service();
m_metadataWriterControl = service ? service->requestControl<QMetaDataWriterControl*>() : 0;
}
@@ -239,6 +242,15 @@ void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Er
qWarning() << "QCameraImageCapture error:" << message;
emit captureFailed(id, message);
}
+
+void QDeclarativeCameraCapture::_q_cameraStatusChanged(QCamera::Status status)
+{
+ if (status != QCamera::UnloadedStatus && status != QCamera::LoadedStatus &&
+ status != QCamera::ActiveStatus)
+ return;
+
+ emit supportedResolutionsChanged();
+}
/*!
\property QDeclarativeCameraCapture::resolution
@@ -251,6 +263,8 @@ void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Er
This property holds the resolution/size of the image to be captured.
If empty, the system chooses the appropriate resolution.
+
+ \sa supportedResolutions
*/
QSize QDeclarativeCameraCapture::resolution()
@@ -289,6 +303,24 @@ QString QDeclarativeCameraCapture::errorString() const
}
/*!
+ \qmlproperty list<size> QtMultimedia::CameraCapture::supportedResolutions
+
+ This property holds a list of resolutions which are supported for capturing.
+ The information can be used to set a valid \e resolution. If the camera isn't
+ loaded, the list will be empty.
+
+ \since 5.9
+ \sa resolution
+ */
+QVariantList QDeclarativeCameraCapture::supportedResolutions()
+{
+ QVariantList supportedResolutions;
+ for (const QSize &res : m_capture->supportedResolutions())
+ supportedResolutions.append(QVariant(res));
+ return supportedResolutions;
+}
+
+/*!
\qmlmethod QtMultimedia::CameraCapture::setMetadata(key, value)
diff --git a/src/imports/multimedia/qdeclarativecameracapture_p.h b/src/imports/multimedia/qdeclarativecameracapture_p.h
index 06cb1b8f1..1b8066a4e 100644
--- a/src/imports/multimedia/qdeclarativecameracapture_p.h
+++ b/src/imports/multimedia/qdeclarativecameracapture_p.h
@@ -69,6 +69,7 @@ class QDeclarativeCameraCapture : public QObject
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)
+ Q_PROPERTY(QVariantList supportedResolutions READ supportedResolutions NOTIFY supportedResolutionsChanged REVISION 1)
public:
~QDeclarativeCameraCapture();
@@ -80,6 +81,7 @@ public:
QString capturedImagePath() const;
QCameraImageCapture::Error error() const;
QString errorString() const;
+ QVariantList supportedResolutions();
public Q_SLOTS:
int capture();
@@ -99,12 +101,14 @@ Q_SIGNALS:
void captureFailed(int requestId, const QString &message);
void resolutionChanged(const QSize &);
+ void supportedResolutionsChanged();
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&);
+ void _q_cameraStatusChanged(QCamera::Status status);
private:
friend class QDeclarativeCamera;