Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.2
  3. import QtQuick.Layouts 1.1
  4. import QtQuick.Controls.Styles 1.2
  5. import QtMultimedia 5.2
  6.  
  7.  
  8. Rectangle {
  9. width: 100
  10. height: 62
  11. property int bottomMargin: 10
  12. property int columnSpacing: 50
  13.  
  14. gradient: Gradient {
  15. GradientStop {
  16. position: 0.00;
  17. color: "#000000";
  18. }
  19. GradientStop {
  20. position: 1.00;
  21. color: "#b9b3b3";
  22. }
  23. }
  24. BusyIndicator {
  25. id : busyInd
  26. }
  27.  
  28. function uploadImage(path)
  29. {
  30. console.log("UPLOAD IMAGE");
  31.  
  32. var fileName = path//propertyInWhichYouStoredImagePath;
  33. if (fileName == "") {
  34. notification.show(qsTr("No Image Exists"));
  35. return;
  36. }
  37. busyInd.running = true;
  38. var fileObject = {
  39. objectType: "objects.image",
  40. name: fileName,
  41. localPath: fileName
  42. }
  43. var reply = enginioClient.create(fileObject);
  44. reply.finished.connect(function() {
  45. var uploadData = {
  46. file: { fileName: fileName },
  47. targetFileProperty: {
  48. objectType: "objects.image",
  49. id: reply.data.id,
  50. propertyName: "file"
  51. },
  52. };
  53.  
  54. var uploadReply = enginioClient.uploadFile(uploadData, fileName);
  55.  
  56. uploadReply.finished.connect(function() {
  57. var tmp = enginioModel.query;
  58. enginioModel.query = null;
  59. enginioModel.query = tmp;
  60. busyInd.running = false;
  61. notification.show(qsTr("Saved to Cloud"));
  62. })
  63. })
  64. }
  65.  
  66. Image {
  67. id: photoPreview
  68. width: 200
  69. height:200
  70. }
  71. Camera {
  72. id: camera
  73.  
  74. imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
  75.  
  76. exposure {
  77. exposureCompensation: -1.0
  78. exposureMode: Camera.ExposurePortrait
  79. }
  80.  
  81. flash.mode: Camera.FlashRedEyeReduction
  82.  
  83. imageCapture {
  84. onImageCaptured: {
  85. photoPreview.source = preview // Show the preview in an Image
  86. }
  87. onImageSaved:
  88. {
  89. console.log("Image Capture Changed " + camera.imageCapture.capturedImagePath);
  90. uploadImage(camera.imageCapture.capturedImagePath);
  91. }
  92. }
  93.  
  94. }
  95.  
  96.  
  97. VideoOutput {
  98. source: camera
  99. anchors.fill: parent
  100. focus : visible // to receive focus and capture key events when visible
  101. MouseArea {
  102. anchors.fill: parent;
  103. onClicked: camera.imageCapture.capture();
  104. onDoubleClicked: camera.imageCapture.captureToLocation()
  105. }
  106. }
  107.  
  108. NotificationMessage {
  109. id: notification
  110. anchors.centerIn: parent
  111. width: 0.5 * parent.width
  112. height: 0.5 * width
  113. onCustomSignal: {
  114. console.log("Notification closed")
  115. }
  116. }
  117.  
  118. ToolBar {
  119. id: bottomToolbar
  120. anchors.bottom: parent.bottom
  121. anchors.bottomMargin: bottomMargin
  122. width: parent.width
  123.  
  124. RowLayout {
  125. anchors.horizontalCenter: parent.horizontalCenter
  126. spacing: columnSpacing
  127. ToolButton {
  128. iconSource: "qrc:/images/arrow_left.png"
  129. onClicked: {
  130. pageStack.pop();
  131. }
  132. }
  133. }
  134. style: ToolBarStyle {
  135. background: Item {
  136. visible: false
  137. }
  138. }
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement