2 * This file is part of CameraPlus.
4 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "qtcamimagesettings.h"
22 #include <QSharedData>
24 class QtCamImageResolutionPrivate : public QSharedData {
37 class QtCamImageSettingsPrivate : public QSharedData {
43 QList<QtCamImageResolution> resolutions;
47 QtCamImageResolution::QtCamImageResolution(const QString& id, const QString& name,
48 const QSize& capture, const QSize& preview,
49 const QSize& viewfinder, int fps, int nightFps,
50 int megaPixels, QString aspectRatio) :
51 d_ptr(new QtCamImageResolutionPrivate) {
54 d_ptr->capture = capture;
55 d_ptr->preview = preview;
56 d_ptr->viewfinder = viewfinder;
58 d_ptr->nightFps = nightFps;
59 d_ptr->megaPixels = megaPixels;
60 d_ptr->aspectRatio = aspectRatio;
63 QtCamImageResolution::QtCamImageResolution(const QtCamImageResolution& other) :
68 QtCamImageResolution& QtCamImageResolution::operator=(const QtCamImageResolution& other) {
74 QtCamImageResolution::~QtCamImageResolution() {
75 // QSharedData will take care of reference counting.
78 QString QtCamImageResolution::id() const {
82 QString QtCamImageResolution::name() const {
86 QSize QtCamImageResolution::captureResolution() const {
87 return d_ptr->capture;
90 QSize QtCamImageResolution::viewfinderResolution() const {
91 return d_ptr->viewfinder;
94 QSize QtCamImageResolution::previewResolution() const {
95 return d_ptr->preview;
98 int QtCamImageResolution::frameRate() const {
102 int QtCamImageResolution::nightFrameRate() const {
103 return d_ptr->nightFps;
106 int QtCamImageResolution::megaPixels() const {
107 return d_ptr->megaPixels;
110 QString QtCamImageResolution::aspectRatio() const {
111 return d_ptr->aspectRatio;
114 QtCamImageSettings::QtCamImageSettings(const QString& id, const QString& suffix,
115 const QString& profileName, const QString& profilePath,
116 const QList<QtCamImageResolution>& resolutions) :
117 d_ptr(new QtCamImageSettingsPrivate) {
120 d_ptr->suffix = suffix;
121 d_ptr->profileName = profileName;
122 d_ptr->profilePath = profilePath;
123 d_ptr->resolutions = resolutions;
126 QtCamImageSettings::QtCamImageSettings(const QtCamImageSettings& other) :
131 QtCamImageSettings& QtCamImageSettings::operator=(const QtCamImageSettings& other) {
137 QtCamImageSettings::~QtCamImageSettings() {
138 // QSharedData will take care of reference counting.
141 QString QtCamImageSettings::id() const {
145 QString QtCamImageSettings::suffix() const {
146 return d_ptr->suffix;
149 QString QtCamImageSettings::profileName() const {
150 return d_ptr->profileName;
153 QString QtCamImageSettings::profilePath() const {
154 return d_ptr->profilePath;
157 QtCamImageResolution QtCamImageSettings::defaultResolution(const QString& aspectRatio) const {
158 if (aspectRatio.isEmpty()) {
159 return d_ptr->resolutions[0];
162 foreach (const QtCamImageResolution& r, d_ptr->resolutions) {
163 if (r.aspectRatio() == aspectRatio) {
168 return d_ptr->resolutions[0];
171 QList<QtCamImageResolution> QtCamImageSettings::resolutions(const QString& aspectRatio) const {
172 if (aspectRatio.isEmpty()) {
173 return d_ptr->resolutions;
176 QList<QtCamImageResolution> res;
178 foreach (const QtCamImageResolution& r, d_ptr->resolutions) {
179 if (r.aspectRatio() == aspectRatio) {
184 return d_ptr->resolutions;
187 QStringList QtCamImageSettings::aspectRatios() const {
190 foreach (const QtCamImageResolution& r, d_ptr->resolutions) {
191 if (aspects.indexOf(r.aspectRatio()) == -1) {
192 aspects << r.aspectRatio();