Don't show rounded corners
[harmattan/cameraplus] / qml / CameraPage.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 QtMobility.systeminfo 1.2
28
29 Page {
30         id: page
31
32         property alias standbyWidget: standby
33
34         property bool needsPipeline: true
35         property int policyMode: CameraResources.None
36
37         property Camera cam: null
38         property bool controlsVisible: cam.running && !standby.visible
39         property bool zoomVisible: true
40         property bool modesVisible: true
41         property bool standbyVisible: true
42         property bool focusReticleVisible: true
43
44         anchors.fill: parent
45
46         property alias previewAnimationRunning: preview.animationRunning
47
48         signal batteryLow
49
50         function updatePolicy() {
51                 if (needsPipeline && Qt.application.active && status == PageStatus.Active) {
52                         pipelineManager.reset();
53                 }
54         }
55
56         FocusReticle {
57                 visible: controlsVisible && focusReticleVisible && cam.autoFocus.canFocus(cam.scene.value);
58                 id: focusReticle
59                 cafStatus: cam.autoFocus.cafStatus
60                 status: cam.autoFocus.status
61         }
62
63         Rectangle {
64                 // TODO: fade out transition
65                 // TODO: there is a toolbar visible on the first startup
66                 id: standby
67                 color: "black"
68                 anchors.fill: parent
69                 visible: standbyVisible && page.status == PageStatus.Active && pipelineManager.showStandBy
70
71                 Image {
72                         id: icon
73                         source: "image://theme/icon-l-camera-standby"
74                         anchors.centerIn: parent
75                 }
76
77                 Label {
78                         anchors.top: icon.bottom
79                         anchors.right: parent.right
80                         anchors.left: parent.left
81                         text: qsTr("Resources lost")
82                         color: "white"
83                         font.pixelSize: 36
84                         horizontalAlignment: Text.AlignHCenter
85                         visible: pipelineManager.state == "policyLost"
86                 }
87         }
88
89         function setPreview(image) {
90                 preview.setPreview(image);
91         }
92
93         ModeButton {
94                 anchors.bottom: parent.bottom
95                 anchors.right: parent.right
96                 anchors.rightMargin: 20
97                 anchors.bottomMargin: 20
98                 visible: controlsVisible && modesVisible
99         }
100
101         PreviewImage {
102                 id: preview
103         }
104
105         ZoomSlider {
106                 id: zoom
107                 camera: cam
108                 anchors.top: parent.top
109                 anchors.topMargin: 0
110                 anchors.horizontalCenter: parent.horizontalCenter
111                 visible: controlsVisible && zoomVisible
112         }
113
114         function checkDiskSpace() {
115                 return fileSystem.hasFreeSpace(fileNaming.path);
116         }
117
118         function checkBattery() {
119                 // We are fine if we are connected to the charger:
120                 if (batteryMonitor.chargingState == BatteryInfo.Charging) {
121                         return true;
122                 }
123
124                 // If we have enough battery then we are fine:
125                 if (batteryMonitor.batteryStatus > BatteryInfo.BatteryCritical) {
126                         return true;
127                 }
128
129                 return false;
130         }
131
132         BatteryInfo {
133                 id: batteryMonitor
134                 monitorChargingStateChanges: cam.running
135                 monitorBatteryStatusChanges: cam.running
136
137                 onChargingStateChanged: {
138                         if (!checkBattery()) {
139                                 parent.batteryLow();
140                         }
141                 }
142
143                 onBatteryStatusChanged:  {
144                         if (!checkBattery()) {
145                                 parent.batteryLow();
146                         }
147                 }
148         }
149 }