VCardPage.qml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. import QtQuick 1.1
  2. import meegim 1.0
  3. MyPage {
  4. id: vCardPage
  5. property string bareJid: ""
  6. property string nextPage: "qrc:/qml/RosterPage.qml"
  7. property bool readOnly: true
  8. property alias vCardPhoto: avatar.source
  9. property alias vCardNickName: tiNickname.text
  10. property alias vCardName: tiName.text
  11. property alias vCardMiddleName: tiMiddlename.text
  12. property alias vCardLastName: tiLastname.text
  13. property alias vCardFullName: tiFullName.text
  14. property alias vCardEmail: tiEmail.text
  15. property alias vCardBirthday: tiBirthday.text
  16. property alias vCardUrl: tiUrl.text
  17. Component.onCompleted: {
  18. showCurtain( true )
  19. if( main.requestMyVCard == true ) {
  20. console.log("QML::VCargPage: 1.Request vCard for: " + xmppClient.myBareJid )
  21. xmppClient.requestVCard( xmppClient.myBareJid )
  22. textCurtain.text = xmppClient.myBareJid
  23. toolBarButtonOptions.visible = true
  24. main.requestMyVCard = false
  25. } else {
  26. console.log("QML::VCargPage: 2.Request vCard for: " + xmppClient.chatJid )
  27. xmppClient.requestVCard( xmppClient.chatJid )
  28. textCurtain.text = xmppClient.chatJid
  29. toolBarButtonOptions.visible = false
  30. }
  31. clearForm()
  32. }
  33. Connections {
  34. target: xmppVCard
  35. onVCardChanged: {
  36. //console.log( "QML: VCardPage: onVCardChanged: " + xmppVCard.nickname )
  37. if( xmppVCard.photo != "" ) {
  38. vCardPhoto = xmppVCard.photo
  39. }
  40. vCardNickName = xmppVCard.nickname
  41. vCardName = xmppVCard.name
  42. vCardMiddleName = xmppVCard.middlename
  43. vCardLastName = xmppVCard.lastname
  44. vCardFullName = xmppVCard.fullname
  45. vCardEmail = xmppVCard.email
  46. vCardBirthday = xmppVCard.birthday
  47. vCardUrl = xmppVCard.url
  48. bareJid = xmppVCard.jid
  49. showCurtain( false )
  50. }
  51. }
  52. function showCurtain( isShow ) {
  53. if( isShow ) {
  54. curtain.opacity = 0.85
  55. } else {
  56. curtain.opacity = 0
  57. }
  58. }
  59. Rectangle {
  60. id: curtain
  61. z: 10
  62. anchors.top: parent.top
  63. anchors.bottom: toolBar.top
  64. anchors.left: parent.left
  65. anchors.right: parent.right
  66. color: "black"
  67. opacity: 0
  68. Behavior on opacity { NumberAnimation { duration: 400 } }
  69. }
  70. Column {
  71. z: curtain.z + 1
  72. anchors.centerIn: parent
  73. width: parent.width
  74. spacing: 5
  75. Image {
  76. id: imgVCardRequest
  77. source: "qrc:/qml/images/vcard.png"
  78. anchors.horizontalCenter: parent.horizontalCenter
  79. visible: curtain.opacity != 0 ? true : false
  80. opacity: curtain.opacity
  81. }
  82. Text {
  83. font.pixelSize: 26
  84. anchors.horizontalCenter: parent.horizontalCenter
  85. text: qsTr("Request vCard for")
  86. color: "white"
  87. visible: curtain.opacity != 0 ? true : false
  88. opacity: curtain.opacity
  89. }
  90. Text {
  91. id: textCurtain
  92. anchors.horizontalCenter: parent.horizontalCenter
  93. font.pixelSize: 26
  94. color: "white"
  95. visible: curtain.opacity != 0 ? true : false
  96. opacity: curtain.opacity
  97. }
  98. }
  99. function clearForm()
  100. {
  101. vCardPhoto = "qrc:/qml/images/avatar.png"
  102. vCardNickName = ""
  103. vCardName = ""
  104. vCardMiddleName = ""
  105. vCardLastName = ""
  106. vCardFullName = ""
  107. vCardEmail = ""
  108. vCardBirthday = ""
  109. vCardUrl = ""
  110. bareJid = ""
  111. }
  112. Flickable {
  113. id: flickArea
  114. anchors.top: parent.top; anchors.topMargin: 12
  115. anchors.bottom: toolBar.top; anchors.bottomMargin: 12
  116. anchors.left: parent.left; anchors.leftMargin: 20
  117. anchors.right: parent.right; anchors.rightMargin: 20
  118. contentHeight: columnContent.height
  119. contentWidth: columnContent.width
  120. flickableDirection: Flickable.VerticalFlick
  121. Column {
  122. id: columnContent
  123. width: vCardPage.width - flickArea.anchors.rightMargin - flickArea.anchors.leftMargin
  124. spacing: 10
  125. Row {
  126. id: rowAvatarAndJid
  127. height: avatar.height
  128. width: columnContent.width
  129. spacing: 15
  130. Image {
  131. id: avatar
  132. smooth: true
  133. height: 80
  134. width: height
  135. source: "qrc:/qml/images/avatar.png"
  136. anchors.verticalCenter: parent.verticalCenter
  137. }
  138. Text {
  139. id: txtJid
  140. text: bareJid
  141. anchors.verticalCenter: parent.verticalCenter
  142. font.pixelSize: 28
  143. }
  144. }
  145. Text {
  146. id: txtNickname
  147. anchors.horizontalCenter: parent.horizontalCenter
  148. text: qsTr("Nickname:")
  149. font.pixelSize: 28
  150. }
  151. MyTextInput {
  152. id: tiNickname
  153. anchors.horizontalCenter: parent.horizontalCenter
  154. height: 50
  155. width: parent.width
  156. readOnly: vCardPage.readOnly
  157. __readonlyIsGray: false
  158. }
  159. Item { height: 10; width: vCardPage.width }
  160. Text {
  161. id: txtName
  162. anchors.horizontalCenter: parent.horizontalCenter
  163. text: qsTr("Name:")
  164. font.pixelSize: 28
  165. }
  166. MyTextInput {
  167. id: tiName
  168. anchors.horizontalCenter: parent.horizontalCenter
  169. height: 50
  170. width: parent.width
  171. readOnly: vCardPage.readOnly
  172. __readonlyIsGray: false
  173. }
  174. Item { height: 10; width: vCardPage.width }
  175. Text {
  176. id: txtLastname
  177. anchors.horizontalCenter: parent.horizontalCenter
  178. text: qsTr("Last name:")
  179. font.pixelSize: 28
  180. }
  181. MyTextInput {
  182. id: tiLastname
  183. anchors.horizontalCenter: parent.horizontalCenter
  184. height: 50
  185. width: parent.width
  186. readOnly: vCardPage.readOnly
  187. __readonlyIsGray: false
  188. }
  189. Item { height: 10; width: vCardPage.width }
  190. Text {
  191. id: txtMiddlename
  192. anchors.horizontalCenter: parent.horizontalCenter
  193. text: qsTr("Middle name:")
  194. font.pixelSize: 28
  195. }
  196. MyTextInput {
  197. id: tiMiddlename
  198. anchors.horizontalCenter: parent.horizontalCenter
  199. height: 50
  200. width: parent.width
  201. readOnly: vCardPage.readOnly
  202. __readonlyIsGray: false
  203. }
  204. Item { height: 10; width: vCardPage.width }
  205. Text {
  206. id: txtFullName
  207. anchors.horizontalCenter: parent.horizontalCenter
  208. text: qsTr("Full name:")
  209. font.pixelSize: 28
  210. }
  211. MyTextInput {
  212. id: tiFullName
  213. anchors.horizontalCenter: parent.horizontalCenter
  214. height: 50
  215. width: parent.width
  216. readOnly: vCardPage.readOnly
  217. __readonlyIsGray: false
  218. }
  219. Item { height: 10; width: vCardPage.width }
  220. Text {
  221. id: txtEmail
  222. anchors.horizontalCenter: parent.horizontalCenter
  223. text: qsTr("E-mail:")
  224. font.pixelSize: 28
  225. }
  226. MyTextInput {
  227. id: tiEmail
  228. anchors.horizontalCenter: parent.horizontalCenter
  229. height: 50
  230. width: parent.width
  231. readOnly: vCardPage.readOnly
  232. __readonlyIsGray: false
  233. }
  234. Item { height: 10; width: vCardPage.width }
  235. Text {
  236. id: txtBirthday
  237. anchors.horizontalCenter: parent.horizontalCenter
  238. text: qsTr("Birthday:")
  239. font.pixelSize: 28
  240. }
  241. MyTextInput {
  242. id: tiBirthday
  243. anchors.horizontalCenter: parent.horizontalCenter
  244. height: 50
  245. width: parent.width
  246. readOnly: vCardPage.readOnly
  247. __readonlyIsGray: false
  248. }
  249. Item { height: 10; width: vCardPage.width }
  250. Text {
  251. id: txtUrl
  252. anchors.horizontalCenter: parent.horizontalCenter
  253. text: qsTr("Url:")
  254. font.pixelSize: 28
  255. }
  256. MyTextInput {
  257. id: tiUrl
  258. anchors.horizontalCenter: parent.horizontalCenter
  259. height: 50
  260. width: parent.width
  261. readOnly: vCardPage.readOnly
  262. __readonlyIsGray: false
  263. }
  264. Item { height: 10; width: vCardPage.width }
  265. } // Column
  266. }
  267. ToolBar {
  268. id: toolBar
  269. ToolButton {
  270. id: toolBarButtonDialog
  271. icon: "qrc:/qml/images/bar_roster.png"
  272. anchors.left: parent.left
  273. anchors.leftMargin: 30
  274. onClicked: {
  275. vCardPage.closePage( vCardPage.nextPage )
  276. }
  277. pauseAnim: 500
  278. }/*
  279. ToolButton {
  280. id: toolBarButtonOptions
  281. icon: "qrc:/qml/images/bar_ok.png"
  282. anchors.left: parent.left
  283. anchors.leftMargin: (3.5*(parent.width/4) - 0.5*toolBarButtonOptions.width)
  284. onClicked: {
  285. //TODO: Отправка vCard на сервер
  286. //xmppClient.setMyVCard()
  287. var objVCard = Qt.createQmlObject("import QtQuick 1.1; import meegim 1.0; XmppVCard {}", parent, "VCardPage.qml: XmppVCard" )
  288. objVCard.name = "xyxyxy"
  289. console.log(objVCard.name)
  290. }
  291. pauseAnim: 600
  292. visible: false
  293. }*/
  294. }
  295. }