watch for zoom and max-zoom property changes.

camerabin can signal a change in those properties and we need to communicate those back to the application
This commit is contained in:
Mohammed Hassan
2015-03-05 19:35:11 +02:00
committed by Martin Jones
parent 4822715845
commit a824c2da1a
2 changed files with 35 additions and 1 deletions

View File

@@ -45,7 +45,9 @@ CameraBinZoom::CameraBinZoom(CameraBinSession *session)
, m_requestedOpticalZoom(1.0)
, m_requestedDigitalZoom(1.0)
{
GstElement *camerabin = m_session->cameraBin();
g_signal_connect(G_OBJECT(camerabin), "notify::zoom", G_CALLBACK(updateZoom), this);
g_signal_connect(G_OBJECT(camerabin), "notify::max-zoom", G_CALLBACK(updateMaxZoom), this);
}
CameraBinZoom::~CameraBinZoom()
@@ -108,4 +110,32 @@ void CameraBinZoom::zoomTo(qreal optical, qreal digital)
emit currentDigitalZoomChanged(digital);
}
void CameraBinZoom::updateZoom(GObject *o, GParamSpec *p, gpointer d)
{
Q_UNUSED(p);
gfloat zoomFactor = 1.0;
g_object_get(o, ZOOM_PROPERTY, &zoomFactor, NULL);
CameraBinZoom *zoom = reinterpret_cast<CameraBinZoom *>(d);
QMetaObject::invokeMethod(zoom, "currentDigitalZoomChanged",
Qt::QueuedConnection,
Q_ARG(qreal, zoomFactor));
}
void CameraBinZoom::updateMaxZoom(GObject *o, GParamSpec *p, gpointer d)
{
Q_UNUSED(p);
gfloat zoomFactor = 1.0;
g_object_get(o, MAX_ZOOM_PROPERTY, &zoomFactor, NULL);
CameraBinZoom *zoom = reinterpret_cast<CameraBinZoom *>(d);
QMetaObject::invokeMethod(zoom, "maximumOpticalZoomChanged",
Qt::QueuedConnection,
Q_ARG(qreal, zoomFactor));
}
QT_END_NAMESPACE

View File

@@ -35,6 +35,7 @@
#define CAMERABINZOOMCONTROL_H
#include <qcamerazoomcontrol.h>
#include <gst/gst.h>
QT_BEGIN_NAMESPACE
@@ -58,6 +59,9 @@ public:
void zoomTo(qreal optical, qreal digital);
private:
static void updateZoom(GObject *o, GParamSpec *p, gpointer d);
static void updateMaxZoom(GObject *o, GParamSpec *p, gpointer d);
CameraBinSession *m_session;
qreal m_requestedOpticalZoom;
qreal m_requestedDigitalZoom;