CaptureWidget.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. */
  23. import QtQuick 2.0
  24. import QtMultimedia 5.0
  25. Rectangle {
  26. property string shootImagePath: "shoot.png"
  27. function isSuffix(str, suffix) {
  28. return String(str).substr(String(str).length - suffix.length) == suffix
  29. }
  30. id: ui
  31. color: "#252423"
  32. anchors.fill: parent
  33. Camera {
  34. objectName: "camera"
  35. id: camera
  36. onError: {
  37. console.log(errorString);
  38. }
  39. videoRecorder.audioBitRate: 128000
  40. imageCapture {
  41. onImageSaved: {
  42. root.exec("Camera", "onImageSaved", [path]);
  43. ui.destroy();
  44. }
  45. }
  46. }
  47. VideoOutput {
  48. id: output
  49. source: camera
  50. width: parent.width
  51. height: parent.height
  52. }
  53. Item {
  54. anchors.bottom: parent.bottom
  55. width: parent.width
  56. height: shootButton.height
  57. BorderImage {
  58. id: leftBackground
  59. anchors.left: parent.left
  60. anchors.top: parent.top
  61. anchors.bottom: parent.bottom
  62. anchors.right: middle.left
  63. anchors.topMargin: units.dp(2)
  64. anchors.bottomMargin: units.dp(2)
  65. source: "toolbar-left.png"
  66. Image {
  67. anchors.verticalCenter: parent.verticalCenter
  68. anchors.left: parent.left
  69. anchors.leftMargin: parent.iconSpacing
  70. source: "back.png"
  71. width: units.gu(6)
  72. height: units.gu(5)
  73. MouseArea {
  74. anchors.fill: parent
  75. onClicked: {
  76. root.exec("Camera", "cancel");
  77. }
  78. }
  79. }
  80. }
  81. BorderImage {
  82. id: middle
  83. anchors.top: parent.top
  84. anchors.bottom: parent.bottom
  85. anchors.horizontalCenter: parent.horizontalCenter
  86. height: shootButton.height + units.gu(1)
  87. width: shootButton.width
  88. source: "toolbar-middle.png"
  89. Image {
  90. id: shootButton
  91. width: units.gu(8)
  92. height: width
  93. anchors.horizontalCenter: parent.horizontalCenter
  94. source: shootImagePath
  95. MouseArea {
  96. anchors.fill: parent
  97. onClicked: {
  98. camera.imageCapture.captureToLocation(ui.parent.plugin('Camera').generateLocation("jpg"));
  99. }
  100. }
  101. }
  102. }
  103. BorderImage {
  104. id: rightBackground
  105. anchors.right: parent.right
  106. anchors.top: parent.top
  107. anchors.bottom: parent.bottom
  108. anchors.left: middle.right
  109. anchors.topMargin: units.dp(2)
  110. anchors.bottomMargin: units.dp(2)
  111. source: "toolbar-right.png"
  112. }
  113. }
  114. }