Initial ui reimplementation. Still in its early phase.
[harmattan/cameraplus] / qml / ImageResolutionSettings.qml
index 344aa33..bfd1309 100644 (file)
@@ -3,7 +3,7 @@
 /*!
  * This file is part of CameraPlus.
  *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 
 import QtQuick 1.1
 import com.nokia.meego 1.1
-import "ImageSettingsDialog.js" as Util
 
 Column {
-        spacing: 10
+    spacing: 10
 
-        SectionHeader {
-                text: qsTr("Aspect ratio");
-        }
-
-        ButtonRow {
-                id: aspectRatioRow
-                width: parent.width
+    SectionHeader {
+        text: qsTr("Aspect ratio")
+    }
 
-                exclusive: false
-                onCheckedButtonChanged: {
-                        // This is needed to initially setup the
-                        // resolutions buttons
-                        Util.resetAspectRatio(aspectRatioRow);
-                }
+    ButtonRow {
+        id: aspectRatioRow
+        width: parent.width
+        enabled: cam.idle
+        exclusive: false
 
-                Repeater {
-                        model: imageSettings.aspectRatios
-                        delegate: Button {
-                                property string aspect: modelData;
-                                text: qsTr(modelData);
-                                checked: settings.imageAspectRatio == modelData;
-                                onClicked: Util.setAspectRatio(modelData);
-                        }
-                }
+        Repeater {
+            model: imageSettings.aspectRatios
+            delegate: Button {
+                text: qsTr(modelData)
+                checked: settings.imageAspectRatio == modelData
+                onClicked: settings.imageAspectRatio = modelData
+            }
         }
+    }
 
-        SectionHeader {
-                text: qsTr("Resolution");
-        }
+    SectionHeader {
+        text: qsTr("Resolution")
+    }
 
-        ButtonRow {
-                id: resolutionsRow
-                width: parent.width
+    ButtonRow {
+        id: resolutionsRow
+        width: parent.width
+        enabled: cam.idle
+        exclusive: false
 
-                exclusive: false
+        Binding {
+            target: imageSettings.resolutions
+            property: "aspectRatio"
+            value: settings.imageAspectRatio
+        }
 
-                Repeater {
-                        id: resolutions
-                        model: imageSettings.resolutions
+        Repeater {
+            id: resolutions
+            model: imageSettings.resolutions.aspectRatio == settings.imageAspectRatio ?
+                imageSettings.resolutions : undefined
 
-                        delegate: Button {
-                                property string resolution: resolutionName
-                                property string aspectRatio: resolutionAspectRatio
-                                font.capitalization: Font.Capitalize
-                                text: qsTr("%1 %2 Mpx").arg(resolutionName).arg(megaPixels);
-                                checked: settings.imageResolution == resolutionName
-                                onClicked: Util.setResolution(resolutionName);
-                        }
-                }
+            delegate: Button {
+                font.capitalization: Font.Capitalize
+                text: qsTr("%1 %2 Mpx").arg(resolutionName).arg(megaPixels)
+                checked: settings.imageResolution == resolutionName
+                onClicked: settings.imageResolution = resolutionName
+            }
         }
+    }
 }