set the width of the delegate to the width of the parent. image width gets 10 pixels...
[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.busy && dimmer.opacity == 0.0 && !previewAnimationRunning
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                         page.setPreview(preview);
76                 }
77         }
78
79         Rectangle {
80                 anchors.top: parent.top
81                 anchors.topMargin: 20
82                 anchors.left: parent.left
83                 anchors.leftMargin: 20
84                 width: 48
85                 height: col.height
86                 color: "black"
87                 border.color: "gray"
88                 radius: 20
89                 opacity: 0.5
90                 visible: controlsVisible
91
92                 Column {
93                         id: col
94                         width: parent.width
95                         spacing: 5
96
97                         Indicator {
98                                 id: resolutionIndicator
99                                 source: "image://theme/" + Data.videoIcon(settings.videoResolution);
100                         }
101
102                         Indicator {
103                                 id: wbIndicator
104                                 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
105                                 visible: settings.videoWhiteBalance != WhiteBalance.Auto
106                         }
107
108                         Indicator {
109                                 id: cfIndicator
110                                 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
111                                 visible: settings.videoColorFilter != ColorTone.Normal
112                         }
113
114                         Indicator {
115                                 id: gpsIndicator
116                                 visible: settings.useGps
117                                 source: "image://theme/icon-m-camera-location"
118
119                                 PropertyAnimation on opacity  {
120                                         easing.type: Easing.OutSine
121                                         loops: Animation.Infinite
122                                         from: 0.2
123                                         to: 1.0
124                                         duration: 1000
125                                         running: settings.useGps && !positionSource.position.longitudeValid
126                                         alwaysRunToEnd: true
127                                 }
128                         }
129                 }
130         }
131
132         Button {
133                 id: cameraRoll
134                 anchors.top: parent.top
135                 anchors.right: parent.right
136                 anchors.topMargin: 20
137                 anchors.rightMargin: 20
138                 width: 56
139                 height: 56
140
141                 opacity: 0.5
142                 iconSource: "image://theme/icon-m-camera-roll"
143                 onClicked: openFile("PostCapturePage.qml");
144                 visible: controlsVisible
145         }
146
147         CameraToolBar {
148                 id: toolBar
149                 anchors.bottom: parent.bottom
150                 anchors.bottomMargin: 20
151                 anchors.left: parent.left
152                 anchors.leftMargin: 20
153                 opacity: 0.5
154                 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
155                 visible: controlsVisible
156                 expanded: settings.showToolBar
157                 onExpandedChanged: settings.showToolBar = expanded;
158
159                 items: [
160                 VideoTorchButton {
161                         camera: cam
162                 },
163                 VideoSceneButton {
164                         onClicked: toolBar.push(items);
165                 },
166                 VideoEvCompButton {
167                         onClicked: toolBar.push(items);
168                 },
169                 VideoWhiteBalanceButton {
170                         onClicked: toolBar.push(items);
171                 },
172                 VideoColorFilterButton {
173                         onClicked: toolBar.push(items);
174                 },
175                 VideoMuteButton {
176                 },
177                 ToolIcon {
178                         iconSource: "image://theme/icon-m-toolbar-view-menu-white"
179                         onClicked: openFile("VideoSettingsPage.qml");
180                 }
181                 ]
182         }
183 }