5830fe213cbc3f49ba27f019b9e60ef6d71a19ba
[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         orientationLock: PageOrientation.LockLandscape
36
37         Button {
38                 id: capture
39                 anchors.right: parent.right
40                 anchors.rightMargin: 20
41                 anchors.verticalCenter: parent.verticalCenter
42                 iconSource: "image://theme/icon-m-camera-shutter"
43                 width: 75
44                 height: 75
45                 opacity: 0.5
46                 onClicked: {
47                         if (!fileSystem.available) {
48                                 showError(qsTr("Camera cannot capture images in mass storage mode."));
49                                 return;
50                         }
51
52                         metaData.setMetaData();
53
54                         if (!imageMode.capture(fileNaming.imageFileName())) {
55                                 showError(qsTr("Failed to capture image. Please restart the camera."));
56                         }
57                 }
58
59                 visible: imageMode.canCapture && !cameraMode.animationRunning && !previewAnimationRunning && cam.running
60         }
61
62         ImageMode {
63                 id: imageMode
64                 camera: cam
65                 onPreviewAvailable: page.setPreview(preview);
66         }
67
68         FlashButton {
69                 id: flash
70                 visible: controlsVisible
71                 anchors.top: parent.top
72                 anchors.left: parent.left
73                 anchors.topMargin: 20
74                 anchors.leftMargin: 20
75         }
76
77         ImageSceneButton {
78                 id: scene
79                 visible: controlsVisible
80                 anchors.top: flash.bottom
81                 anchors.left: parent.left
82                 anchors.topMargin: 10
83                 anchors.leftMargin: 20
84         }
85
86         EvCompButton {
87                 id: evComp
88                 visible: controlsVisible
89                 anchors.top: scene.bottom
90                 anchors.left: parent.left
91                 anchors.topMargin: 10
92                 anchors.leftMargin: 20
93         }
94
95         MouseArea {
96                 id: indicators
97                 anchors.bottom: parent.bottom
98                 anchors.bottomMargin: 20
99                 anchors.left: parent.left
100                 anchors.leftMargin: 20
101                 width: 48
102                 height: col.height
103                 onClicked: openFile("ImageSettingsPage.qml");
104                 visible: controlsVisible
105
106                 BorderImage {
107                         id: image
108                         anchors.fill: parent
109                         smooth: true
110                         source: indicators.pressed ? "image://theme/meegotouch-camera-settings-indicators-background-pressed" : "image://theme/meegotouch-camera-settings-indicators-background"
111                 }
112
113                 Column {
114                         id: col
115                         width: parent.width
116                         spacing: 5
117
118                         Indicator {
119                                 id: resolutionIndicator
120                                 source: "image://theme/" + Data.imageIcon(settings.imageAspectRatio, settings.imageResolution);
121                         }
122
123                         Indicator {
124                                 id: wbIndicator
125                                 source: "image://theme/" + Data.wbIcon(settings.imageWhiteBalance) + "-screen"
126                                 visible: settings.imageWhiteBalance != WhiteBalance.Auto
127                         }
128
129                         Indicator {
130                                 id: cfIndicator
131                                 source: "image://theme/" + Data.cfIcon(settings.imageColorFilter) + "-screen"
132                                 visible: settings.imageColorFilter != ColorTone.Normal
133                         }
134
135                         Indicator {
136                                 id: isoIndicator
137                                 visible: settings.imageIso != 0
138                                 source: "image://theme/" + Data.isoIcon(settings.imageIso);
139                         }
140
141                         Indicator {
142                                 id: gpsIndicator
143                                 visible: settings.useGps
144                                 source: "image://theme/icon-m-camera-location"
145
146                                 PropertyAnimation on opacity  {
147                                         easing.type: Easing.OutSine
148                                         loops: Animation.Infinite
149                                         from: 0.2
150                                         to: 1.0
151                                         duration: 1000
152                                         running: settings.useGps && !positionSource.position.longitudeValid
153                                         alwaysRunToEnd: true
154                                 }
155                         }
156                 }
157         }
158
159         Button {
160                 id: cameraRoll
161                 anchors.top: parent.top
162                 anchors.right: parent.right
163                 anchors.topMargin: 20
164                 anchors.rightMargin: 20
165                 width: 56
166                 height: 56
167
168                 opacity: 0.5
169                 iconSource: "image://theme/icon-m-camera-roll"
170                 onClicked: openFile("PostCapturePage.qml");
171                 visible: controlsVisible
172         }
173 }