Fix QML Camera::supportedViewfinderFrameRateRanges().
Pass the resolution argument as a QJSValue instead of a QSize. This allows to be more flexible and doesn't require the QML argument to be an actual QML 'size' value. It can be any object with the 'width' and 'height' properties. Added missing auto-tests for supportedViewfinderResolutions() and supportedViewfinderFrameRateRanges(). Change-Id: I6c8ae72e6dab8c9d12bbada5b8e7f45e96e9289d Task-number: QTBUG-47630 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
@@ -1013,12 +1013,17 @@ QJSValue QDeclarativeCamera::supportedViewfinderResolutions(qreal minimumFrameRa
|
||||
|
||||
\since 5.5
|
||||
*/
|
||||
QJSValue QDeclarativeCamera::supportedViewfinderFrameRateRanges(const QSize &resolution)
|
||||
QJSValue QDeclarativeCamera::supportedViewfinderFrameRateRanges(const QJSValue &resolution)
|
||||
{
|
||||
QQmlEngine *engine = qmlEngine(this);
|
||||
|
||||
QCameraViewfinderSettings settings;
|
||||
settings.setResolution(resolution);
|
||||
if (!resolution.isUndefined()) {
|
||||
QJSValue width = resolution.property(QStringLiteral("width"));
|
||||
QJSValue height = resolution.property(QStringLiteral("height"));
|
||||
if (width.isNumber() && height.isNumber())
|
||||
settings.setResolution(width.toInt(), height.toInt());
|
||||
}
|
||||
QList<QCamera::FrameRateRange> frameRateRanges = m_camera->supportedViewfinderFrameRateRanges(settings);
|
||||
|
||||
QJSValue supportedFrameRateRanges = engine->newArray(frameRateRanges.count());
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtQml/qqmlparserstatus.h>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QtQml/qjsvalue.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -297,7 +298,7 @@ public Q_SLOTS:
|
||||
Q_REVISION(2) QJSValue supportedViewfinderResolutions(qreal minimumFrameRate = 0.0,
|
||||
qreal maximumFrameRate = 0.0);
|
||||
|
||||
Q_REVISION(2) QJSValue supportedViewfinderFrameRateRanges(const QSize &resolution = QSize());
|
||||
Q_REVISION(2) QJSValue supportedViewfinderFrameRateRanges(const QJSValue &resolution = QJSValue());
|
||||
|
||||
Q_SIGNALS:
|
||||
void errorChanged();
|
||||
|
||||
Reference in New Issue
Block a user