Added currentResolutionMegapixel property to ImageSettings
authorMohammed Sameer <msameer@foolab.org>
Thu, 8 Aug 2013 21:33:32 +0000 (00:33 +0300)
committerMohammed Sameer <msameer@foolab.org>
Thu, 8 Aug 2013 21:33:32 +0000 (00:33 +0300)
declarative/imagesettings.cpp
declarative/imagesettings.h

index 6d12097..327b8da 100644 (file)
@@ -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());
+}
index ecebb16..9a7b485 100644 (file)
@@ -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();