DialogSubscribes.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import QtQuick 1.1
  2. DialogLiquid {
  3. id: dlgSubscribes
  4. height: parent.height*0.5
  5. property string selectedBareJidSubscribe: ""
  6. function addBareJid( bareJid )
  7. {
  8. if( bareJid != "" ) {
  9. modelListBareJids.append( { bareJid : bareJid } )
  10. }
  11. }
  12. ListModel {
  13. id: modelListBareJids
  14. //ListElement { bareJid: "bareJid1@server1.com" } //as example
  15. }
  16. Component {
  17. id: componentWrapper
  18. Rectangle {
  19. id: wrapper
  20. width: listViewJids.width
  21. height: 70
  22. border.color: "gray"
  23. Text {
  24. id: txtItem
  25. anchors.verticalCenter: parent.verticalCenter
  26. anchors.left: parent.left
  27. anchors.leftMargin: 20
  28. text: bareJid
  29. font.pixelSize: 28
  30. }
  31. MouseArea {
  32. id: mouseAreaItem;
  33. anchors.fill: parent
  34. onClicked: {
  35. wrapper.ListView.view.currentIndex = index
  36. selectedBareJidSubscribe = bareJid
  37. }
  38. }
  39. Component.onCompleted: {
  40. if( index == 0 ) {
  41. selectedBareJidSubscribe = bareJid
  42. //console.log("*** selected: " + selectedBareJidSubscribe)
  43. }
  44. }
  45. states: State {
  46. name: "Current"
  47. when: wrapper.ListView.isCurrentItem
  48. PropertyChanges { target: wrapper; color: "lightblue" }
  49. }
  50. }
  51. }
  52. Rectangle {
  53. id: headerDlg
  54. anchors.top: parent.top
  55. anchors.left: parent.left
  56. width: parent.width
  57. height: 70
  58. gradient: Gradient {
  59. GradientStop { position: 0; color: "#919191" }
  60. GradientStop { position: 1; color: "#666666" }
  61. }
  62. Text {
  63. anchors.centerIn: parent
  64. font.pixelSize: 22
  65. color: "white"
  66. text: qsTr("Authorization requests")
  67. }
  68. }
  69. property int __marg1 : 3
  70. ListView {
  71. id: listViewJids
  72. anchors.top: headerDlg.bottom
  73. anchors.topMargin: __marg1
  74. anchors.left: parent.left
  75. anchors.leftMargin: __marg1
  76. anchors.bottom: rowOfButtons.top
  77. anchors.bottomMargin: __marg1
  78. width: parent.width - __marg1*2
  79. model: modelListBareJids
  80. delegate: componentWrapper
  81. clip: true
  82. }
  83. Item {
  84. id:rowOfButtons
  85. width: parent.width - 2*__marg1
  86. height: 80
  87. anchors.left: parent.left
  88. anchors.leftMargin: __marg1
  89. anchors.bottom: parent.bottom
  90. anchors.bottomMargin: __marg1
  91. Button {
  92. id: buttonAccept
  93. text: qsTr("Accept")
  94. height: 70
  95. width: parent.width/2 - 10
  96. anchors.verticalCenter: parent.verticalCenter
  97. anchors.left: parent.left
  98. anchors.leftMargin: 4
  99. onClicked: {
  100. var res = xmppClient.acceptSubscribtion( selectedBareJidSubscribe )
  101. if( res ) {
  102. for( var j=0; j<modelListBareJids.count; j++ ) {
  103. var jid = modelListBareJids.get(j).bareJid
  104. if( jid == selectedBareJidSubscribe ) {
  105. modelListBareJids.remove(j);
  106. break;
  107. }
  108. }
  109. } //if(res)
  110. }
  111. }
  112. Button {
  113. id: buttonReject
  114. text: qsTr("Reject")
  115. height: 70
  116. width: parent.width/2 - 10
  117. anchors.verticalCenter: parent.verticalCenter
  118. anchors.right: parent.right
  119. anchors.rightMargin: 4
  120. onClicked: {
  121. var res = xmppClient.rejectSubscribtion( selectedBareJidSubscribe )
  122. if( res ) {
  123. for( var j=0; j<modelListBareJids.count; j++ ) {
  124. var jid = modelListBareJids.get(j).bareJid
  125. if( jid == selectedBareJidSubscribe ) {
  126. modelListBareJids.remove(j);
  127. break;
  128. }
  129. }
  130. } //if(res)
  131. }
  132. }
  133. }
  134. }