Kill DeclarativeQtCameraNotifications
[harmattan/cameraplus] / declarative / camera.cpp
index 518f2f6..252a6c2 100644 (file)
@@ -1,7 +1,7 @@
 /*!
  * This file is part of CameraPlus.
  *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,7 +26,7 @@
 #include "qtcamvideomode.h"
 #include "qtcamgraphicsviewfinder.h"
 #include "qtcamconfig.h"
-#include "notifications.h"
+#include "sounds.h"
 #include "notificationscontainer.h"
 #include "sounds.h"
 #include <QDeclarativeInfo>
 #include "flickerreduction.h"
 #include "focus.h"
 #include "autofocus.h"
+#include "roi.h"
 
 #include "videomute.h"
 #include "videotorch.h"
+#include "cameraconfig.h"
 
 Camera::Camera(QDeclarativeItem *parent) :
   QDeclarativeItem(parent),
@@ -68,8 +70,12 @@ Camera::Camera(QDeclarativeItem *parent) :
   m_flickerReduction(0),
   m_focus(0),
   m_autoFocus(0),
+  m_roi(0),
   m_videoMute(0),
-  m_videoTorch(0) {
+  m_videoTorch(0),
+  m_config(new CameraConfig(this)) {
+
+  m_config->componentComplete();
 
   QObject::connect(m_vf, SIGNAL(renderAreaChanged()), this, SIGNAL(renderAreaChanged()));
   QObject::connect(m_vf, SIGNAL(videoResolutionChanged()), this, SIGNAL(videoResolutionChanged()));
@@ -100,6 +106,7 @@ Camera::~Camera() {
   delete m_flickerReduction;
   delete m_focus;
   delete m_autoFocus;
+  delete m_roi;
   delete m_videoMute;
   delete m_videoTorch;
 }
@@ -191,7 +198,9 @@ QVariant Camera::deviceId() const {
 void Camera::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) {
   QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
 
-  m_vf->setGeometry(newGeometry);
+  // TODO: seems setting geometry breaks rendering somehow
+  //  m_vf->setGeometry(newGeometry);
+  m_vf->resize(newGeometry.size());
 }
 
 QtCamDevice *Camera::device() const {
@@ -271,19 +280,13 @@ QString Camera::videoSuffix() const {
   return m_cam->config()->videoSuffix();
 }
 
-Notifications *Camera::notifications() const {
-  return m_notifications->notifications();
+Sounds *Camera::sounds() const {
+  return m_notifications->sounds();
 }
-
-void Camera::setNotifications(Notifications *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();
   }
 }
 
@@ -350,6 +353,10 @@ void Camera::resetCapabilities() {
   m_autoFocus = new AutoFocus(dev, this);
   emit autoFocusChanged();
 
+  delete m_roi;
+  m_roi = new Roi(dev, this);
+  emit roiChanged();
+
   delete m_videoMute;
   m_videoMute = new VideoMute(dev, this);
   emit videoMuteChanged();
@@ -411,6 +418,10 @@ AutoFocus *Camera::autoFocus() const {
   return m_autoFocus;
 }
 
+Roi *Camera::roi() const {
+  return m_roi;
+}
+
 VideoMute *Camera::videoMute() const {
   return m_videoMute;
 }
@@ -426,3 +437,7 @@ bool Camera::isRenderingEnabled() const {
 void Camera::setRenderingEnabled(bool enabled) {
   m_vf->setRenderingEnabled(enabled);
 }
+
+CameraConfig *Camera::cameraConfig() const {
+  return m_config;
+}