From b9fc7dacba3b692c7a0a019df6dcf59ed678dfa9 Mon Sep 17 00:00:00 2001 From: Mohammed Sameer Date: Fri, 9 Aug 2013 00:33:32 +0300 Subject: [PATCH] Added currentResolutionMegapixel property to ImageSettings --- declarative/imagesettings.cpp | 15 ++++++++++++++- declarative/imagesettings.h | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/declarative/imagesettings.cpp b/declarative/imagesettings.cpp index 6d12097..327b8da 100644 --- a/declarative/imagesettings.cpp +++ b/declarative/imagesettings.cpp @@ -108,7 +108,12 @@ bool ImageSettings::setResolution(const QString& aspectRatio, const QString& res foreach (const QtCamImageResolution& r, res) { if (r.name() == resolution) { - return m_cam->device()->imageMode()->setResolution(r); + bool set = m_cam->device()->imageMode()->setResolution(r); + if (set) { + emit currentResolutionMegapixelChanged(); + } + + return set; } } @@ -118,3 +123,11 @@ bool ImageSettings::setResolution(const QString& aspectRatio, const QString& res int ImageSettings::aspectRatioCount() const { return aspectRatios().count(); } + +QString ImageSettings::currentResolutionMegapixel() const { + if (!m_cam || !m_cam->device()) { + return QString(); + } + + return QString("%1").arg(m_cam->device()->imageMode()->currentResolution().megaPixels()); +} diff --git a/declarative/imagesettings.h b/declarative/imagesettings.h index ecebb16..9a7b485 100644 --- a/declarative/imagesettings.h +++ b/declarative/imagesettings.h @@ -39,6 +39,7 @@ class ImageSettings : public QObject { Q_PROPERTY(int aspectRatioCount READ aspectRatioCount NOTIFY aspectRatioCountChanged); Q_PROPERTY(ImageResolutionModel *resolutions READ resolutions NOTIFY resolutionsChanged); Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged); + Q_PROPERTY(QString currentResolutionMegapixel READ currentResolutionMegapixel NOTIFY currentResolutionMegapixelChanged); public: ImageSettings(QObject *parent = 0); @@ -58,12 +59,15 @@ public: int aspectRatioCount() const; + QString currentResolutionMegapixel() const; + signals: void settingsChanged(); void cameraChanged(); void resolutionsChanged(); void readyChanged(); void aspectRatioCountChanged(); + void currentResolutionMegapixelChanged(); private slots: void deviceChanged(); -- 2.25.1