X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=lib%2Fqtcamaperture.cpp;h=5bd5a612a293f3bc3c70afe1e8530b14721ae8c9;hp=0171290522b62e9e6b188dd04d8155722b4c78c2;hb=f15b7b41a0fd2cade6cd0bb3771c2c0da14db3c8;hpb=7ccbbf507e953850f8ca23735ba8bf5eaa18db81 diff --git a/lib/qtcamaperture.cpp b/lib/qtcamaperture.cpp index 0171290..5bd5a61 100644 --- a/lib/qtcamaperture.cpp +++ b/lib/qtcamaperture.cpp @@ -1,13 +1,30 @@ +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012-2013 Mohammed Sameer + * + * 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 + */ + #include "qtcamaperture.h" #include "qtcamcapability_p.h" -#define APERTURE_MIN 0 -#define APERTURE_MAX 255 - QtCamAperture::QtCamAperture(QtCamDevice *dev, QObject *parent) : QtCamCapability(new QtCamCapabilityPrivate(dev, QtCamCapability::Aperture, "aperture"), parent) { - // TODO: QML + } QtCamAperture::~QtCamAperture() { @@ -15,11 +32,9 @@ QtCamAperture::~QtCamAperture() { } unsigned int QtCamAperture::value() { - unsigned int val = 0; + unsigned int val = defaultValue(); - if (!d_ptr->uintValue(&val)) { - return 0; - } + d_ptr->uintValue(&val); return val; } @@ -29,9 +44,31 @@ bool QtCamAperture::setValue(unsigned int val) { } unsigned int QtCamAperture::minimumValue() { - return APERTURE_MIN; + GParamSpec *p = d_ptr->paramSpec(); + + if (p && G_IS_PARAM_SPEC_UINT(p)) { + return G_PARAM_SPEC_UINT(p)->minimum; + } + + return 0; } unsigned int QtCamAperture::maximumValue() { - return APERTURE_MAX; + GParamSpec *p = d_ptr->paramSpec(); + + if (p && G_IS_PARAM_SPEC_UINT(p)) { + return G_PARAM_SPEC_UINT(p)->maximum; + } + + return 0; +} + +unsigned int QtCamAperture::defaultValue() { + GParamSpec *p = d_ptr->paramSpec(); + + if (p && G_IS_PARAM_SPEC_UINT(p)) { + return G_PARAM_SPEC_UINT(p)->default_value; + } + + return 0; }