summaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-04-15 10:18:43 +0200
committerLars Knoll <lars.knoll@qt.io>2021-04-19 11:06:54 +0000
commit0ca672235b097937f32d2960e4a8ca3e323074db (patch)
treec7990c15714e373a8271c6ab168a55207098fcba /src/imports
parent8d0cd064a0272b0d7a005738f0a08c5e3b8e7281 (diff)
New QML API for image capturing
Adjust the QML API for image capturing to fit with the new handling of capture sessions. Simplify some things and avoid using a wrapper class to the largest degree by inheriting from QCameraImageCapture. Remove the old image capturing code. Change-Id: Ic99116f5202f2d0438fe0d048be2faa6687f0e4b Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/multimedia/CMakeLists.txt2
-rw-r--r--src/imports/multimedia/multimedia.cpp7
-rw-r--r--src/imports/multimedia/qdeclarativecamera.cpp4
-rw-r--r--src/imports/multimedia/qdeclarativecamera_p.h5
-rw-r--r--src/imports/multimedia/qdeclarativecameracapture.cpp307
-rw-r--r--src/imports/multimedia/qdeclarativecameracapture_p.h114
-rw-r--r--src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp95
-rw-r--r--src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h70
-rw-r--r--src/imports/multimedia/qdeclarativecamerarecorder_p.h2
9 files changed, 6 insertions, 600 deletions
diff --git a/src/imports/multimedia/CMakeLists.txt b/src/imports/multimedia/CMakeLists.txt
index 2a09a00cd..9ef27bab8 100644
--- a/src/imports/multimedia/CMakeLists.txt
+++ b/src/imports/multimedia/CMakeLists.txt
@@ -11,10 +11,8 @@ qt_internal_add_qml_module(declarative_multimedia
SOURCES
multimedia.cpp
qdeclarativecamera.cpp qdeclarativecamera_p.h
- qdeclarativecameracapture.cpp qdeclarativecameracapture_p.h
qdeclarativecameraexposure.cpp qdeclarativecameraexposure_p.h
qdeclarativecameraflash.cpp qdeclarativecameraflash_p.h
- qdeclarativecamerapreviewprovider.cpp qdeclarativecamerapreviewprovider_p.h
qdeclarativecamerarecorder.cpp qdeclarativecamerarecorder_p.h
qdeclarativemultimediaglobal.cpp qdeclarativemultimediaglobal_p.h
qdeclarativeplaylist.cpp qdeclarativeplaylist_p.h
diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp
index 0360a859e..a838dcf86 100644
--- a/src/imports/multimedia/multimedia.cpp
+++ b/src/imports/multimedia/multimedia.cpp
@@ -53,11 +53,12 @@
#include "qdeclarativemultimediaglobal_p.h"
#include "qdeclarativeplaylist_p.h"
#include "qdeclarativecamera_p.h"
-#include "qdeclarativecamerapreviewprovider_p.h"
#include "qdeclarativecameraexposure_p.h"
#include "qdeclarativecameraflash_p.h"
#include "qdeclarativetorch_p.h"
+#include "qquickimagepreviewprovider_p.h"
+
QML_DECLARE_TYPE(QSoundEffect)
QT_BEGIN_NAMESPACE
@@ -87,8 +88,6 @@ public:
// 6.0 types
qmlRegisterType<QDeclarativeCamera>(uri, 6, 0, "Camera");
- qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 6, 0, "CameraCapture",
- tr("CameraCapture is provided by Camera"));
qmlRegisterUncreatableType<QDeclarativeCameraRecorder>(uri, 6, 0, "CameraRecorder",
tr("CameraRecorder is provided by Camera"));
qmlRegisterUncreatableType<QDeclarativeCameraExposure>(uri, 6, 0, "CameraExposure",
@@ -111,7 +110,7 @@ public:
void initializeEngine(QQmlEngine *engine, const char *uri) override
{
Q_UNUSED(uri);
- engine->addImageProvider("camera", new QDeclarativeCameraPreviewProvider);
+ engine->addImageProvider("camera", new QQuickImagePreviewProvider);
}
};
diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp
index 626342cc6..282359efa 100644
--- a/src/imports/multimedia/qdeclarativecamera.cpp
+++ b/src/imports/multimedia/qdeclarativecamera.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qdeclarativecamera_p.h"
-#include "qdeclarativecamerapreviewprovider_p.h"
#include "qdeclarativecameraexposure_p.h"
#include "qdeclarativecameraflash_p.h"
@@ -48,6 +47,7 @@
#include <qobject.h>
#include <QMediaDeviceManager>
#include <QtQml/qqmlinfo.h>
+#include <QtQml/qqmlengine.h>
#include <QtCore/QTimer>
#include <QtGui/qevent.h>
@@ -166,7 +166,6 @@ QDeclarativeCamera::QDeclarativeCamera(QObject *parent) :
m_currentCameraInfo = QMediaDeviceManager::defaultVideoInput();
m_camera = new QCamera(m_currentCameraInfo);
- m_imageCapture = new QDeclarativeCameraCapture(&captureSession);
m_videoRecorder = new QDeclarativeCameraRecorder(&captureSession);
m_exposure = new QDeclarativeCameraExposure(m_camera);
m_flash = new QDeclarativeCameraFlash(m_camera);
@@ -181,7 +180,6 @@ QDeclarativeCamera::QDeclarativeCamera(QObject *parent) :
QDeclarativeCamera::~QDeclarativeCamera()
{
// These must be deleted before QCamera
- delete m_imageCapture;
delete m_videoRecorder;
delete m_exposure;
delete m_flash;
diff --git a/src/imports/multimedia/qdeclarativecamera_p.h b/src/imports/multimedia/qdeclarativecamera_p.h
index 5d4f68114..425c60ddf 100644
--- a/src/imports/multimedia/qdeclarativecamera_p.h
+++ b/src/imports/multimedia/qdeclarativecamera_p.h
@@ -51,13 +51,11 @@
// We mean it.
//
-#include "qdeclarativecameracapture_p.h"
#include "qdeclarativecamerarecorder_p.h"
#include <qcamera.h>
#include <qcamerainfo.h>
#include <qcameraimageprocessing.h>
-#include <qcameraimagecapture.h>
#include <qmediacapturesession.h>
#include <QtCore/qbasictimer.h>
@@ -85,7 +83,6 @@ class QDeclarativeCamera : public QObject, public QQmlParserStatus
Q_PROPERTY(Error errorCode READ errorCode NOTIFY errorChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
- 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)
@@ -171,7 +168,6 @@ public:
QDeclarativeCamera(QObject *parent = 0);
~QDeclarativeCamera();
- QDeclarativeCameraCapture *imageCapture() { return m_imageCapture; }
QDeclarativeCameraRecorder *videoRecorder() { return m_videoRecorder; }
QDeclarativeCameraExposure *exposure() { return m_exposure; }
QDeclarativeCameraFlash *flash() { return m_flash; }
@@ -232,7 +228,6 @@ private:
QCamera *m_camera;
QCameraInfo m_currentCameraInfo;
- QDeclarativeCameraCapture *m_imageCapture;
QDeclarativeCameraRecorder *m_videoRecorder;
QDeclarativeCameraExposure *m_exposure;
QDeclarativeCameraFlash *m_flash;
diff --git a/src/imports/multimedia/qdeclarativecameracapture.cpp b/src/imports/multimedia/qdeclarativecameracapture.cpp
deleted file mode 100644
index 26ee1e67c..000000000
--- a/src/imports/multimedia/qdeclarativecameracapture.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecamera_p.h"
-#include "qdeclarativecameracapture_p.h"
-#include "qdeclarativecamerapreviewprovider_p.h"
-
-#include <QtCore/qurl.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype CameraCapture
- \instantiates QDeclarativeCameraCapture
- \brief An interface for capturing camera images.
- \ingroup multimedia_qml
- \inqmlmodule QtMultimedia
- \ingroup camera_qml
-
- This type allows you to capture still images and be notified when they
- are available or saved to disk. You can adjust the resolution of the captured
- image and where the saved image should go.
-
- CameraCapture is a child of a \l Camera (as the \c imageCapture property)
- and cannot be created directly.
-
- \qml
- Item {
- width: 640
- height: 360
-
- Camera {
- id: camera
-
- imageCapture {
- onImageCaptured: {
- // Show the preview in an Image
- photoPreview.source = preview
- }
- }
- }
-
- VideoOutput {
- source: camera
- focus : visible // to receive focus and capture key events when visible
- anchors.fill: parent
-
- MouseArea {
- anchors.fill: parent;
- onClicked: camera.imageCapture.capture();
- }
- }
-
- Image {
- id: photoPreview
- }
- }
- \endqml
-
-*/
-
-QDeclarativeCameraCapture::QDeclarativeCameraCapture(QMediaCaptureSession *captureSession)
- : QObject(captureSession)
-{
- m_capture = new QCameraImageCapture(captureSession);
-
- connect(m_capture, SIGNAL(readyForCaptureChanged(bool)), this, SIGNAL(readyForCaptureChanged(bool)));
- connect(m_capture, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed(int)));
- connect(m_capture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(_q_imageCaptured(int,QImage)));
- connect(m_capture, SIGNAL(imageMetadataAvailable(int,const QMediaMetaData&)), this,
- SIGNAL(imageMetadataAvailable(int,const QMediaMetaData&)));
- 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() = default;
-
-/*!
- \property QDeclarativeCameraCapture::ready
-
- This property holds a bool value indicating whether the camera
- is ready to capture photos or not.
-
- Calling capture() while \e ready is \c false is not permitted and
- results in an error.
-*/
-
-/*!
- \qmlproperty bool QtMultimedia::CameraCapture::ready
-
- This property holds a bool value indicating whether the camera
- is ready to capture photos or not.
-
- Calling capture() while \e ready is \c false is not permitted and
- results in an error.
-*/
-bool QDeclarativeCameraCapture::isReadyForCapture() const
-{
- return m_capture->isReadyForCapture();
-}
-
-/*!
- \qmlmethod QtMultimedia::CameraCapture::capture()
-
- Start image capture. The \l imageCaptured and \l imageSaved signals will
- be emitted when the capture is complete.
-
- The image will be captured to the default system location, typically
- QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) for
- still imaged or QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)
- for video.
-
- Camera saves all the capture parameters like exposure settings or
- image processing parameters, so changes to camera parameters after
- capture() is called do not affect previous capture requests.
-
- capture() returns the capture requestId parameter, used with
- imageExposed(), imageCaptured(), imageMetadataAvailable() and imageSaved() signals.
-
- \sa ready
-*/
-int QDeclarativeCameraCapture::capture()
-{
- return m_capture->capture();
-}
-
-/*!
- \qmlmethod QtMultimedia::CameraCapture::captureToLocation(location)
-
- Start image capture to specified \a location. The \l imageCaptured and \l imageSaved signals will
- be emitted when the capture is complete.
-
- CameraCapture::captureToLocation returns the capture requestId parameter, used with
- imageExposed(), imageCaptured(), imageMetadataAvailable() and imageSaved() signals.
-
- If the application is unable to write to the location specified by \c location
- the CameraCapture will emit an error. The most likely reasons for the application
- to be unable to write to a location is that the path is wrong and the location does not exists,
- or the application does not have write permission for that location.
-*/
-int QDeclarativeCameraCapture::captureToLocation(const QString &location)
-{
- return m_capture->capture(location);
-}
-
-/*!
- \property QDeclarativeCameraCapture::capturedImagePath
-
- This property holds the location of the last captured image.
-*/
-/*!
- \qmlproperty string QtMultimedia::CameraCapture::capturedImagePath
-
- This property holds the location of the last 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(id, QLatin1String("image://camera/")+previewId);
-}
-
-void QDeclarativeCameraCapture::_q_imageSaved(int id, const QString &fileName)
-{
- m_capturedImagePath = fileName;
- emit imageSaved(id, fileName);
-}
-
-void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message)
-{
- Q_UNUSED(error);
- qWarning() << "QCameraImageCapture error:" << message;
- emit captureFailed(id, message);
-}
-
-/*!
- \property QDeclarativeCameraCapture::resolution
-
- This property holds the resolution/size of the image to be captured.
- If empty, the system chooses the appropriate resolution.
-*/
-QCameraImageCapture::Error QDeclarativeCameraCapture::error() const
-{
- return m_capture->error();
-}
-/*!
- \property QDeclarativeCameraCapture::errorString
-
- This property holds the error message related to the last capture.
-*/
-
-/*!
- \qmlproperty string QtMultimedia::CameraCapture::errorString
-
- This property holds the error message related to the last capture.
-*/
-QString QDeclarativeCameraCapture::errorString() const
-{
- return m_capture->errorString();
-}
-
-/*!
- \qmlmethod QtMultimedia::CameraCapture::setMetadata(key, value)
-
-
- Sets a particular metadata \a key to \a value for the subsequent image captures.
-
- \sa QMediaMetaData
-*/
-void QDeclarativeCameraCapture::setMetadata(QMediaMetaData::Key key, const QVariant &value)
-{
- QMediaMetaData data;
- data.insert(key, value);
- m_capture->addMetaData(data);
-}
-
-/*!
- \qmlsignal QtMultimedia::CameraCapture::captureFailed(requestId, message)
-
- This signal is emitted when an error occurs during capture with \a requestId.
- A descriptive message is available in \a message.
-
- The corresponding handler is \c onCaptureFailed.
-*/
-
-/*!
- \qmlsignal QtMultimedia::CameraCapture::imageCaptured(requestId, preview)
-
- This signal is emitted when an image with \a requestId has been captured
- but not yet saved to the filesystem. The \a preview
- parameter can be used as the URL supplied to an \l Image.
-
- The corresponding handler is \c onImageCaptured.
-
- \sa imageSaved
-*/
-
-/*!
- \qmlsignal QtMultimedia::CameraCapture::imageSaved(requestId, path)
-
- This signal is emitted after the image with \a requestId has been written to the filesystem.
- The \a path is a local file path, not a URL.
-
- The corresponding handler is \c onImageSaved.
-
- \sa imageCaptured
-*/
-
-
-/*!
- \qmlsignal QtMultimedia::CameraCapture::imageMetadataAvailable(requestId, key, value)
-
- This signal is emitted when the image with \a requestId has new metadata
- available with the key \a key and value \a value.
-
- The corresponding handler is \c onImageMetadataAvailable.
-
- \sa imageCaptured
-*/
-
-
-QT_END_NAMESPACE
-
-#include "moc_qdeclarativecameracapture_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecameracapture_p.h b/src/imports/multimedia/qdeclarativecameracapture_p.h
deleted file mode 100644
index 6ef19e941..000000000
--- a/src/imports/multimedia/qdeclarativecameracapture_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $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>
-#include <qmediametadata.h>
-
-#include <QtQml/qqml.h>
-
-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(QString errorString READ errorString NOTIFY captureFailed)
-
-public:
- ~QDeclarativeCameraCapture();
-
- bool isReadyForCapture() const;
-
- QString capturedImagePath() const;
- QCameraImageCapture::Error error() const;
- QString errorString() const;
-
-public Q_SLOTS:
- int capture();
- int captureToLocation(const QString &location);
-
- void setMetadata(QMediaMetaData::Key key, const QVariant &value);
-
-Q_SIGNALS:
- void readyForCaptureChanged(bool);
-
- void imageExposed(int requestId);
- void imageCaptured(int requestId, const QString &preview);
- void imageMetadataAvailable(int requestId, const QMediaMetaData &);
- void imageSaved(int requestId, const QString &path);
- void captureFailed(int requestId, const QString &message);
-
-private slots:
- void _q_imageCaptured(int, const QImage&);
- void _q_imageSaved(int, const QString&);
- void _q_captureFailed(int, QCameraImageCapture::Error, const QString&);
-
-private:
- friend class QDeclarativeCamera;
- QDeclarativeCameraCapture(QMediaCaptureSession *captureSession);
-
- QCameraImageCapture *m_capture;
- QImageEncoderSettings m_imageSettings;
- QString m_capturedImagePath;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraCapture))
-
-#endif
diff --git a/src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp b/src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp
deleted file mode 100644
index 0c1566992..000000000
--- a/src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecamerapreviewprovider_p.h"
-#include <QtCore/qmutex.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QDeclarativeCameraPreviewProviderPrivate
-{
- QString id;
- QImage image;
- QMutex mutex;
-};
-
-Q_GLOBAL_STATIC(QDeclarativeCameraPreviewProviderPrivate, qDeclarativeCameraPreviewProviderPrivate)
-
-QDeclarativeCameraPreviewProvider::QDeclarativeCameraPreviewProvider()
-: QQuickImageProvider(QQuickImageProvider::Image)
-{
-}
-
-QDeclarativeCameraPreviewProvider::~QDeclarativeCameraPreviewProvider()
-{
- QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
- QMutexLocker lock(&d->mutex);
- d->id.clear();
- d->image = QImage();
-}
-
-QImage QDeclarativeCameraPreviewProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize)
-{
- QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
- QMutexLocker lock(&d->mutex);
-
- if (d->id != id)
- return QImage();
-
- QImage res = d->image;
- if (!requestedSize.isEmpty())
- res = res.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
-
- if (size)
- *size = res.size();
-
- return res;
-}
-
-void QDeclarativeCameraPreviewProvider::registerPreview(const QString &id, const QImage &preview)
-{
- //only the last preview is kept
- QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
- QMutexLocker lock(&d->mutex);
- d->id = id;
- d->image = preview;
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h b/src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h
deleted file mode 100644
index cf5f0644c..000000000
--- a/src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECAMERAPREVIEWPROVIDER_H
-#define QDECLARATIVECAMERAPREVIEWPROVIDER_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 <QtQuick/qquickimageprovider.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeCameraPreviewProvider : public QQuickImageProvider
-{
-public:
- QDeclarativeCameraPreviewProvider();
- ~QDeclarativeCameraPreviewProvider();
-
- QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) override;
- static void registerPreview(const QString &id, const QImage &preview);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/imports/multimedia/qdeclarativecamerarecorder_p.h b/src/imports/multimedia/qdeclarativecamerarecorder_p.h
index 9903c552d..467cc304d 100644
--- a/src/imports/multimedia/qdeclarativecamerarecorder_p.h
+++ b/src/imports/multimedia/qdeclarativecamerarecorder_p.h
@@ -56,6 +56,8 @@
#include <qmediaencodersettings.h>
#include <qmediaformat.h>
+#include <QtQml/qqml.h>
+
QT_BEGIN_NAMESPACE
class QDeclarativeCamera;