Use the new Selector instead of the existing mess
authorMohammed Sameer <msameer@foolab.org>
Sat, 1 Sep 2012 13:33:29 +0000 (16:33 +0300)
committerMohammed Sameer <msameer@foolab.org>
Sat, 1 Sep 2012 13:33:29 +0000 (16:33 +0300)
qml/CheckButton.qml
qml/FlashButton.qml
qml/ImagePage.qml
qml/SceneButton.qml

index c0063ff..0864f1e 100644 (file)
@@ -10,9 +10,8 @@ Button {
         property QtObject fader: null
         property int value: -1
 
-        visible: fader.enabled
         width: visible ? 64 : 0
         height: visible ? 64 : 0
         iconSource: !visible ? "" : controller.value == value ? checkedIcon : normalIcon
-        onClicked: { controller.value = value; fader.enabled = !fader.enabled }
+        onClicked: { controller.value = value; close(); }
 }
index c9b3ae0..5804579 100644 (file)
@@ -3,29 +3,10 @@ import QtQuick 1.1
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
-MouseArea {
-        id: mouse
-        anchors.fill: parent
-        enabled: false
-        onClicked: enabled = !enabled;
-        onEnabledChanged: button.checked = enabled;
+Selector {
+        id: button
 
-        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;
-                        }
-                }
-        }
-
-        Timer {
-                interval: 2000
-                running: mouse.enabled
-                repeat: false
-                onTriggered: mouse.enabled = !mouse.enabled
-        }
+        iconSource: flashIcon(flash.value);
 
         Flash {
                 id: flash
@@ -34,21 +15,20 @@ MouseArea {
                 value: Flash.Auto
         }
 
-        Button {
-                anchors.left: parent.left
-                id: button
-                width: 64
-                height: 64
-                opacity: 0.5
-                onClicked: mouse.enabled = !mouse.enabled;
-                checkable: true
-                iconSource: flashIcon(flash.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;
+                        }
+                }
         }
 
-        Row {
+        widget: Row {
                 id: row
-                height: mouse.enabled ? 64 : 0
-                width: mouse.enabled ? (children.length * height) +  (children.length - 1) * spacing : 0
+                height: button.checked ? 64 : 0
+                width: button.checked ? (children.length * height) +  (children.length - 1) * spacing : 0
                 anchors.left: button.right
                 anchors.leftMargin: 20
                 spacing: 10
@@ -63,7 +43,6 @@ MouseArea {
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-auto-pressed.png"
                         controller: flash
                         value: Flash.Auto
-                        fader: mouse
                 }
 
                 CheckButton {
@@ -71,7 +50,6 @@ MouseArea {
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-always-pressed.png"
                         controller: flash
                         value: Flash.On
-                        fader: mouse
                 }
 
                 CheckButton {
@@ -79,7 +57,6 @@ MouseArea {
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-off-pressed.png"
                         controller: flash
                         value: Flash.Off
-                        fader: mouse
                 }
 
                 CheckButton {
@@ -87,7 +64,6 @@ MouseArea {
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-red-eye-pressed.png"
                         controller: flash
                         value: Flash.RedEye
-                        fader: mouse
                 }
         }
 }
index 51c5729..157ff33 100644 (file)
@@ -25,6 +25,7 @@ CameraPage {
                 id: imageMode
                 camera: cam
                 onPreviewAvailable: page.setPreview(preview);
+                // TODO: this is not working
                 nightMode: scene.sceneValue == Scene.Night
         }
 
index 34cf69e..7f02177 100644 (file)
@@ -3,14 +3,17 @@ import QtQuick 1.1
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
-MouseArea {
-        id: mouse
-        anchors.fill: parent
-        enabled: false
-        onClicked: enabled = !enabled;
-        onEnabledChanged: button.checked = enabled;
+Selector {
+        id: button
 
-        property alias sceneValue: scene.value
+        iconSource: sceneIcon(scene.value);
+
+        Scene {
+                id: scene
+                camera: cam
+                // TODO: hardcoding
+                value: Scene.Auto
+        }
 
         function sceneIcon(val) {
                 var x = row.children.length;
@@ -22,35 +25,10 @@ MouseArea {
                 }
         }
 
-        Timer {
-                interval: 2000
-                running: mouse.enabled
-                repeat: false
-                onTriggered: mouse.enabled = !mouse.enabled
-        }
-
-        Scene {
-                id: scene
-                camera: cam
-                // TODO: hardcoding
-                value: Scene.Auto
-        }
-
-        Button {
-                anchors.left: parent.left
-                id: button
-                width: 64
-                height: 64
-                opacity: 0.5
-                onClicked: mouse.enabled = !mouse.enabled;
-                checkable: true
-                iconSource: sceneIcon(scene.value);
-        }
-
-        Row {
+        widget: Row {
                 id: row
-                height: mouse.enabled ? 64 : 0
-                width: mouse.enabled ? (children.length * height) +  (children.length - 1) * spacing : 0
+                height: button.checked ? 64 : 0
+                width: button.checked ? (children.length * height) +  (children.length - 1) * spacing : 0
                 anchors.left: button.right
                 anchors.leftMargin: 20
                 spacing: 10
@@ -65,42 +43,41 @@ MouseArea {
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-auto-selected.png"
                         controller: scene
                         value: Scene.Auto
-                        fader: mouse
                 }
+
                 CheckButton {
                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-macro.png"
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-macro-selected.png"
                         controller: scene
                         value: Scene.Closeup
-                        fader: mouse
                 }
+
                 CheckButton {
                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-landscape.png"
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-landscape-selected.png"
                         controller: scene
                         value: Scene.Landscape
-                        fader: mouse
                 }
+
                 CheckButton {
                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-portrait.png"
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-portrait-selected.png"
                         controller: scene
                         value: Scene.Portrait
-                        fader: mouse
                 }
+
                 CheckButton {
                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-night.png"
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-night-selected.png"
                         controller: scene
                         value: Scene.Night
-                        fader: mouse
                 }
+
                 CheckButton {
                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-sports.png"
                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-scene-sports-selected.png"
                         controller: scene
                         value: Scene.Sport
-                        fader: mouse
                 }
         }
 }