4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef QT_CAM_CAPABILITY_P_H
24 #define QT_CAM_CAPABILITY_P_H
27 #include "qtcamcapability.h"
28 #include "qtcamdevice.h"
29 #include "qtcamdevice_p.h"
31 class QtCamCapabilityPrivate {
33 QtCamCapabilityPrivate(QtCamDevice *d, const QtCamCapability::Capability& c, const QString& p) :
44 QtCamCapabilityPrivate(QtCamDevice *d, const QtCamCapability::Capability& c) :
54 virtual ~QtCamCapabilityPrivate() {
58 GParamSpec *paramSpec() {
59 if (!src || prop.isEmpty()) {
63 return g_object_class_find_property(G_OBJECT_GET_CLASS(src), prop.toUtf8().constData());
66 void startMonitoring() {
68 QString p = QString("notify::%1").arg(prop);
69 handler = g_signal_connect(src, p.toLatin1().data(), G_CALLBACK(camera_src_notify), this);
73 void stopMonitoring() {
75 g_signal_handler_disconnect(src, handler);
79 bool uintValue(unsigned int *val) {
84 g_object_get(src, prop.toLatin1().data(), val, NULL);
89 bool setUintValue(unsigned int val) {
94 g_object_set(src, prop.toLatin1().data(), val, NULL);
99 bool intValue(int *val) {
104 g_object_get(src, prop.toLatin1().data(), val, NULL);
109 bool setIntValue(int val, bool force) {
115 g_object_set(src, prop.toLatin1().data(), val, NULL);
120 g_object_get(src, prop.toLatin1().data(), &old, NULL);
123 g_object_set(src, prop.toLatin1().data(), val, NULL);
129 bool floatValue(qreal *val) {
134 g_object_get(src, prop.toLatin1().data(), val, NULL);
139 bool setFloatValue(qreal val) {
144 g_object_set(src, prop.toLatin1().data(), val, NULL);
149 static void camera_src_notify(GObject *gobject, GParamSpec *pspec, QtCamCapabilityPrivate *d) {
153 QMetaObject::invokeMethod(d->q_ptr, "valueChanged", Qt::QueuedConnection);
157 QtCamCapability::Capability cap;
162 QtCamCapability *q_ptr;
165 #endif /* QT_CAM_CAPABILITY_P_H */