X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=lib%2Fqtcamimagesettings.cpp;h=3bf1a08e6ec516538545a35fed7a689d9412ba44;hp=0208fd13b10cf0d696f967ca3b7ca38053b17418;hb=3fa3497f2a03fcb1d483638efc831b72aac574c3;hpb=8fda608e8809c2b5c1b0db2a10e6099b73759ce8 diff --git a/lib/qtcamimagesettings.cpp b/lib/qtcamimagesettings.cpp index 0208fd1..3bf1a08 100644 --- a/lib/qtcamimagesettings.cpp +++ b/lib/qtcamimagesettings.cpp @@ -1,7 +1,7 @@ /*! * This file is part of CameraPlus. * - * Copyright (C) 2012 Mohammed Sameer + * 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 @@ -19,8 +19,10 @@ */ #include "qtcamimagesettings.h" +#include +#include -class QtCamImageSettingsPrivate { +class QtCamImageResolutionPrivate : public QSharedData { public: QString id; QString name; @@ -29,14 +31,25 @@ public: QSize viewfinder; int fps; int nightFps; + int megaPixels; + QString aspectRatio; }; -QtCamImageSettings::QtCamImageSettings(const QString& id, const QString& name, - const QSize& capture, const QSize& preview, - const QSize& viewfinder, - int fps, int nightFps) : - d_ptr(new QtCamImageSettingsPrivate) { +class QtCamImageSettingsPrivate : public QSharedData { +public: + QString id; + QString suffix; + QString profileName; + QString profilePath; + QList resolutions; +}; + +QtCamImageResolution::QtCamImageResolution(const QString& id, const QString& name, + const QSize& capture, const QSize& preview, + const QSize& viewfinder, int fps, int nightFps, + int megaPixels, QString aspectRatio) : + d_ptr(new QtCamImageResolutionPrivate) { d_ptr->id = id; d_ptr->name = name; d_ptr->capture = capture; @@ -44,61 +57,148 @@ QtCamImageSettings::QtCamImageSettings(const QString& id, const QString& name, d_ptr->viewfinder = viewfinder; d_ptr->fps = fps; d_ptr->nightFps = nightFps; + d_ptr->megaPixels = megaPixels; + d_ptr->aspectRatio = aspectRatio; } -QtCamImageSettings::QtCamImageSettings(const QtCamImageSettings& other) : - d_ptr(new QtCamImageSettingsPrivate) { +QtCamImageResolution::QtCamImageResolution(const QtCamImageResolution& other) : + d_ptr(other.d_ptr) { - d_ptr->id = other.d_ptr->id; - d_ptr->name = other.d_ptr->name; - d_ptr->capture = other.d_ptr->capture; - d_ptr->preview = other.d_ptr->preview; - d_ptr->viewfinder = other.d_ptr->viewfinder; - d_ptr->fps = other.d_ptr->fps; - d_ptr->nightFps = other.d_ptr->nightFps; } -QtCamImageSettings::~QtCamImageSettings() { - delete d_ptr; -} - -QtCamImageSettings& QtCamImageSettings::operator=(const QtCamImageSettings& - other) { - d_ptr->id = other.d_ptr->id; - d_ptr->name = other.d_ptr->name; - d_ptr->capture = other.d_ptr->capture; - d_ptr->preview = other.d_ptr->preview; - d_ptr->viewfinder = other.d_ptr->viewfinder; - d_ptr->fps = other.d_ptr->fps; - d_ptr->nightFps = other.d_ptr->nightFps; +QtCamImageResolution& QtCamImageResolution::operator=(const QtCamImageResolution& other) { + d_ptr = other.d_ptr; return *this; } -QString QtCamImageSettings::id() const { +QtCamImageResolution::~QtCamImageResolution() { + // QSharedData will take care of reference counting. +} + +QString QtCamImageResolution::id() const { return d_ptr->id; } -QString QtCamImageSettings::name() const { +QString QtCamImageResolution::name() const { return d_ptr->name; } -QSize QtCamImageSettings::captureResolution() const { +QSize QtCamImageResolution::captureResolution() const { return d_ptr->capture; } -QSize QtCamImageSettings::viewfinderResolution() const { +QSize QtCamImageResolution::viewfinderResolution() const { return d_ptr->viewfinder; } -QSize QtCamImageSettings::previewResolution() const { +QSize QtCamImageResolution::previewResolution() const { return d_ptr->preview; } -int QtCamImageSettings::frameRate() const { +int QtCamImageResolution::frameRate() const { return d_ptr->fps; } -int QtCamImageSettings::nightFrameRate() const { +int QtCamImageResolution::nightFrameRate() const { return d_ptr->nightFps; } + +int QtCamImageResolution::megaPixels() const { + return d_ptr->megaPixels; +} + +QString QtCamImageResolution::aspectRatio() const { + return d_ptr->aspectRatio; +} + +QtCamImageSettings::QtCamImageSettings(const QString& id, const QString& suffix, + const QString& profileName, const QString& profilePath, + const QList& resolutions) : + d_ptr(new QtCamImageSettingsPrivate) { + + d_ptr->id = id; + d_ptr->suffix = suffix; + d_ptr->profileName = profileName; + d_ptr->profilePath = profilePath; + d_ptr->resolutions = resolutions; +} + +QtCamImageSettings::QtCamImageSettings(const QtCamImageSettings& other) : + d_ptr(other.d_ptr) { + +} + +QtCamImageSettings& QtCamImageSettings::operator=(const QtCamImageSettings& other) { + d_ptr = other.d_ptr; + + return *this; +} + +QtCamImageSettings::~QtCamImageSettings() { + // QSharedData will take care of reference counting. +} + +QString QtCamImageSettings::id() const { + return d_ptr->id; +} + +QString QtCamImageSettings::suffix() const { + return d_ptr->suffix; +} + +QString QtCamImageSettings::profileName() const { + return d_ptr->profileName; +} + +QString QtCamImageSettings::profilePath() const { + return d_ptr->profilePath; +} + +QtCamImageResolution QtCamImageSettings::defaultResolution(const QString& aspectRatio) const { + if (d_ptr->resolutions.isEmpty()) { + return QtCamImageResolution(QString(), QString(), + QSize(), QSize(), QSize(), + -1, -1, -1, QString()); + } + + if (aspectRatio.isEmpty()) { + return d_ptr->resolutions[0]; + } + + foreach (const QtCamImageResolution& r, d_ptr->resolutions) { + if (r.aspectRatio() == aspectRatio) { + return r; + } + } + + return d_ptr->resolutions[0]; +} + +QList QtCamImageSettings::resolutions(const QString& aspectRatio) const { + if (aspectRatio.isEmpty()) { + return d_ptr->resolutions; + } + + QList res; + + foreach (const QtCamImageResolution& r, d_ptr->resolutions) { + if (r.aspectRatio() == aspectRatio) { + res << r; + } + } + + return res; +} + +QStringList QtCamImageSettings::aspectRatios() const { + QStringList aspects; + + foreach (const QtCamImageResolution& r, d_ptr->resolutions) { + if (aspects.indexOf(r.aspectRatio()) == -1) { + aspects << r.aspectRatio(); + } + } + + return aspects; +}