/*!
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-import QtQuick 1.1
-import com.nokia.meego 1.1
-import "ImageSettingsDialog.js" as Util
+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
+ property string __aspectRatio: settings.device == 1 ?
+ settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio
+ property string __resolution: settings.device == 1 ?
+ settings.secondaryImageResolution : settings.primaryImageResolution
- exclusive: false
- onCheckedButtonChanged: {
- // This is needed to initially setup the
- // resolutions buttons
- Util.resetAspectRatio(aspectRatioRow);
- }
+ SectionHeader {
+ text: qsTr("Aspect ratio")
+ visible: aspectRatioRow.visible
+ }
- Repeater {
- model: imageSettings.aspectRatios
- delegate: Button {
- property string aspect: modelData;
- text: qsTr(modelData);
- checked: settings.imageAspectRatio == modelData;
- onClicked: Util.setAspectRatio(modelData);
- }
+ CameraButtonRow {
+ id: aspectRatioRow
+ width: parent.width
+ enabled: camera ? camera.idle : false
+ exclusive: false
+ visible: imageSettings.aspectRatioCount > 1
+
+ Repeater {
+ model: imageSettings.aspectRatios
+ delegate: CameraButton {
+ text: qsTr(modelData)
+ checked: __aspectRatio == modelData
+ onClicked: {
+ if (settings.device == 1) {
+ settings.secondaryImageAspectRatio = modelData
+ } else {
+ settings.primaryImageAspectRatio = modelData
+ }
}
+ }
}
+ }
- SectionHeader {
- text: qsTr("Resolution");
- }
+ SectionHeader {
+ text: qsTr("Resolution")
+ visible: resolutionsRow.visible
+ }
- ButtonRow {
- id: resolutionsRow
- width: parent.width
+ CameraButtonRow {
+ id: resolutionsRow
+ width: parent.width
+ enabled: camera ? camera.idle : false
+ exclusive: false
+ visible: imageSettings.resolutions.count > 1
- exclusive: false
+ Binding {
+ target: imageSettings.resolutions
+ property: "aspectRatio"
+ value: settings.primaryImageAspectRatio
+ when: settings.device == 0
+ }
+
+ Binding {
+ target: imageSettings.resolutions
+ property: "aspectRatio"
+ value: settings.secondaryImageAspectRatio
+ when: settings.device == 1
+ }
- Repeater {
- id: resolutions
- model: imageSettings.resolutions
+ Repeater {
+ id: resolutions
- // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
- function name(name, mp) {
- return name.charAt(0).toUpperCase() + name.slice(1) + " " + mp + " Mpx";
- }
+ model: imageSettings.resolutions.aspectRatio == __aspectRatio ?
+ imageSettings.resolutions : undefined
- delegate: Button {
- property string resolution: resolutionName
- property string aspectRatio: resolutionAspectRatio
- text: resolutions.name(resolutionName, megaPixels);
- checked: settings.imageResolution == resolutionName
- onClicked: Util.setResolution(resolutionName);
- }
+ delegate: CameraButton {
+ capitalize: true
+ text: qsTr("%1 %2 Mpx").arg(resolutionName).arg(megaPixels)
+ checked: __resolution == resolutionName
+ onClicked: {
+ if (settings.device == 1) {
+ settings.secondaryImageResolution = resolutionName
+ } else {
+ settings.primaryImageResolution = resolutionName
+ }
}
+ }
}
+ }
}