summaryrefslogtreecommitdiffstats
path: root/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/multimedia/qdeclarativecameraviewfinder.cpp')
-rw-r--r--src/imports/multimedia/qdeclarativecameraviewfinder.cpp74
1 files changed, 42 insertions, 32 deletions
diff --git a/src/imports/multimedia/qdeclarativecameraviewfinder.cpp b/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
index 66d4e1bbc..ccd1882e5 100644
--- a/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
+++ b/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -42,68 +42,78 @@ QT_BEGIN_NAMESPACE
QDeclarativeCameraViewfinder::QDeclarativeCameraViewfinder(QCamera *camera, QObject *parent)
: QObject(parent)
, m_camera(camera)
- , m_control(0)
{
- if (QMediaService *service = m_camera->service())
- m_control = service->requestControl<QCameraViewfinderSettingsControl *>();
+ connect(m_camera, &QCamera::statusChanged,
+ this, &QDeclarativeCameraViewfinder::_q_cameraStatusChanged);
}
QDeclarativeCameraViewfinder::~QDeclarativeCameraViewfinder()
{
- if (m_control) {
- if (QMediaService *service = m_camera->service())
- service->releaseControl(m_control);
- }
}
QSize QDeclarativeCameraViewfinder::resolution() const
{
- return m_control
- ? m_control->viewfinderParameter(QCameraViewfinderSettingsControl::Resolution).value<QSize>()
- : QSize();
+ return m_settings.resolution();
}
-void QDeclarativeCameraViewfinder::setResolution(const QSize &resolution)
+void QDeclarativeCameraViewfinder::setResolution(const QSize &res)
{
- if (m_control) {
- m_control->setViewfinderParameter(
- QCameraViewfinderSettingsControl::Resolution, resolution);
+ if (res != m_settings.resolution()) {
+ m_settings = m_camera->viewfinderSettings();
+ m_settings.setResolution(res);
+ m_camera->setViewfinderSettings(m_settings);
emit resolutionChanged();
}
}
qreal QDeclarativeCameraViewfinder::minimumFrameRate() const
{
- return m_control
- ? m_control->viewfinderParameter(QCameraViewfinderSettingsControl::MinimumFrameRate).value<qreal>()
- : 0.0;
+ return m_settings.minimumFrameRate();
}
void QDeclarativeCameraViewfinder::setMinimumFrameRate(qreal frameRate)
{
- if (m_control) {
- m_control->setViewfinderParameter(
- QCameraViewfinderSettingsControl::MinimumFrameRate, frameRate);
+ if (frameRate != minimumFrameRate()) {
+ m_settings = m_camera->viewfinderSettings();
+ m_settings.setMinimumFrameRate(frameRate);
+ m_camera->setViewfinderSettings(m_settings);
emit minimumFrameRateChanged();
}
}
qreal QDeclarativeCameraViewfinder::maximumFrameRate() const
{
- return m_control
- ? m_control->viewfinderParameter(QCameraViewfinderSettingsControl::MaximumFrameRate).value<qreal>()
- : 0.0;
+ return m_settings.maximumFrameRate();
}
void QDeclarativeCameraViewfinder::setMaximumFrameRate(qreal frameRate)
{
- if (m_control) {
- m_control->setViewfinderParameter(
- QCameraViewfinderSettingsControl::MaximumFrameRate, frameRate);
+ if (frameRate != maximumFrameRate()) {
+ m_settings = m_camera->viewfinderSettings();
+ m_settings.setMaximumFrameRate(frameRate);
+ m_camera->setViewfinderSettings(m_settings);
emit maximumFrameRateChanged();
}
}
+void QDeclarativeCameraViewfinder::_q_cameraStatusChanged(QCamera::Status status)
+{
+ // Settings values might change when the camera starts, for example if the settings are
+ // undefined, if unsupported values were set or if the settings conflict with capture settings.
+ // They might also change on LoadedStatus, for example reverting to values that were set by the
+ // user.
+ if (status == QCamera::ActiveStatus || status == QCamera::LoadedStatus) {
+ QCameraViewfinderSettings oldSettings = m_settings;
+ m_settings = m_camera->viewfinderSettings();
+ if (oldSettings.resolution() != m_settings.resolution())
+ emit resolutionChanged();
+ if (oldSettings.minimumFrameRate() != m_settings.minimumFrameRate())
+ emit minimumFrameRateChanged();
+ if (oldSettings.maximumFrameRate() != m_settings.maximumFrameRate())
+ emit maximumFrameRateChanged();
+ }
+}
+
QT_END_NAMESPACE
#include "moc_qdeclarativecameraviewfinder_p.cpp"