#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 <QDeclarativeInfo>
-
+#elif defined(QT5)
+#include <QQmlInfo>
+#endif
#include "zoom.h"
#include "flash.h"
#include "scene.h"
#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),
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() {
delete m_roi;
delete m_videoMute;
delete m_videoTorch;
-}
-
-void Camera::componentComplete() {
- QDeclarativeItem::componentComplete();
-
- emit deviceCountChanged();
+ delete m_quirks;
}
int Camera::deviceCount() const {
return false;
}
- if (!isComponentComplete()) {
- qmlInfo(this) << "Component is still not ready";
- return false;
- }
-
QVariant oldId = m_id;
Camera::CameraMode oldMode = m_mode;
}
if (m_dev && m_dev->stop(false)) {
+ emit prepareForDeviceChange();
delete m_dev;
}
else if (m_dev) {
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()));
return m_id;
}
-void Camera::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) {
- QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
-
- // TODO: seems setting geometry breaks rendering somehow
- // m_vf->setGeometry(newGeometry);
- m_vf->resize(newGeometry.size());
-}
-
QtCamDevice *Camera::device() const {
return m_dev;
}
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<Sounds *>(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();
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 {
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;
}