Disable viewfinder in settings pages
[harmattan/cameraplus] / lib / qtcammode_p.h
index 7ce7bbf..4fc5f52 100644 (file)
@@ -1,10 +1,31 @@
 // -*- c++ -*-
 
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
 #ifndef QT_CAM_MODE_P_H
 #define QT_CAM_MODE_P_H
 
 #include <QSize>
 #include "qtcamdevice_p.h"
+#include "qtcamanalysisbin.h"
 #include <gst/pbutils/encoding-profile.h>
 #include <gst/pbutils/encoding-target.h>
 
@@ -13,6 +34,8 @@
 #endif /* GST_USE_UNSTABLE_API */
 #include <gst/interfaces/photography.h>
 
+#define PREVIEW_CAPS "video/x-raw-rgb, width = (int) %1, height = (int) %2, bpp = (int) 32, depth = (int) 24, red_mask = (int) 65280, green_mask = (int) 16711680, blue_mask = (int) -16777216"
+
 class QtCamDevicePrivate;
 class PreviewImageHandler;
 class DoneHandler;
@@ -37,7 +60,7 @@ public:
       return -1;
     }
 
-    GParamSpecEnum *e = (GParamSpecEnum *)pspec;
+    GParamSpecEnum *e = G_PARAM_SPEC_ENUM(pspec);
     GEnumClass *klass = e->enum_class;
 
     for (unsigned x = 0; x < klass->n_values; x++) {
@@ -135,10 +158,52 @@ public:
     }
   }
 
+  void setPreviewSize(const QSize& size) {
+    if (!dev->cameraBin) {
+      return;
+    }
+
+    if (size.width() <= 0 && size.height() <= 0) {
+      g_object_set(dev->cameraBin, "preview-caps", NULL, "post-previews", FALSE, NULL);
+    }
+    else {
+      QString preview = QString(PREVIEW_CAPS).arg(size.width()).arg(size.height());
+
+      GstCaps *caps = gst_caps_from_string(preview.toAscii());
+
+      g_object_set(dev->cameraBin, "preview-caps", caps, "post-previews", TRUE, NULL);
+
+      gst_caps_unref(caps);
+    }
+  }
+
+  void setFileName(const QString& file) {
+    fileName = file;
+  }
+
+  void setTempFileName(const QString& file) {
+    tempFileName = file;
+  }
+
+  void enableViewfinderFilters() {
+    if (dev->viewfinderFilters) {
+      dev->viewfinderFilters->setBlocked(false);
+    }
+  }
+
+  void disableViewfinderFilters() {
+    if (dev->viewfinderFilters) {
+      dev->viewfinderFilters->setBlocked(true);
+    }
+  }
+
   int id;
+  QtCamMode *q_ptr;
   QtCamDevicePrivate *dev;
   PreviewImageHandler *previewImageHandler;
   DoneHandler *doneHandler;
+  QString fileName;
+  QString tempFileName;
 };
 
 #endif /* QT_CAM_MODE_P_H */