Don't set Indicator icon source if wbIndicator is not visible to avoid a warning
[harmattan/cameraplus] / qml / VideoPage.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.Video
33
34         controlsVisible: cam.running && !videoMode.recording && videoMode.canCapture && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
35         orientationLock: PageOrientation.LockLandscape
36
37         function startRecording() {
38                 if (!fileSystem.available) {
39                         showError(qsTr("Camera cannot record videos in mass storage mode."));
40                         return;
41                 }
42
43                 if (!checkBattery()) {
44                         showError(qsTr("Not enough battery to record video."));
45                         return;
46                 }
47
48                 if (!checkDiskSpace()) {
49                         showError(qsTr("Not enough space to record video."));
50                         return;
51                 }
52
53                 openFileNow("RecordingPage.qml");
54         }
55
56         CaptureButton {
57                 id: recording
58                 anchors.right: parent.right
59                 anchors.rightMargin: 20
60                 anchors.verticalCenter: parent.verticalCenter
61                 iconSource: "image://theme/icon-m-camera-video-record"
62                 width: 75
63                 height: 75
64                 opacity: 0.5
65
66                 onClicked: startRecording();
67
68                 visible: controlsVisible
69         }
70
71         VideoMode {
72                 id: videoMode
73                 camera: cam
74                 onPreviewAvailable: {
75                         if (!standbyWidget.visible) {
76                                 page.setPreview(preview);
77                         }
78                 }
79         }
80
81         VideoTorchButton {
82                 id: torch
83                 camera: cam
84                 visible: controlsVisible
85                 anchors.top: parent.top
86                 anchors.left: parent.left
87                 anchors.topMargin: 20
88                 anchors.leftMargin: 20
89                 opacity: 0.5
90         }
91
92         VideoSceneButton {
93                 id: scene
94                 visible: controlsVisible
95                 anchors.top: torch.bottom
96                 anchors.left: parent.left
97                 anchors.topMargin: 10
98                 anchors.leftMargin: 20
99         }
100
101         VideoEvCompButton {
102                 id: evComp
103                 visible: controlsVisible
104                 anchors.top: scene.bottom
105                 anchors.left: parent.left
106                 anchors.topMargin: 10
107                 anchors.leftMargin: 20
108         }
109
110         MouseArea {
111                 id: indicators
112                 anchors.bottom: parent.bottom
113                 anchors.bottomMargin: 20
114                 anchors.left: parent.left
115                 anchors.leftMargin: 20
116                 width: 48
117                 height: col.height
118                 onClicked: openFile("VideoSettingsPage.qml");
119                 visible: controlsVisible
120
121                 BorderImage {
122                         id: image
123                         anchors.fill: parent
124                         smooth: true
125                         source: indicators.pressed ? "image://theme/meegotouch-camera-settings-indicators-background-pressed" : "image://theme/meegotouch-camera-settings-indicators-background"
126                 }
127
128                 Column {
129                         id: col
130                         width: parent.width
131                         spacing: 5
132
133                         Indicator {
134                                 id: resolutionIndicator
135                                 source: "image://theme/" + Data.videoIcon(settings.videoResolution);
136                         }
137
138                         Indicator {
139                                 id: wbIndicator
140                                 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
141                                 visible: settings.videoWhiteBalance != WhiteBalance.Auto
142                         }
143
144                         Indicator {
145                                 id: cfIndicator
146                                 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
147                                 visible: settings.videoColorFilter != ColorTone.Normal
148                         }
149
150                         Indicator {
151                                 id: gpsIndicator
152                                 visible: settings.useGps
153                                 source: "image://theme/icon-m-camera-location"
154
155                                 PropertyAnimation on opacity  {
156                                         easing.type: Easing.OutSine
157                                         loops: Animation.Infinite
158                                         from: 0.2
159                                         to: 1.0
160                                         duration: 1000
161                                         running: settings.useGps && !positionSource.position.longitudeValid
162                                         alwaysRunToEnd: true
163                                 }
164                         }
165                 }
166         }
167
168         Button {
169                 id: cameraRoll
170                 anchors.top: parent.top
171                 anchors.right: parent.right
172                 anchors.topMargin: 20
173                 anchors.rightMargin: 20
174                 width: 56
175                 height: 56
176
177                 opacity: 0.5
178                 iconSource: "image://theme/icon-m-camera-roll"
179                 onClicked: openFile("PostCapturePage.qml");
180                 visible: controlsVisible
181         }
182 }