From 1bf9d73eff18fde3f7cfe0e6aa7e7edc39264e77 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 23 Sep 2013 12:18:11 +0200 Subject: Add subdirs .pro files so that it can be built from top directory Change-Id: Idf5e9a70a56a1f896f8b7463348826aa5453b59d Reviewed-by: Gatis Paeglis --- b2qt-demos.pro | 4 + basicsuite/basicsuite.pro | 1 + experimental/Camera/Camera.pro | 4 + experimental/Camera/camerautils/camerautils.cpp | 189 ++++++++++++++++++++++++ experimental/Camera/camerautils/camerautils.h | 87 +++++++++++ experimental/Camera/camerautils/camerautils.pro | 19 +++ experimental/Camera/camerautils/plugin.cpp | 60 ++++++++ experimental/Camera/camerautils/qmldir | 2 + experimental/Camera/qmlplugin/camerautils.cpp | 189 ------------------------ experimental/Camera/qmlplugin/camerautils.h | 87 ----------- experimental/Camera/qmlplugin/camerautils.pro | 19 --- experimental/Camera/qmlplugin/plugin.cpp | 60 -------- experimental/Camera/qmlplugin/qmldir | 2 - experimental/experimental.pro | 3 + 14 files changed, 369 insertions(+), 357 deletions(-) create mode 100644 b2qt-demos.pro create mode 100644 basicsuite/basicsuite.pro create mode 100644 experimental/Camera/Camera.pro create mode 100644 experimental/Camera/camerautils/camerautils.cpp create mode 100644 experimental/Camera/camerautils/camerautils.h create mode 100644 experimental/Camera/camerautils/camerautils.pro create mode 100644 experimental/Camera/camerautils/plugin.cpp create mode 100644 experimental/Camera/camerautils/qmldir delete mode 100644 experimental/Camera/qmlplugin/camerautils.cpp delete mode 100644 experimental/Camera/qmlplugin/camerautils.h delete mode 100644 experimental/Camera/qmlplugin/camerautils.pro delete mode 100644 experimental/Camera/qmlplugin/plugin.cpp delete mode 100644 experimental/Camera/qmlplugin/qmldir create mode 100644 experimental/experimental.pro diff --git a/b2qt-demos.pro b/b2qt-demos.pro new file mode 100644 index 0000000..93b6e9f --- /dev/null +++ b/b2qt-demos.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS += \ + basicsuite \ + experimental diff --git a/basicsuite/basicsuite.pro b/basicsuite/basicsuite.pro new file mode 100644 index 0000000..9671085 --- /dev/null +++ b/basicsuite/basicsuite.pro @@ -0,0 +1 @@ +TEMPLATE = subdirs diff --git a/experimental/Camera/Camera.pro b/experimental/Camera/Camera.pro new file mode 100644 index 0000000..d8e46c6 --- /dev/null +++ b/experimental/Camera/Camera.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS += \ + camerautils + diff --git a/experimental/Camera/camerautils/camerautils.cpp b/experimental/Camera/camerautils/camerautils.cpp new file mode 100644 index 0000000..608bfaa --- /dev/null +++ b/experimental/Camera/camerautils/camerautils.cpp @@ -0,0 +1,189 @@ +#include "camerautils.h" + +#include +#include +#include +#include +#include +#include + +static QList g_commonResolutions; +static QList g_commonVideoResolutions; +static QList g_whiteBalanceModes; +static QList g_sceneModes; +static QList g_flashModes; +static QList g_focusModes; + +QDebug operator<<(QDebug dbg, const CameraSettingsValue &r) { + dbg.nospace() << "CameraSettingsValue(" << r.name() << ", " << r.value() << ')'; + return dbg.space(); +} + +CameraUtils::CameraUtils(QObject *parent) + : QObject(parent) + , m_camera(0) +{ + if (g_commonResolutions.isEmpty()) { + g_commonResolutions << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240)) + << new CameraSettingsValue(QStringLiteral("0.3M"), QSize(640, 480)) + << new CameraSettingsValue(QStringLiteral("0.8M"), QSize(1024, 768)) + << new CameraSettingsValue(QStringLiteral("1.2M"), QSize(1280, 960)) + << new CameraSettingsValue(QStringLiteral("2M"), QSize(1600, 1200)) + << new CameraSettingsValue(QStringLiteral("5M"), QSize(2560, 1920)) + << new CameraSettingsValue(QStringLiteral("8M"), QSize(3264, 2448)); + + g_commonVideoResolutions << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1080)) + << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1088)) + << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1080)) + << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1088)) + << new CameraSettingsValue(QStringLiteral("720p (16:9)"), QSize(1280, 720)) + << new CameraSettingsValue(QStringLiteral("720p (4:3)"), QSize(960, 720)) + << new CameraSettingsValue(QStringLiteral("480p (16:9)"), QSize(720, 480)) + << new CameraSettingsValue(QStringLiteral("480p (4:3)"), QSize(640, 480)) + << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240)); + + g_whiteBalanceModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraImageProcessing::WhiteBalanceAuto) + << new CameraSettingsValue(QStringLiteral("Manual"), QCameraImageProcessing::WhiteBalanceManual) + << new CameraSettingsValue(QStringLiteral("Sunlight"), QCameraImageProcessing::WhiteBalanceSunlight) + << new CameraSettingsValue(QStringLiteral("Cloudy"), QCameraImageProcessing::WhiteBalanceCloudy) + << new CameraSettingsValue(QStringLiteral("Shade"), QCameraImageProcessing::WhiteBalanceShade) + << new CameraSettingsValue(QStringLiteral("Tungsten"), QCameraImageProcessing::WhiteBalanceTungsten) + << new CameraSettingsValue(QStringLiteral("Fluorescent"), QCameraImageProcessing::WhiteBalanceFluorescent) + << new CameraSettingsValue(QStringLiteral("Flash"), QCameraImageProcessing::WhiteBalanceFlash) + << new CameraSettingsValue(QStringLiteral("Sunset"), QCameraImageProcessing::WhiteBalanceSunset); + + g_sceneModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::ExposureAuto) + << new CameraSettingsValue(QStringLiteral("Manual"), QCameraExposure::ExposureManual) + << new CameraSettingsValue(QStringLiteral("Portrait"), QCameraExposure::ExposurePortrait) + << new CameraSettingsValue(QStringLiteral("Night"), QCameraExposure::ExposureNight) + << new CameraSettingsValue(QStringLiteral("Backlight"), QCameraExposure::ExposureBacklight) + << new CameraSettingsValue(QStringLiteral("Spotlight"), QCameraExposure::ExposureSpotlight) + << new CameraSettingsValue(QStringLiteral("Sports"), QCameraExposure::ExposureSports) + << new CameraSettingsValue(QStringLiteral("Snow"), QCameraExposure::ExposureSnow) + << new CameraSettingsValue(QStringLiteral("Beach"), QCameraExposure::ExposureBeach) + << new CameraSettingsValue(QStringLiteral("Large Aperture"), QCameraExposure::ExposureLargeAperture) + << new CameraSettingsValue(QStringLiteral("Small Aperture"), QCameraExposure::ExposureSmallAperture); + + g_flashModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::FlashAuto) + << new CameraSettingsValue(QStringLiteral("Off"), QCameraExposure::FlashOff) + << new CameraSettingsValue(QStringLiteral("On"), QCameraExposure::FlashOn) + << new CameraSettingsValue(QStringLiteral("Red-Eye"), QCameraExposure::FlashRedEyeReduction) + << new CameraSettingsValue(QStringLiteral("Torch"), QCameraExposure::FlashVideoLight); + + g_focusModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraFocus::AutoFocus) + << new CameraSettingsValue(QStringLiteral("Continuous"), QCameraFocus::ContinuousFocus) + << new CameraSettingsValue(QStringLiteral("Hyperfocal"), QCameraFocus::HyperfocalFocus) + << new CameraSettingsValue(QStringLiteral("Infinity"), QCameraFocus::InfinityFocus) + << new CameraSettingsValue(QStringLiteral("Macro"), QCameraFocus::MacroFocus) + << new CameraSettingsValue(QStringLiteral("Off"), QCameraFocus::ManualFocus); + } + +} + +CameraUtils::~CameraUtils() +{ +} + +void CameraUtils::init() +{ + m_camera = new QCamera; + connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); + connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(onError())); + m_camera->load(); +} + +void CameraUtils::setCamera(QObject *obj) +{ + QObject *mediaObject = qvariant_cast(obj->property("mediaObject")); + if (!mediaObject) + return; + + m_camera = qobject_cast(mediaObject); + if (!m_camera) + return; + + if (m_camera->status() >= QCamera::LoadedStatus) + onCameraStatusChanged(); + else + connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); +} + +void CameraUtils::onError() +{ + if (m_camera && m_camera->status() == QCamera::UnavailableStatus) { + delete m_camera; + m_camera = 0; + + emit done(); + } +} + +void CameraUtils::onCameraStatusChanged() +{ + if (!m_camera || m_camera->status() < QCamera::LoadedStatus) + return; + + disconnect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); + + QCameraImageCapture *imageCapture = new QCameraImageCapture(m_camera); + QCameraImageProcessing *imageProc = m_camera->imageProcessing(); + QCameraExposure *exposure = m_camera->exposure(); + QCameraFocus *focus = m_camera->focus(); + QMediaRecorder rec(m_camera); + + // Supported image resolutions + QList resolutions = imageCapture->supportedResolutions(); + for (int i = resolutions.size() - 1; i >= 0; --i) { + QSize reso = resolutions.at(i); + int mp = reso.width() * reso.height(); + CameraSettingsValue *r = new CameraSettingsValue(QString::number(mp / double(1000000), 'f', 1) + QLatin1String("M"), reso); + m_supportedResolutions.append(r); + } + + // Supported video resolutions + QList suppRes = rec.supportedResolutions(); + for (int i = 0; i < g_commonVideoResolutions.size(); ++i) { + CameraSettingsValue *r = g_commonVideoResolutions.at(i); + if (suppRes.contains(r->value().toSize())) + m_supportedVideoResolutions.append(r); + } + + + // Supported white balance modes + for (int i = 0; i < g_whiteBalanceModes.size(); ++i) { + CameraSettingsValue *m = g_whiteBalanceModes.at(i); + if (imageProc->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode(m->value().toInt()))) + m_supportedWhiteBalanceModes.append(m); + } + + // Supported scene modes + for (int i = 0; i < g_sceneModes.size(); ++i) { + CameraSettingsValue *sm = g_sceneModes.at(i); + if (exposure->isExposureModeSupported(QCameraExposure::ExposureMode(sm->value().toInt()))) + m_supportedSceneModes.append(sm); + } + + // Supported flash modes + for (int i = 0; i < g_flashModes.size(); ++i) { + CameraSettingsValue *sm = g_flashModes.at(i); + if (exposure->isFlashModeSupported(QCameraExposure::FlashModes(sm->value().toInt()))) + m_supportedFlashModes.append(sm); + } + + // Supported focus modes + for (int i = 0; i < g_focusModes.size(); ++i) { + CameraSettingsValue *sm = g_focusModes.at(i); + if (focus->isFocusModeSupported(QCameraFocus::FocusModes(sm->value().toInt()))) + m_supportedFocusModes.append(sm); + } + + delete imageCapture; + + emit supportedCaptureResolutionsChanged(); + emit supportedVideoResolutionsChanged(); + emit supportedWhiteBalanceModesChanged(); + emit supportedSceneModesChanged(); + emit supportedFlashModesChanged(); +} + + diff --git a/experimental/Camera/camerautils/camerautils.h b/experimental/Camera/camerautils/camerautils.h new file mode 100644 index 0000000..562b675 --- /dev/null +++ b/experimental/Camera/camerautils/camerautils.h @@ -0,0 +1,87 @@ +#ifndef CAMERAUTILS_H +#define CAMERAUTILS_H + +#include +#include + +class QCamera; + +class CameraSettingsValue : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) + +public: + CameraSettingsValue(const QString &n, const QVariant &v) + : QObject() + , m_name(n) + , m_value(v) + { } + + QString name() const { return m_name; } + void setName(const QString &n) { m_name = n; emit nameChanged(); } + + QVariant value() const { return m_value; } + void setValue(const QVariant &v) { m_value = v; emit valueChanged(); } + +Q_SIGNALS: + void nameChanged(); + void valueChanged(); + +private: + QString m_name; + QVariant m_value; +}; + +QDebug operator<<(QDebug, const CameraSettingsValue &); + +class CameraUtils : public QObject +{ + Q_OBJECT + Q_PROPERTY(QList supportedCaptureResolutions READ supportedCaptureResolutions NOTIFY supportedCaptureResolutionsChanged) + Q_PROPERTY(QList supportedWhiteBalanceModes READ supportedWhiteBalanceModes NOTIFY supportedWhiteBalanceModesChanged) + Q_PROPERTY(QList supportedSceneModes READ supportedSceneModes NOTIFY supportedSceneModesChanged) + Q_PROPERTY(QList supportedFlashModes READ supportedFlashModes NOTIFY supportedFlashModesChanged) + Q_PROPERTY(QList supportedFocusModes READ supportedFocusModes NOTIFY supportedFocusModesChanged) + Q_PROPERTY(QList supportedVideoResolutions READ supportedVideoResolutions NOTIFY supportedVideoResolutionsChanged) +public: + explicit CameraUtils(QObject *parent = 0); + ~CameraUtils(); + + Q_INVOKABLE void init(); + Q_INVOKABLE void setCamera(QObject *cam); + + QList supportedCaptureResolutions() const { return m_supportedResolutions; } + QList supportedVideoResolutions() const { return m_supportedVideoResolutions; } + QList supportedWhiteBalanceModes() const { return m_supportedWhiteBalanceModes; } + QList supportedSceneModes() const { return m_supportedSceneModes; } + QList supportedFlashModes() const { return m_supportedFlashModes; } + QList supportedFocusModes() const { return m_supportedFocusModes; } + +Q_SIGNALS: + void supportedCaptureResolutionsChanged(); + void supportedWhiteBalanceModesChanged(); + void supportedSceneModesChanged(); + void supportedFlashModesChanged(); + void supportedFocusModesChanged(); + void supportedVideoResolutionsChanged(); + + void done(); + +private Q_SLOTS: + void onCameraStatusChanged(); + void onError(); + +private: + QCamera *m_camera; + + QList m_supportedResolutions; + QList m_supportedVideoResolutions; + QList m_supportedWhiteBalanceModes; + QList m_supportedSceneModes; + QList m_supportedFlashModes; + QList m_supportedFocusModes; +}; + +#endif // CAMERAUTILS_H diff --git a/experimental/Camera/camerautils/camerautils.pro b/experimental/Camera/camerautils/camerautils.pro new file mode 100644 index 0000000..938a0a9 --- /dev/null +++ b/experimental/Camera/camerautils/camerautils.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib +CONFIG += plugin +QT += qml multimedia + +TARGET = camerautilsplugin + +SOURCES += plugin.cpp \ + camerautils.cpp + +HEADERS += camerautils.h + +pluginfiles.files += \ + qmldir \ + +target.path += $$[QT_INSTALL_QML]/CameraUtils +pluginfiles.path += $$[QT_INSTALL_QML]/CameraUtils + +INSTALLS += target pluginfiles + diff --git a/experimental/Camera/camerautils/plugin.cpp b/experimental/Camera/camerautils/plugin.cpp new file mode 100644 index 0000000..2a8c3ea --- /dev/null +++ b/experimental/Camera/camerautils/plugin.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include "camerautils.h" + +class QExampleQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "CameraUtils"); + } +}; + + +#include "plugin.moc" diff --git a/experimental/Camera/camerautils/qmldir b/experimental/Camera/camerautils/qmldir new file mode 100644 index 0000000..a5ab412 --- /dev/null +++ b/experimental/Camera/camerautils/qmldir @@ -0,0 +1,2 @@ +module CameraUtils +plugin camerautilsplugin diff --git a/experimental/Camera/qmlplugin/camerautils.cpp b/experimental/Camera/qmlplugin/camerautils.cpp deleted file mode 100644 index 608bfaa..0000000 --- a/experimental/Camera/qmlplugin/camerautils.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include "camerautils.h" - -#include -#include -#include -#include -#include -#include - -static QList g_commonResolutions; -static QList g_commonVideoResolutions; -static QList g_whiteBalanceModes; -static QList g_sceneModes; -static QList g_flashModes; -static QList g_focusModes; - -QDebug operator<<(QDebug dbg, const CameraSettingsValue &r) { - dbg.nospace() << "CameraSettingsValue(" << r.name() << ", " << r.value() << ')'; - return dbg.space(); -} - -CameraUtils::CameraUtils(QObject *parent) - : QObject(parent) - , m_camera(0) -{ - if (g_commonResolutions.isEmpty()) { - g_commonResolutions << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240)) - << new CameraSettingsValue(QStringLiteral("0.3M"), QSize(640, 480)) - << new CameraSettingsValue(QStringLiteral("0.8M"), QSize(1024, 768)) - << new CameraSettingsValue(QStringLiteral("1.2M"), QSize(1280, 960)) - << new CameraSettingsValue(QStringLiteral("2M"), QSize(1600, 1200)) - << new CameraSettingsValue(QStringLiteral("5M"), QSize(2560, 1920)) - << new CameraSettingsValue(QStringLiteral("8M"), QSize(3264, 2448)); - - g_commonVideoResolutions << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1080)) - << new CameraSettingsValue(QStringLiteral("1080p (16:9)"), QSize(1920, 1088)) - << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1080)) - << new CameraSettingsValue(QStringLiteral("1080p (4:3)"), QSize(1440, 1088)) - << new CameraSettingsValue(QStringLiteral("720p (16:9)"), QSize(1280, 720)) - << new CameraSettingsValue(QStringLiteral("720p (4:3)"), QSize(960, 720)) - << new CameraSettingsValue(QStringLiteral("480p (16:9)"), QSize(720, 480)) - << new CameraSettingsValue(QStringLiteral("480p (4:3)"), QSize(640, 480)) - << new CameraSettingsValue(QStringLiteral("QVGA"), QSize(320, 240)); - - g_whiteBalanceModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraImageProcessing::WhiteBalanceAuto) - << new CameraSettingsValue(QStringLiteral("Manual"), QCameraImageProcessing::WhiteBalanceManual) - << new CameraSettingsValue(QStringLiteral("Sunlight"), QCameraImageProcessing::WhiteBalanceSunlight) - << new CameraSettingsValue(QStringLiteral("Cloudy"), QCameraImageProcessing::WhiteBalanceCloudy) - << new CameraSettingsValue(QStringLiteral("Shade"), QCameraImageProcessing::WhiteBalanceShade) - << new CameraSettingsValue(QStringLiteral("Tungsten"), QCameraImageProcessing::WhiteBalanceTungsten) - << new CameraSettingsValue(QStringLiteral("Fluorescent"), QCameraImageProcessing::WhiteBalanceFluorescent) - << new CameraSettingsValue(QStringLiteral("Flash"), QCameraImageProcessing::WhiteBalanceFlash) - << new CameraSettingsValue(QStringLiteral("Sunset"), QCameraImageProcessing::WhiteBalanceSunset); - - g_sceneModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::ExposureAuto) - << new CameraSettingsValue(QStringLiteral("Manual"), QCameraExposure::ExposureManual) - << new CameraSettingsValue(QStringLiteral("Portrait"), QCameraExposure::ExposurePortrait) - << new CameraSettingsValue(QStringLiteral("Night"), QCameraExposure::ExposureNight) - << new CameraSettingsValue(QStringLiteral("Backlight"), QCameraExposure::ExposureBacklight) - << new CameraSettingsValue(QStringLiteral("Spotlight"), QCameraExposure::ExposureSpotlight) - << new CameraSettingsValue(QStringLiteral("Sports"), QCameraExposure::ExposureSports) - << new CameraSettingsValue(QStringLiteral("Snow"), QCameraExposure::ExposureSnow) - << new CameraSettingsValue(QStringLiteral("Beach"), QCameraExposure::ExposureBeach) - << new CameraSettingsValue(QStringLiteral("Large Aperture"), QCameraExposure::ExposureLargeAperture) - << new CameraSettingsValue(QStringLiteral("Small Aperture"), QCameraExposure::ExposureSmallAperture); - - g_flashModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraExposure::FlashAuto) - << new CameraSettingsValue(QStringLiteral("Off"), QCameraExposure::FlashOff) - << new CameraSettingsValue(QStringLiteral("On"), QCameraExposure::FlashOn) - << new CameraSettingsValue(QStringLiteral("Red-Eye"), QCameraExposure::FlashRedEyeReduction) - << new CameraSettingsValue(QStringLiteral("Torch"), QCameraExposure::FlashVideoLight); - - g_focusModes << new CameraSettingsValue(QStringLiteral("Auto"), QCameraFocus::AutoFocus) - << new CameraSettingsValue(QStringLiteral("Continuous"), QCameraFocus::ContinuousFocus) - << new CameraSettingsValue(QStringLiteral("Hyperfocal"), QCameraFocus::HyperfocalFocus) - << new CameraSettingsValue(QStringLiteral("Infinity"), QCameraFocus::InfinityFocus) - << new CameraSettingsValue(QStringLiteral("Macro"), QCameraFocus::MacroFocus) - << new CameraSettingsValue(QStringLiteral("Off"), QCameraFocus::ManualFocus); - } - -} - -CameraUtils::~CameraUtils() -{ -} - -void CameraUtils::init() -{ - m_camera = new QCamera; - connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); - connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(onError())); - m_camera->load(); -} - -void CameraUtils::setCamera(QObject *obj) -{ - QObject *mediaObject = qvariant_cast(obj->property("mediaObject")); - if (!mediaObject) - return; - - m_camera = qobject_cast(mediaObject); - if (!m_camera) - return; - - if (m_camera->status() >= QCamera::LoadedStatus) - onCameraStatusChanged(); - else - connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); -} - -void CameraUtils::onError() -{ - if (m_camera && m_camera->status() == QCamera::UnavailableStatus) { - delete m_camera; - m_camera = 0; - - emit done(); - } -} - -void CameraUtils::onCameraStatusChanged() -{ - if (!m_camera || m_camera->status() < QCamera::LoadedStatus) - return; - - disconnect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged())); - - QCameraImageCapture *imageCapture = new QCameraImageCapture(m_camera); - QCameraImageProcessing *imageProc = m_camera->imageProcessing(); - QCameraExposure *exposure = m_camera->exposure(); - QCameraFocus *focus = m_camera->focus(); - QMediaRecorder rec(m_camera); - - // Supported image resolutions - QList resolutions = imageCapture->supportedResolutions(); - for (int i = resolutions.size() - 1; i >= 0; --i) { - QSize reso = resolutions.at(i); - int mp = reso.width() * reso.height(); - CameraSettingsValue *r = new CameraSettingsValue(QString::number(mp / double(1000000), 'f', 1) + QLatin1String("M"), reso); - m_supportedResolutions.append(r); - } - - // Supported video resolutions - QList suppRes = rec.supportedResolutions(); - for (int i = 0; i < g_commonVideoResolutions.size(); ++i) { - CameraSettingsValue *r = g_commonVideoResolutions.at(i); - if (suppRes.contains(r->value().toSize())) - m_supportedVideoResolutions.append(r); - } - - - // Supported white balance modes - for (int i = 0; i < g_whiteBalanceModes.size(); ++i) { - CameraSettingsValue *m = g_whiteBalanceModes.at(i); - if (imageProc->isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode(m->value().toInt()))) - m_supportedWhiteBalanceModes.append(m); - } - - // Supported scene modes - for (int i = 0; i < g_sceneModes.size(); ++i) { - CameraSettingsValue *sm = g_sceneModes.at(i); - if (exposure->isExposureModeSupported(QCameraExposure::ExposureMode(sm->value().toInt()))) - m_supportedSceneModes.append(sm); - } - - // Supported flash modes - for (int i = 0; i < g_flashModes.size(); ++i) { - CameraSettingsValue *sm = g_flashModes.at(i); - if (exposure->isFlashModeSupported(QCameraExposure::FlashModes(sm->value().toInt()))) - m_supportedFlashModes.append(sm); - } - - // Supported focus modes - for (int i = 0; i < g_focusModes.size(); ++i) { - CameraSettingsValue *sm = g_focusModes.at(i); - if (focus->isFocusModeSupported(QCameraFocus::FocusModes(sm->value().toInt()))) - m_supportedFocusModes.append(sm); - } - - delete imageCapture; - - emit supportedCaptureResolutionsChanged(); - emit supportedVideoResolutionsChanged(); - emit supportedWhiteBalanceModesChanged(); - emit supportedSceneModesChanged(); - emit supportedFlashModesChanged(); -} - - diff --git a/experimental/Camera/qmlplugin/camerautils.h b/experimental/Camera/qmlplugin/camerautils.h deleted file mode 100644 index 562b675..0000000 --- a/experimental/Camera/qmlplugin/camerautils.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef CAMERAUTILS_H -#define CAMERAUTILS_H - -#include -#include - -class QCamera; - -class CameraSettingsValue : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) - -public: - CameraSettingsValue(const QString &n, const QVariant &v) - : QObject() - , m_name(n) - , m_value(v) - { } - - QString name() const { return m_name; } - void setName(const QString &n) { m_name = n; emit nameChanged(); } - - QVariant value() const { return m_value; } - void setValue(const QVariant &v) { m_value = v; emit valueChanged(); } - -Q_SIGNALS: - void nameChanged(); - void valueChanged(); - -private: - QString m_name; - QVariant m_value; -}; - -QDebug operator<<(QDebug, const CameraSettingsValue &); - -class CameraUtils : public QObject -{ - Q_OBJECT - Q_PROPERTY(QList supportedCaptureResolutions READ supportedCaptureResolutions NOTIFY supportedCaptureResolutionsChanged) - Q_PROPERTY(QList supportedWhiteBalanceModes READ supportedWhiteBalanceModes NOTIFY supportedWhiteBalanceModesChanged) - Q_PROPERTY(QList supportedSceneModes READ supportedSceneModes NOTIFY supportedSceneModesChanged) - Q_PROPERTY(QList supportedFlashModes READ supportedFlashModes NOTIFY supportedFlashModesChanged) - Q_PROPERTY(QList supportedFocusModes READ supportedFocusModes NOTIFY supportedFocusModesChanged) - Q_PROPERTY(QList supportedVideoResolutions READ supportedVideoResolutions NOTIFY supportedVideoResolutionsChanged) -public: - explicit CameraUtils(QObject *parent = 0); - ~CameraUtils(); - - Q_INVOKABLE void init(); - Q_INVOKABLE void setCamera(QObject *cam); - - QList supportedCaptureResolutions() const { return m_supportedResolutions; } - QList supportedVideoResolutions() const { return m_supportedVideoResolutions; } - QList supportedWhiteBalanceModes() const { return m_supportedWhiteBalanceModes; } - QList supportedSceneModes() const { return m_supportedSceneModes; } - QList supportedFlashModes() const { return m_supportedFlashModes; } - QList supportedFocusModes() const { return m_supportedFocusModes; } - -Q_SIGNALS: - void supportedCaptureResolutionsChanged(); - void supportedWhiteBalanceModesChanged(); - void supportedSceneModesChanged(); - void supportedFlashModesChanged(); - void supportedFocusModesChanged(); - void supportedVideoResolutionsChanged(); - - void done(); - -private Q_SLOTS: - void onCameraStatusChanged(); - void onError(); - -private: - QCamera *m_camera; - - QList m_supportedResolutions; - QList m_supportedVideoResolutions; - QList m_supportedWhiteBalanceModes; - QList m_supportedSceneModes; - QList m_supportedFlashModes; - QList m_supportedFocusModes; -}; - -#endif // CAMERAUTILS_H diff --git a/experimental/Camera/qmlplugin/camerautils.pro b/experimental/Camera/qmlplugin/camerautils.pro deleted file mode 100644 index 938a0a9..0000000 --- a/experimental/Camera/qmlplugin/camerautils.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -QT += qml multimedia - -TARGET = camerautilsplugin - -SOURCES += plugin.cpp \ - camerautils.cpp - -HEADERS += camerautils.h - -pluginfiles.files += \ - qmldir \ - -target.path += $$[QT_INSTALL_QML]/CameraUtils -pluginfiles.path += $$[QT_INSTALL_QML]/CameraUtils - -INSTALLS += target pluginfiles - diff --git a/experimental/Camera/qmlplugin/plugin.cpp b/experimental/Camera/qmlplugin/plugin.cpp deleted file mode 100644 index 2a8c3ea..0000000 --- a/experimental/Camera/qmlplugin/plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include "camerautils.h" - -class QExampleQmlPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "CameraUtils"); - } -}; - - -#include "plugin.moc" diff --git a/experimental/Camera/qmlplugin/qmldir b/experimental/Camera/qmlplugin/qmldir deleted file mode 100644 index a5ab412..0000000 --- a/experimental/Camera/qmlplugin/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module CameraUtils -plugin camerautilsplugin diff --git a/experimental/experimental.pro b/experimental/experimental.pro new file mode 100644 index 0000000..d067cd5 --- /dev/null +++ b/experimental/experimental.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + Camera -- cgit v1.2.3