Now we set the camera mode when the settings mode changes
[harmattan/cameraplus] / qml / ModeController.qml
1 // -*- qml -*-
2 import QtQuick 1.1
3 import com.nokia.meego 1.1
4 import QtCamera 1.0
5
6 Item {
7         id: controller
8         property int mode: settings.mode
9         property Camera cam: null
10         property Item dimmer: null
11         property alias animationRunning: animation.running
12
13         SequentialAnimation {
14                 id: animation
15                 property int mode: 0
16
17                 function setMode() {
18                         cam.mode = mode;
19                 }
20
21                 NumberAnimation { target: dimmer; property: "opacity"; from: 0; to: 1; duration: 250; alwaysRunToEnd: true }
22                 ParallelAnimation {
23                         ScriptAction { script: animation.setMode(); }
24                         PauseAnimation { duration: 100 }
25                 }
26
27                 NumberAnimation { target: dimmer; property: "opacity"; from: 1; to: 0; duration: 250; alwaysRunToEnd: true }
28         }
29
30         onModeChanged: {
31                 set(mode);
32         }
33
34         function set(newMode) {
35                 if (cam.mode == newMode) {
36                         return;
37                 }
38
39                 animation.mode = newMode;
40
41                 animation.start();
42         }
43 }