openEventsPlatformApp/plugins/cordova-plugin-camera/src/ubuntu/CaptureWidget.qml
plugins/cordova-plugin-camera/src/ubuntu/CaptureWidget.qmlRaw
1/*
2 *
3 * Copyright 2013 Canonical Ltd.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22*/
23import QtQuick 2.0
24import QtMultimedia 5.0
25
26Rectangle {
27 property string shootImagePath: "shoot.png"
28 function isSuffix(str, suffix) {
29 return String(str).substr(String(str).length - suffix.length) == suffix
30 }
31
32 id: ui
33 color: "#252423"
34 anchors.fill: parent
35
36 Camera {
37 objectName: "camera"
38 id: camera
39 onError: {
40 console.log(errorString);
41 }
42 videoRecorder.audioBitRate: 128000
43 imageCapture {
44 onImageSaved: {
45 root.exec("Camera", "onImageSaved", [path]);
46 ui.destroy();
47 }
48 }
49 }
50 VideoOutput {
51 id: output
52 source: camera
53 width: parent.width
54 height: parent.height
55 }
56
57 Item {
58 anchors.bottom: parent.bottom
59 width: parent.width
60 height: shootButton.height
61 BorderImage {
62 id: leftBackground
63 anchors.left: parent.left
64 anchors.top: parent.top
65 anchors.bottom: parent.bottom
66 anchors.right: middle.left
67 anchors.topMargin: units.dp(2)
68 anchors.bottomMargin: units.dp(2)
69 source: "toolbar-left.png"
70 Image {
71 anchors.verticalCenter: parent.verticalCenter
72 anchors.left: parent.left
73 anchors.leftMargin: parent.iconSpacing
74 source: "back.png"
75 width: units.gu(6)
76 height: units.gu(5)
77 MouseArea {
78 anchors.fill: parent
79 onClicked: {
80 root.exec("Camera", "cancel");
81 }
82 }
83 }
84 }
85 BorderImage {
86 id: middle
87 anchors.top: parent.top
88 anchors.bottom: parent.bottom
89 anchors.horizontalCenter: parent.horizontalCenter
90 height: shootButton.height + units.gu(1)
91 width: shootButton.width
92 source: "toolbar-middle.png"
93 Image {
94 id: shootButton
95 width: units.gu(8)
96 height: width
97 anchors.horizontalCenter: parent.horizontalCenter
98 source: shootImagePath
99 MouseArea {
100 anchors.fill: parent
101 onClicked: {
102 camera.imageCapture.captureToLocation(ui.parent.plugin('Camera').generateLocation("jpg"));
103 }
104 }
105 }
106 }
107 BorderImage {
108 id: rightBackground
109 anchors.right: parent.right
110 anchors.top: parent.top
111 anchors.bottom: parent.bottom
112 anchors.left: middle.right
113 anchors.topMargin: units.dp(2)
114 anchors.bottomMargin: units.dp(2)
115 source: "toolbar-right.png"
116 }
117 }
118}