CallPopup.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. Rectangle {
  29. id: root
  30. property CallStatus callStatus: null
  31. color: "#B0BEC5"
  32. border.width: 1
  33. border.color: "#cfdfe7"
  34. opacity: 0.0
  35. visible: opacity > 0
  36. PrimaryText {
  37. id: _statusText
  38. text: _d.getCallStatusText()
  39. anchors.horizontalCenter: parent.horizontalCenter
  40. anchors.bottom: _hangButton.top
  41. anchors.bottomMargin: 20
  42. }
  43. radius: 10
  44. transform: Rotation {
  45. id: _rotation
  46. axis {
  47. x: 1
  48. y: 0
  49. z: 0
  50. }
  51. origin {
  52. x: root.width / 2
  53. y: root.height / 2
  54. }
  55. angle: 0
  56. }
  57. states: [
  58. State {
  59. name: "opened"
  60. when: callStatus.status === CallStatus.Active || callStatus.status === CallStatus.Ended
  61. },
  62. State {
  63. name: "closed"
  64. when: callStatus.status !== CallStatus.Active && callStatus.status !== CallStatus.Ended
  65. }
  66. ]
  67. transitions: [
  68. Transition {
  69. from: "opened"
  70. to: "closed"
  71. NumberAnimation {
  72. target: root
  73. property: "opacity"
  74. duration: 300
  75. from: 1.0
  76. to: 0.0
  77. }
  78. NumberAnimation {
  79. target: root
  80. property: "anchors.verticalCenterOffset"
  81. duration: 300
  82. from: 0
  83. to: 50
  84. }
  85. NumberAnimation {
  86. target: _rotation
  87. property: "angle"
  88. duration: 300
  89. from: 0
  90. to: -45
  91. }
  92. },
  93. Transition {
  94. from: "closed"
  95. to: "opened"
  96. NumberAnimation {
  97. target: root
  98. property: "anchors.verticalCenterOffset"
  99. duration: 300
  100. from: 50
  101. to: 0
  102. }
  103. NumberAnimation {
  104. target: root
  105. property: "opacity"
  106. duration: 300
  107. from: 0.0
  108. to: 1.0
  109. }
  110. NumberAnimation {
  111. target: _rotation
  112. property: "angle"
  113. duration: 300
  114. from: -45
  115. to: 0
  116. }
  117. }
  118. ]
  119. MouseArea {
  120. anchors.fill: parent
  121. }
  122. FloatingRoundButton {
  123. id: _hangButton
  124. primaryColor: "#d31a5b"
  125. secondaryColor: "#E91E63"
  126. anchors.bottom: parent.bottom
  127. anchors.horizontalCenter: parent.horizontalCenter
  128. anchors.bottomMargin: 10
  129. icon: "qrc:/images/drop.png"
  130. onClicked: {
  131. abEngine.endCall()
  132. }
  133. }
  134. QtObject {
  135. id: _d
  136. function getCallStatusText() {
  137. switch(callStatus.status) {
  138. case CallStatus.Active:
  139. return qsTr("Active call to %1...").arg("+" + callStatus.phoneNumber.countryCode + " " + callStatus.phoneNumber.number)
  140. case CallStatus.Ended:
  141. return qsTr("Ending call...")
  142. default:
  143. return qsTr("No active call")
  144. }
  145. }
  146. }
  147. }