CallPopup.qml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. visible: false
  32. color: "#B0BEC5"
  33. border.width: 1
  34. border.color: "#cfdfe7"
  35. PrimaryText {
  36. id: _statusText
  37. text: _d.getCallStatusText()
  38. anchors.horizontalCenter: parent.horizontalCenter
  39. anchors.bottom: _hangButton.top
  40. anchors.bottomMargin: 20
  41. }
  42. radius: 10
  43. states: [
  44. State {
  45. name: "opened"
  46. when: callStatus.status === CallStatus.Active || callStatus.status === CallStatus.Ended
  47. PropertyChanges {
  48. target: root
  49. visible: true
  50. }
  51. },
  52. State {
  53. name: "closed"
  54. when: callStatus.status !== CallStatus.Active && callStatus.status !== CallStatus.Ended
  55. PropertyChanges {
  56. target: root
  57. visible: false
  58. }
  59. }
  60. ]
  61. FloatingRoundButton {
  62. id: _hangButton
  63. primaryColor: "#d31a5b"
  64. secondaryColor: "#E91E63"
  65. anchors.bottom: parent.bottom
  66. anchors.horizontalCenter: parent.horizontalCenter
  67. anchors.bottomMargin: 10
  68. icon: "qrc:/images/drop.png"
  69. onClicked: {
  70. abEngine.endCall()
  71. }
  72. }
  73. QtObject {
  74. id: _d
  75. function getCallStatusText() {
  76. switch(callStatus.status) {
  77. case CallStatus.Active:
  78. return qsTr("Active call to %1...").arg("+" + callStatus.phoneNumber.countryCode + " " + callStatus.phoneNumber.number)
  79. case CallStatus.Ended:
  80. return qsTr("Ending call...")
  81. default:
  82. return qsTr("No active call")
  83. }
  84. }
  85. }
  86. }