X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=declarative%2Fcamera.cpp;h=34298326c4690db9976ba3fb14453d07a3f6f706;hb=1f7e1a5a0cf588f60f5be6c0c61fd5a8659aec95;hp=07f38015404206530c74cf8a994d8ec64938af1c;hpb=b37f9df89dc20000f88767537caf4415746a34a5;p=harmattan%2Fcameraplus diff --git a/declarative/camera.cpp b/declarative/camera.cpp index 07f3801..3429832 100644 --- a/declarative/camera.cpp +++ b/declarative/camera.cpp @@ -1,7 +1,7 @@ /*! * This file is part of CameraPlus. * - * Copyright (C) 2012 Mohammed Sameer + * Copyright (C) 2012-2013 Mohammed Sameer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,13 +24,15 @@ #include "qtcammode.h" #include "qtcamimagemode.h" #include "qtcamvideomode.h" -#include "qtcamgraphicsviewfinder.h" #include "qtcamconfig.h" -#include "declarativeqtcameranotifications.h" +#include "sounds.h" #include "notificationscontainer.h" #include "sounds.h" +#if defined(QT4) #include - +#elif defined(QT5) +#include +#endif #include "zoom.h" #include "flash.h" #include "scene.h" @@ -48,12 +50,13 @@ #include "videomute.h" #include "videotorch.h" +#include "cameraconfig.h" +#include "quirks.h" -Camera::Camera(QDeclarativeItem *parent) : - QDeclarativeItem(parent), +Camera::Camera(QObject *parent) : + QObject(parent), m_cam(new QtCamera(this)), m_dev(0), - m_vf(new QtCamGraphicsViewfinder(m_cam->config(), this)), m_mode(Camera::UnknownMode), m_notifications(new NotificationsContainer(this)), m_zoom(0), @@ -71,11 +74,11 @@ Camera::Camera(QDeclarativeItem *parent) : m_autoFocus(0), m_roi(0), m_videoMute(0), - m_videoTorch(0) { + m_videoTorch(0), + m_config(new CameraConfig(this)), + m_quirks(0) { - QObject::connect(m_vf, SIGNAL(renderAreaChanged()), this, SIGNAL(renderAreaChanged())); - QObject::connect(m_vf, SIGNAL(videoResolutionChanged()), this, SIGNAL(videoResolutionChanged())); - QObject::connect(m_vf, SIGNAL(renderingEnabledChanged()), this, SIGNAL(renderingEnabledChanged())); + m_config->componentComplete(); } Camera::~Camera() { @@ -105,12 +108,7 @@ Camera::~Camera() { delete m_roi; delete m_videoMute; delete m_videoTorch; -} - -void Camera::componentComplete() { - QDeclarativeItem::componentComplete(); - - emit deviceCountChanged(); + delete m_quirks; } int Camera::deviceCount() const { @@ -131,11 +129,6 @@ bool Camera::reset(const QVariant& deviceId, const CameraMode& mode) { return false; } - if (!isComponentComplete()) { - qmlInfo(this) << "Component is still not ready"; - return false; - } - QVariant oldId = m_id; Camera::CameraMode oldMode = m_mode; @@ -163,6 +156,7 @@ bool Camera::setDeviceId(const QVariant& deviceId) { } if (m_dev && m_dev->stop(false)) { + emit prepareForDeviceChange(); delete m_dev; } else if (m_dev) { @@ -174,8 +168,6 @@ bool Camera::setDeviceId(const QVariant& deviceId) { m_id = deviceId; - m_vf->setDevice(m_dev); - QObject::connect(m_dev, SIGNAL(runningStateChanged(bool)), this, SIGNAL(runningStateChanged())); QObject::connect(m_dev, SIGNAL(idleStateChanged(bool)), this, SIGNAL(idleStateChanged())); @@ -191,12 +183,6 @@ QVariant Camera::deviceId() const { return m_id; } -void Camera::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) { - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); - - m_vf->setGeometry(newGeometry); -} - QtCamDevice *Camera::device() const { return m_dev; } @@ -274,30 +260,16 @@ QString Camera::videoSuffix() const { return m_cam->config()->videoSuffix(); } -DeclarativeQtCameraNotifications *Camera::notifications() const { - return m_notifications->notifications(); +Sounds *Camera::sounds() const { + return m_notifications->sounds(); } - -void Camera::setNotifications(DeclarativeQtCameraNotifications *notifications) { - if (m_notifications->setNotifications(notifications)) { - - if (Sounds *s = dynamic_cast(notifications)) { - s->setConfig(m_cam->config()); - s->reload(); - } - - emit notificationsChanged(); +void Camera::setSounds(Sounds *sounds) { + if (m_notifications->setSounds(sounds)) { + sounds->reload(); + emit soundsChanged(); } } -QRectF Camera::renderArea() const { - return m_vf->renderArea(); -} - -QSizeF Camera::videoResolution() const { - return m_vf->videoResolution(); -} - void Camera::resetCapabilities() { QtCamDevice *dev = device(); @@ -364,6 +336,10 @@ void Camera::resetCapabilities() { delete m_videoTorch; m_videoTorch = new VideoTorch(dev, this); emit videoTorchChanged(); + + delete m_quirks; + m_quirks = new Quirks(dev->config()->quirks(dev->id()), this); + emit quirksChanged(); } Zoom *Camera::zoom() const { @@ -430,10 +406,10 @@ VideoTorch *Camera::videoTorch() const { return m_videoTorch; } -bool Camera::isRenderingEnabled() const { - return m_vf->isRenderingEnabled(); +CameraConfig *Camera::cameraConfig() const { + return m_config; } -void Camera::setRenderingEnabled(bool enabled) { - m_vf->setRenderingEnabled(enabled); +Quirks *Camera::quirks() const { + return m_quirks; }