Added an error() signal to declarative Camera and show an error when it gets emitted
[harmattan/cameraplus] / qml / ModeButton.qml
1 // -*- qml -*-
2
3 import QtQuick 1.1
4 import QtCamera 1.0
5
6 Rectangle {
7         id: button
8         property int mode: settings.mode
9
10         color: "black"
11         width: 60
12         height: 120
13         smooth: true
14         radius: width
15         border.width: 2
16         border.color: "gray"
17
18         visible: cam.running && cam.idle && !cameraMode.animationRunning
19
20         Rectangle {
21                 id: highlighter
22                 width: parent.width
23                 height: parent.width
24                 color: mouse.pressed ? "lightblue" : "white"
25                 radius: parent.width
26                 y: mode == 1 ? video.y : image.y
27         }
28
29         Column {
30                 Image {
31                         id: image
32                         width: button.width
33                         height: width
34                         property string released: "icon-m-viewfinder-camera"
35                         property string active: "icon-m-viewfinder-camera-selected"
36                         source: mouse.pressed ? "image://theme/" + released : button.mode == 0 ? "image://theme/" + active : "image://theme/" + released
37                 }
38
39                 Image {
40                         id: video
41                         width: button.width
42                         height: width
43                         property string released: "icon-m-camera-video-record"
44                         property string active: "icon-m-camera-video-selected"
45                         source: mouse.pressed ? "image://theme/" + released : button.mode == 1 ? "image://theme/" + active : "image://theme/" + released
46                 }
47         }
48
49         MouseArea {
50                 anchors.fill: parent
51                 id: mouse
52                 drag.target: highlighter
53                 drag.axis: Drag.YAxis
54                 drag.minimumY: 0
55                 drag.maximumY: parent.height / 2
56                 onReleased: {
57
58                         if (!drag.active) {
59                                 if (mode == 0) {
60                                         settings.mode = Camera.VideoMode;
61                                 }
62                                 else {
63                                         settings.mode = Camera.ImageMode;
64                                 }
65
66                                 return;
67                         }
68
69                         if (mouse.y >= video.y) {
70                                 settings.mode = Camera.VideoMode;
71                         }
72                         else {
73                                 settings.mode = Camera.ImageMode;
74                         }
75                 }
76
77                 onPressed: {
78                         var y = mouse.y - highlighter.height / 2;
79
80                         if (y > drag.maximumY) {
81                                 y = drag.maximumY;
82                         }
83
84                         else if (y < drag.minimumY) {
85                                 y = 0;
86                         }
87
88                         highlighter.y = y
89                 }
90         }
91 }