Reworked CameraButton to get rid of meego bits
[harmattan/cameraplus] / qml / ImageResolutionSettings.qml
index b57570e..6cb05b1 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
-import com.nokia.meego 1.1
+import QtQuick 2.0
+import QtCamera 1.0
 
 Column {
-        spacing: 10
+    property Camera camera: null
 
-        SectionHeader {
-                text: qsTr("Aspect ratio");
-        }
+    spacing: 10
 
-        ButtonRow {
-                id: aspectRatioRow
-                width: parent.width
-                enabled: cam.idle
-                exclusive: false
+    SectionHeader {
+        text: qsTr("Aspect ratio")
+        visible: aspectRatioRow.visible
+    }
 
-                Repeater {
-                        model: imageSettings.aspectRatios
-                        delegate: Button {
-                                text: qsTr(modelData);
-                                checked: settings.imageAspectRatio == modelData;
-                                onClicked: settings.imageAspectRatio = modelData;
-                        }
-                }
-        }
+    CameraButtonRow {
+        id: aspectRatioRow
+        width: parent.width
+        enabled: camera ? camera.idle : false
+        exclusive: false
+        visible: imageSettings.aspectRatioCount > 1
 
-        SectionHeader {
-                text: qsTr("Resolution");
+        Repeater {
+            id: aspectRatios
+            model: imageSettings.aspectRatios
+            delegate: CameraButton {
+                width: aspectRatioRow.width / aspectRatios.count
+                text: qsTr(modelData)
+                checked: settings.imageAspectRatio == modelData
+                onClicked: settings.imageAspectRatio = modelData
+            }
         }
+    }
 
-        ButtonRow {
-                id: resolutionsRow
-                width: parent.width
-                enabled: cam.idle
-                exclusive: false
+    SectionHeader {
+        text: qsTr("Resolution")
+        visible: resolutionsRow.visible
+    }
 
-                Binding {
-                        target: imageSettings.resolutions
-                        property: "aspectRatio"
-                        value: settings.imageAspectRatio
-                }
+    CameraButtonRow {
+        id: resolutionsRow
+        width: parent.width
+        enabled: camera ? camera.idle : false
+        exclusive: false
+        visible: imageSettings.resolutions.count > 1
+
+        Binding {
+            target: imageSettings.resolutions
+            property: "aspectRatio"
+            value: settings.imageAspectRatio
+        }
 
-                Repeater {
-                        id: resolutions
-                        model: imageSettings.resolutions.aspectRatio == settings.imageAspectRatio ? imageSettings.resolutions : undefined
+        Repeater {
+            id: resolutions
+            model: imageSettings.resolutions.aspectRatio == settings.imageAspectRatio ?
+                imageSettings.resolutions : undefined
 
-                        delegate: Button {
-                                font.capitalization: Font.Capitalize
-                                text: qsTr("%1 %2 Mpx").arg(resolutionName).arg(megaPixels);
-                                checked: settings.imageResolution == resolutionName
-                                onClicked: settings.imageResolution = resolutionName;
-                        }
-                }
+            delegate: CameraButton {
+                width: resolutionsRow.width / resolutions.count
+                capitalize: true
+                text: qsTr("%1 %2 Mpx").arg(resolutionName).arg(megaPixels)
+                checked: settings.imageResolution == resolutionName
+                onClicked: settings.imageResolution = resolutionName
+            }
         }
+    }
 }