Move all flash icons to data.js
authorMohammed Sameer <msameer@foolab.org>
Sat, 13 Oct 2012 19:58:58 +0000 (22:58 +0300)
committerMohammed Sameer <msameer@foolab.org>
Sat, 13 Oct 2012 19:58:58 +0000 (22:58 +0300)
qml/FlashButton.qml
qml/data.js
qml/main.qml

index b965d0d..08bfd9e 100644 (file)
 import QtQuick 1.1
 import com.nokia.meego 1.1
 import QtCamera 1.0
+import "data.js" as Data
 
 Selector {
         id: button
 
         property alias value: flash.value
 
-        iconSource: flashIcon(flash.value);
+        iconSource: "image://theme/" + Data.flashIcon(settings.imageFlashMode)
 
         title: qsTr("Flash mode");
 
@@ -38,20 +39,10 @@ Selector {
                 id: flash
                 camera: cam
                 value: settings.imageFlashMode
-               // TODO: scene modes can change flash value. what to do here ?
+                       // TODO: scene modes can change flash value. what to do here ?
                 onValueChanged: settings.imageFlashMode = value;
         }
 
-        function flashIcon(val) {
-                var x = row.children.length;
-                var i = 0;
-                for (i = 0; i < x; i++) {
-                        if (row.children[i].value == val) {
-                                return row.children[i].normalIcon;
-                        }
-                }
-        }
-
         widget: Row {
                 id: row
                 height: button.checked ? 64 : 0
@@ -64,32 +55,32 @@ Selector {
                 }
 
                 CheckButton {
-                        normalIcon: "image://theme/icon-m-camera-flash-auto"
-                        checkedIcon: "image://theme/icon-m-camera-flash-auto-pressed"
+                        normalIcon: "image://theme/" + Data.flashIcon(value)
+                        checkedIcon: "image://theme/" + Data.flashPressedIcon(value)
                         onClicked: settings.imageFlashMode = value;
                         value: Flash.Auto
                         savedValue: settings.imageFlashMode
                 }
 
                 CheckButton {
-                        normalIcon: "image://theme/icon-m-camera-flash-always"
-                        checkedIcon: "image://theme/icon-m-camera-flash-always-pressed"
+                        normalIcon: "image://theme/" + Data.flashIcon(value)
+                        checkedIcon: "image://theme/" + Data.flashPressedIcon(value)
                         onClicked: settings.imageFlashMode = value;
                         value: Flash.On
                         savedValue: settings.imageFlashMode
                 }
 
                 CheckButton {
-                        normalIcon: "image://theme/icon-m-camera-flash-off"
-                        checkedIcon: "image://theme/icon-m-camera-flash-off-pressed"
+                        normalIcon: "image://theme/" + Data.flashIcon(value)
+                        checkedIcon: "image://theme/" + Data.flashPressedIcon(value)
                         onClicked: settings.imageFlashMode = value;
                         value: Flash.Off
                         savedValue: settings.imageFlashMode
                 }
 
                 CheckButton {
-                        normalIcon: "image://theme/icon-m-camera-flash-red-eye"
-                        checkedIcon: "image://theme/icon-m-camera-flash-red-eye-pressed"
+                        normalIcon: "image://theme/" + Data.flashIcon(value)
+                        checkedIcon: "image://theme/" + Data.flashPressedIcon(value)
                         onClicked: settings.imageFlashMode = value;
                         value: Flash.RedEye
                         savedValue: settings.imageFlashMode
index 58b2c8a..125341d 100644 (file)
@@ -77,6 +77,14 @@ var __vsm = [
      "icon-m-camera-video-night-selected", "icon-m-camera-video-night"]
 ];
 
+var __flash = [
+    [Flash.Auto,"icon-m-camera-flash-auto-pressed", "icon-m-camera-flash-auto"],
+    [Flash.On, "icon-m-camera-flash-always-pressed", "icon-m-camera-flash-always"],
+    [Flash.Off, "icon-m-camera-flash-off-pressed", "icon-m-camera-flash-off"],
+    [Flash.RedEye, "icon-m-camera-flash-red-eye-pressed", "icon-m-camera-flash-red-eye"]
+];
+
+// ISO
 var __iso = [
     [0, "icon-m-camera-iso-auto"],
     [100, "icon-m-camera-iso-100"],
@@ -85,6 +93,7 @@ var __iso = [
     [800, "icon-m-camera-iso-800"]
 ];
 
+// Image resolutions
 var __image = [
     ["3:2", "low", "icon-m-camera-resolution-3m"],
     ["3:2", "medium", "icon-m-camera-resolution-6m"],
@@ -97,6 +106,7 @@ var __image = [
     ["16:9", "high", "icon-m-camera-resolution-7m"]
 ];
 
+// Video resolutions
 var __video = [
     ["low", "icon-m-camera-video-low-resolution"],
     ["medium", "icon-m-camera-video-fine-resolution"],
@@ -188,3 +198,11 @@ function imageIcon(aspect, res) {
 function videoIcon(res) {
     return filterData(res, __video, 1);
 }
+
+function flashIcon(val) {
+    return filterData(val, __flash, 2);
+}
+
+function flashPressedIcon(val) {
+    return filterData(val, __flash, 1);
+}
index 19fa76d..b124fc6 100644 (file)
@@ -40,6 +40,8 @@ import QtMobility.location 1.2
 // TODO: disable debug builds.
 // TODO: a way to get buffers to the application
 // TODO: fcam like functionality (precise control over capture parameters).
+// TODO: changing scene mode doesn't affect the existing properties ?
+// TODO: upon startup all properties don't load correct values.
 
 PageStackWindow {
         id: root