2 * This file is part of CameraPlus.
4 * Copyright (C) 2012-2013 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>
25 class QtCamImageResolutionPrivate : public QSharedData {
38 class QtCamImageSettingsPrivate : public QSharedData {
44 QList<QtCamImageResolution> resolutions;
48 QtCamImageResolution::QtCamImageResolution(const QString& id, const QString& name,
49 const QSize& capture, const QSize& preview,
50 const QSize& viewfinder, int fps, int nightFps,
51 int megaPixels, QString aspectRatio) :
52 d_ptr(new QtCamImageResolutionPrivate) {
55 d_ptr->capture = capture;
56 d_ptr->preview = preview;
57 d_ptr->viewfinder = viewfinder;
59 d_ptr->nightFps = nightFps;
60 d_ptr->megaPixels = megaPixels;
61 d_ptr->aspectRatio = aspectRatio;
64 QtCamImageResolution::QtCamImageResolution(const QtCamImageResolution& other) :
69 QtCamImageResolution& QtCamImageResolution::operator=(const QtCamImageResolution& other) {
75 QtCamImageResolution::~QtCamImageResolution() {
76 // QSharedData will take care of reference counting.
79 QString QtCamImageResolution::id() const {
83 QString QtCamImageResolution::name() const {
87 QSize QtCamImageResolution::captureResolution() const {
88 return d_ptr->capture;
91 QSize QtCamImageResolution::viewfinderResolution() const {
92 return d_ptr->viewfinder;
95 QSize QtCamImageResolution::previewResolution() const {
96 return d_ptr->preview;
99 int QtCamImageResolution::frameRate() const {
103 int QtCamImageResolution::nightFrameRate() const {
104 return d_ptr->nightFps;
107 int QtCamImageResolution::megaPixels() const {
108 return d_ptr->megaPixels;
111 QString QtCamImageResolution::aspectRatio() const {
112 return d_ptr->aspectRatio;
115 QtCamImageSettings::QtCamImageSettings(const QString& id, const QString& suffix,
116 const QString& profileName, const QString& profilePath,
117 const QList<QtCamImageResolution>& resolutions) :
118 d_ptr(new QtCamImageSettingsPrivate) {
121 d_ptr->suffix = suffix;
122 d_ptr->profileName = profileName;
123 d_ptr->profilePath = profilePath;
124 d_ptr->resolutions = resolutions;
127 QtCamImageSettings::QtCamImageSettings(const QtCamImageSettings& other) :
132 QtCamImageSettings& QtCamImageSettings::operator=(const QtCamImageSettings& other) {
138 QtCamImageSettings::~QtCamImageSettings() {
139 // QSharedData will take care of reference counting.
142 QString QtCamImageSettings::id() const {
146 QString QtCamImageSettings::suffix() const {
147 return d_ptr->suffix;
150 QString QtCamImageSettings::profileName() const {
151 return d_ptr->profileName;
154 QString QtCamImageSettings::profilePath() const {
155 return d_ptr->profilePath;
158 QtCamImageResolution QtCamImageSettings::defaultResolution(const QString& aspectRatio) const {
159 if (aspectRatio.isEmpty()) {
160 return d_ptr->resolutions[0];
163 foreach (const QtCamImageResolution& r, d_ptr->resolutions) {
164 if (r.aspectRatio() == aspectRatio) {
169 return d_ptr->resolutions[0];
172 QList<QtCamImageResolution> QtCamImageSettings::resolutions(const QString& aspectRatio) const {
173 if (aspectRatio.isEmpty()) {
174 return d_ptr->resolutions;
177 QList<QtCamImageResolution> res;
179 foreach (const QtCamImageResolution& r, d_ptr->resolutions) {
180 if (r.aspectRatio() == aspectRatio) {
188 QStringList QtCamImageSettings::aspectRatios() const {
191 foreach (const QtCamImageResolution& r, d_ptr->resolutions) {
192 if (aspects.indexOf(r.aspectRatio()) == -1) {
193 aspects << r.aspectRatio();