CallPopup.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
  5. *
  6. * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. import QtQuick 2.9
  26. import QtQuick.Controls 2.4
  27. import qtprotobuf.examples 1.0
  28. import examples.grpc.addressbook 1.0
  29. Rectangle {
  30. id: root
  31. property CallStatus callStatus: null
  32. color: "#B0BEC5"
  33. border.width: 1
  34. border.color: "#cfdfe7"
  35. opacity: 0.0
  36. visible: opacity > 0
  37. PrimaryText {
  38. id: _statusText
  39. text: _d.getCallStatusText()
  40. anchors.horizontalCenter: parent.horizontalCenter
  41. anchors.bottom: _hangButton.top
  42. anchors.bottomMargin: 20
  43. }
  44. radius: 10
  45. Connections {
  46. target: root.callStatus
  47. onStatusChanged: {
  48. console.log("root.callStatus call status: " + root.callStatus.status);
  49. }
  50. }
  51. transform: Rotation {
  52. id: _rotation
  53. axis {
  54. x: 1
  55. y: 0
  56. z: 0
  57. }
  58. origin {
  59. x: root.width / 2
  60. y: root.height / 2
  61. }
  62. angle: 0
  63. }
  64. states: [
  65. State {
  66. name: "opened"
  67. when: root.callStatus.status === CallStatus.Active || root.callStatus.status === CallStatus.Ended
  68. PropertyChanges {
  69. target: root
  70. opacity: 1.0
  71. anchors.verticalCenterOffset: 0
  72. }
  73. PropertyChanges {
  74. target: _rotation
  75. angle: 0
  76. }
  77. },
  78. State {
  79. name: "closed"
  80. when: root.callStatus.status !== CallStatus.Active && root.callStatus.status !== CallStatus.Ended
  81. PropertyChanges {
  82. target: root
  83. opacity: 0.0
  84. anchors.verticalCenterOffset: 50
  85. }
  86. PropertyChanges {
  87. target: _rotation
  88. angle: -45
  89. }
  90. }
  91. ]
  92. transitions: [
  93. Transition {
  94. from: "*"
  95. to: "*"
  96. ParallelAnimation {
  97. alwaysRunToEnd: true
  98. NumberAnimation {
  99. target: root
  100. properties: "opacity,anchors.verticalCenterOffset"
  101. duration: 300
  102. }
  103. NumberAnimation {
  104. target: _rotation
  105. properties: "angle"
  106. duration: 300
  107. }
  108. }
  109. }
  110. ]
  111. MouseArea {
  112. anchors.fill: parent
  113. }
  114. FloatingRoundButton {
  115. id: _hangButton
  116. primaryColor: "#d31a5b"
  117. secondaryColor: "#E91E63"
  118. anchors.bottom: parent.bottom
  119. anchors.horizontalCenter: parent.horizontalCenter
  120. anchors.bottomMargin: 10
  121. icon: "qrc:/images/drop.png"
  122. onClicked: {
  123. AddressBookEngine.endCall()
  124. }
  125. }
  126. QtObject {
  127. id: _d
  128. function getCallStatusText() {
  129. switch (callStatus.status) {
  130. case CallStatus.Active:
  131. return qsTr("Active call to %1...").arg("+" + callStatus.phoneNumber.countryCode + " " + callStatus.phoneNumber.number)
  132. case CallStatus.Ended:
  133. return qsTr("Ending call...")
  134. default:
  135. return qsTr("No active call")
  136. }
  137. }
  138. }
  139. }