Added copyright headers and COPYING file.
[harmattan/cameraplus] / qml / ImagePage.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 import QtQuick 1.1
24 import com.nokia.meego 1.1
25 import QtCamera 1.0
26 import CameraPlus 1.0
27 import "data.js" as Data
28
29 CameraPage {
30         id: page
31
32         policyMode: CameraResources.Image
33         controlsVisible: capture.visible && cam.running && !standbyWidget.visible
34
35         Button {
36                 id: capture
37                 anchors.right: parent.right
38                 anchors.rightMargin: 20
39                 anchors.verticalCenter: parent.verticalCenter
40                 iconSource: "image://theme/icon-m-camera-shutter"
41                 width: 75
42                 height: 75
43                 opacity: 0.5
44                 onClicked: {
45                         if (!fileSystem.available) {
46                                 showError(qsTr("Camera cannot capture images in mass storage mode."));
47                                 return;
48                         }
49
50                         metaData.setMetaData();
51
52                         if (!imageMode.capture(fileNaming.imageFileName())) {
53                                 showError(qsTr("Failed to capture image. Please restart the camera."));
54                         }
55                 }
56
57                 visible: imageMode.canCapture && !cameraMode.animationRunning && !previewAnimationRunning && cam.running
58         }
59
60         ImageMode {
61                 id: imageMode
62                 camera: cam
63                 onPreviewAvailable: page.setPreview(preview);
64         }
65
66         FlashButton {
67                 id: flash
68                 visible: controlsVisible
69                 anchors.top: parent.top
70                 anchors.left: parent.left
71                 anchors.topMargin: 20
72                 anchors.leftMargin: 20
73         }
74
75         ImageSceneButton {
76                 id: scene
77                 visible: controlsVisible
78                 anchors.top: flash.bottom
79                 anchors.left: parent.left
80                 anchors.topMargin: 10
81                 anchors.leftMargin: 20
82         }
83
84         EvCompButton {
85                 id: evComp
86                 visible: controlsVisible
87                 anchors.top: scene.bottom
88                 anchors.left: parent.left
89                 anchors.topMargin: 10
90                 anchors.leftMargin: 20
91         }
92
93         MouseArea {
94                 id: indicators
95                 anchors.bottom: parent.bottom
96                 anchors.bottomMargin: 20
97                 anchors.left: parent.left
98                 anchors.leftMargin: 20
99                 width: 48
100                 height: col.height
101                 onClicked: openFile("ImageSettingsPage.qml");
102                 visible: controlsVisible
103
104                 BorderImage {
105                         id: image
106                         anchors.fill: parent
107                         smooth: true
108                         source: indicators.pressed ? "image://theme/meegotouch-camera-settings-indicators-background-pressed" : "image://theme/meegotouch-camera-settings-indicators-background"
109                 }
110
111                 Column {
112                         id: col
113                         width: parent.width
114                         spacing: 5
115
116                         Indicator {
117                                 id: resolutionIndicator
118                                 // TODO:
119                         }
120
121                         Indicator {
122                                 id: wbIndicator
123                                 source: "image://theme/" + Data.wbIcon(settings.imageWhiteBalance) + "-screen"
124                                 visible: settings.imageWhiteBalance != WhiteBalance.Auto
125                         }
126
127                         Indicator {
128                                 id: cfIndicator
129                                 source: "image://theme/" + Data.cfIcon(settings.imageColorFilter) + "-screen"
130                                 visible: settings.imageColorFilter != ColorTone.Normal
131                         }
132
133                         Indicator {
134                                 id: isoIndicator
135                                 visible: settings.imageIso != 0
136                                 source: "image://theme/" + Data.isoIcon(settings.imageIso);
137                         }
138
139                         Indicator {
140                                 id: gpsIndicator
141                                 visible: settings.useGps
142                                 source: "image://theme/icon-m-camera-location"
143
144                                 PropertyAnimation on opacity  {
145                                         easing.type: Easing.OutSine
146                                         loops: Animation.Infinite
147                                         from: 0.2
148                                         to: 1.0
149                                         duration: 1000
150                                         running: settings.useGps && !positionSource.position.longitudeValid
151                                         alwaysRunToEnd: true
152                                 }
153                         }
154                 }
155         }
156
157         Button {
158                 id: cameraRoll
159                 anchors.top: parent.top
160                 anchors.right: parent.right
161                 anchors.topMargin: 20
162                 anchors.rightMargin: 20
163                 width: 56
164                 height: 56
165
166                 opacity: 0.5
167                 iconSource: "image://theme/icon-m-camera-roll"
168                 onClicked: openFile("PostCapturePage.qml");
169                 visible: controlsVisible
170         }
171 }