Mirror.qml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * Copyright (c) 2011-2012 Nokia Corporation.
  3. */
  4. import QtQuick 1.1
  5. import CustomItems 1.0
  6. Item {
  7. id: mirror
  8. anchors.fill: parent
  9. property int mirrorEffectId
  10. // Create camera component
  11. function createCamera(enable) {
  12. if (enable && cameraLoader.item == undefined) {
  13. cameraLoader.sourceComponent = cameraComponent;
  14. }
  15. }
  16. // Delete camera component
  17. function deleteCamera() {
  18. cameraLoader.sourceComponent = undefined;
  19. }
  20. // Enable or disable camera
  21. function enableCamera(enable) {
  22. createCamera(enable);
  23. if (cameraLoader.item != undefined) {
  24. cameraLoader.item.enableEffect(mirrorEffectId,0,0);
  25. cameraLoader.item.enableCamera(enable);
  26. }
  27. }
  28. // Enable or disable camera by index
  29. function enableCameraAt(enable, index) {
  30. createCamera(enable);
  31. if (cameraLoader.item != undefined) {
  32. cameraLoader.item.enableEffect(mirrorEffectId,0,0);
  33. cameraLoader.item.enableCameraAt(enable,index);
  34. }
  35. }
  36. // Pause camera
  37. function pauseCamera() {
  38. if (cameraLoader.item != undefined)
  39. cameraLoader.item.pauseCamera();
  40. }
  41. // Save camera frame to Gallery
  42. function saveToFile() {
  43. if (cameraLoader.item != undefined)
  44. cameraLoader.item.saveToFile();
  45. }
  46. signal zoomIn()
  47. signal zoomOut()
  48. Rectangle {
  49. anchors.fill: parent
  50. gradient: Gradient {
  51. GradientStop { position: 0.0; color: "#FFFFFF" }
  52. GradientStop { position: 1.0; color: "#7F7F7F" }
  53. }
  54. }
  55. // Loader for dynamically creating MirrorItem
  56. Loader {
  57. id: cameraLoader
  58. anchors.fill: parent
  59. sourceComponent: undefined
  60. }
  61. // Custom camera component that shows mirror camera
  62. Component {
  63. id: cameraComponent
  64. MirrorItem {
  65. anchors.fill: parent
  66. effectId: mirror.mirrorEffectId
  67. onMinimizeMirror: {
  68. zoomOut();
  69. }
  70. onMaximizeMirror: {
  71. zoomIn();
  72. }
  73. }
  74. }
  75. Image {
  76. id: border
  77. smooth: true
  78. source: "qrc:/gfx/mirror.png"
  79. width: parent.width * 1.3
  80. height: parent.height * 1.5
  81. anchors.horizontalCenter: parent.horizontalCenter
  82. anchors.verticalCenter: parent.verticalCenter
  83. }
  84. }