MessagesPage.qml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. import QtQuick 1.1
  2. //FIXME: temporary for the platform: Harmattan
  3. //use TextArea
  4. //import com.nokia.meego 1.0
  5. MyPage {
  6. id: messagesPage
  7. /************************************************************/
  8. colorPage: "white"
  9. property string avatarPic: ""
  10. property string resourceJid: ""
  11. Component.onCompleted: {
  12. /* разблокировка ориентации */
  13. main.appOrientation = main.orAuto
  14. /* открываем чат и инициализируем список сообщениями
  15. * которые были ранее с этим собеседником */
  16. xmppClient.openChat( xmppClient.chatJid )
  17. /* запрашиваем его аватарку */
  18. avatarPic = xmppClient.getAvatarByJid( xmppClient.chatJid )
  19. /* если последнее сообщение было от собеседника чата
  20. * то инициализируем ресурс messagesPage.resourceJid
  21. * ресурсом его последнего сообщения */
  22. if( xmppClient.bareJidLastMsg == xmppClient.chatJid ) {
  23. messagesPage.resourceJid = xmppClient.resourceLastMsg
  24. }
  25. if( messagesPage.resourceJid == "" ) {
  26. listModelResources.append( {resource:"(by default)", checked:true} )
  27. } else {
  28. listModelResources.append( {resource:"(by default)", checked:false} )
  29. }
  30. var listResources = xmppClient.getResourcesByJid(xmppClient.chatJid)
  31. /* инициализация списка ресурсов */
  32. for( var z=0; z<listResources.length; z++ )
  33. {
  34. //console.log( "resources:["+listResources[z]+"]" )
  35. if( listResources[z] == "" ) { continue; }
  36. if( messagesPage.resourceJid ==listResources[z] ) {
  37. listModelResources.append( {resource:listResources[z], checked:true} )
  38. } else {
  39. listModelResources.append( {resource:listResources[z], checked:false} )
  40. }
  41. }
  42. }
  43. /**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
  44. Component {
  45. id: componentWrapperItem
  46. Rectangle {
  47. id: wrapper
  48. border.color: msgType == 0 ? "blue" : "red"
  49. color: msgMy === true ? "white" : "lightblue"
  50. radius: 8
  51. property string text: msgText
  52. clip: true
  53. //height: imgDlr.height+imgDlr.anchors.bottomMargin + imgAvatar.height + imgAvatar.anchors.topMargin
  54. anchors.horizontalCenter: parent.horizontalCenter
  55. MouseArea {
  56. id: maMsg
  57. anchors.fill: parent
  58. enabled: msgType == 0 ? true : false
  59. onPressAndHold: {
  60. // цитирование
  61. animCit.start()
  62. txtMessage.text += "> \"" + mainSmiles.htmlToPlainText( wrapper.text ) + "\"\n"
  63. //txtMessage.text += "> \"" + wrapper.text + "\"<br/>"
  64. }
  65. onClicked: {
  66. wrapper.ListView.view.currentIndex = index
  67. }
  68. }
  69. ListView.onAdd: ParallelAnimation {
  70. NumberAnimation {
  71. target: wrapper
  72. property: "opacity"
  73. from: 0; to: 1
  74. duration: 100
  75. easing.type: Easing.InOutQuad
  76. }
  77. NumberAnimation {
  78. target: wrapper;
  79. property: "scale";
  80. duration: 200;
  81. from: 0.1; to: 1
  82. easing.type: Easing.InOutQuad
  83. }
  84. }
  85. Image {
  86. id: imgDlr
  87. visible: msgType == 0 ? true : false
  88. anchors.bottom: parent.bottom; anchors.bottomMargin: 10
  89. source: msgMy !== true ? "qrc:/qml/images/msg_recv.png" : ( msgDlr === true ? "qrc:/qml/images/msg_dlr.png" : "qrc:/qml/images/msg_sent.png")
  90. height: 32
  91. width: 32
  92. smooth: true
  93. Component.onCompleted: {
  94. if( msgMy == true ) {
  95. imgDlr.anchors.right = parent.right
  96. imgDlr.anchors.rightMargin = 10
  97. } else {
  98. imgDlr.anchors.left = parent.left
  99. imgDlr.anchors.leftMargin = 10
  100. }
  101. }
  102. }
  103. Image {
  104. id: imgAvatar
  105. smooth: true
  106. height: 32
  107. width: 32
  108. anchors.top: parent.top; anchors.topMargin: 10
  109. source: msgMy === true ? "qrc:/qml/images/avatar.png" : (avatarPic === "" ? "qrc:/qml/images/avatar.png" : avatarPic)
  110. Image {
  111. anchors.centerIn: parent
  112. height: parent.height
  113. width: parent.width
  114. smooth: true
  115. source: msgMy === true ? "qrc:/qml/images/meego_frame_32w.png" : "qrc:/qml/images/meego_frame_32b.png"
  116. }
  117. Component.onCompleted: {
  118. if( msgMy == true ) {
  119. imgAvatar.anchors.right = parent.right
  120. imgAvatar.anchors.rightMargin = 10
  121. } else {
  122. imgAvatar.anchors.left = parent.left
  123. imgAvatar.anchors.leftMargin = 10
  124. }
  125. }
  126. }
  127. Text {
  128. id: txtHeader
  129. anchors.top: parent.top; anchors.topMargin: 10
  130. anchors.left: msgMy == true ? parent.left : imgDlr.right; anchors.leftMargin: 10
  131. text: msgMy === true ? "[" + msgDateTime + "] :" : "[" + msgDateTime + "] " + xmppClient.chatJid + "/" + msgResource + ":"
  132. font.pixelSize: 16
  133. opacity: 0.8
  134. color: msgMy === true ? "blue" : "black"
  135. }
  136. Text {
  137. id: text_field
  138. anchors.left: msgMy == true ? parent.left : imgDlr.right; anchors.leftMargin: 10
  139. anchors.right: msgMy == true ? imgDlr.left : parent.right; anchors.rightMargin: 10
  140. anchors.top: txtHeader.bottom; anchors.topMargin: 5
  141. anchors.bottom: parent.bottom; anchors.bottomMargin: 10
  142. text: msgType == 0 ? wrapper.text : msgMy == true ? "You have called " + xmppClient.chatJid : xmppClient.chatJid + " has called you !"
  143. wrapMode: Text.WrapAtWordBoundaryOrAnywhere
  144. font.pixelSize: 20
  145. font.italic: msgType == 0 ? false : true
  146. textFormat: Text.RichText
  147. onLinkActivated: {
  148. Qt.openUrlExternally(link)
  149. }
  150. }
  151. width: listViewMessages.width - 10
  152. height: text_field.paintedHeight + text_field.anchors.topMargin + text_field.anchors.bottomMargin + txtHeader.height + txtHeader.anchors.topMargin <
  153. imgDlr.height+imgDlr.anchors.bottomMargin + imgAvatar.height + imgAvatar.anchors.topMargin ?
  154. imgDlr.height+imgDlr.anchors.bottomMargin + imgAvatar.height + imgAvatar.anchors.topMargin :
  155. text_field.paintedHeight + text_field.anchors.topMargin + text_field.anchors.bottomMargin + txtHeader.height + txtHeader.anchors.topMargin
  156. SequentialAnimation {
  157. id: animCit
  158. NumberAnimation { target: wrapper; property: "rotation"; to: 0.8; duration: 35 }
  159. NumberAnimation { target: wrapper; property: "rotation"; to: -0.8; duration: 70 }
  160. NumberAnimation { target: wrapper; property: "rotation"; to: 0; duration: 30 }
  161. loops: 3
  162. alwaysRunToEnd: true
  163. }
  164. Component.onCompleted: {
  165. // парсинг на смайлы в сообщении
  166. wrapper.text = mainSmiles.parseMsgString( wrapper.text )
  167. }
  168. states: State {
  169. name: "Current"
  170. when: (wrapper.ListView.isCurrentItem )
  171. //PropertyChanges { target: posGr1; position: 0 }
  172. }
  173. transitions: Transition {
  174. //NumberAnimation { properties: "position"; duration: 300 }
  175. }
  176. }
  177. } //Component
  178. /**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
  179. /* --------------------( ресурсы jid )-------------------- */
  180. ListModel {
  181. id: listModelResources
  182. }
  183. /*--------------------(верхняя панелька с отображение информации о jid)--------------------*/
  184. property bool flTyping: false
  185. property bool flSendMsg: false
  186. Timer {
  187. id: timerTextTyping
  188. interval: 3000
  189. repeat: true
  190. onTriggered: {
  191. if( flTyping == false ) {
  192. timerTextTyping.stop()
  193. xmppClient.typingStop( xmppClient.chatJid, messagesPage.resourceJid )
  194. }
  195. flTyping = false
  196. }
  197. }
  198. /* ------------( подписка на сигналы XMPP клиента )------------ */
  199. Connections {
  200. target: xmppClient
  201. onPresenceJidChanged: {
  202. if( presenceBareJid == xmppClient.chatJid ) {
  203. imgPresence.source = presencePicStatus
  204. //txtPresence.text = strTopPanel( isTyping, false ) //что это ??? - закоментировал
  205. }
  206. }
  207. onTypingChanged: {
  208. if( bareJid == xmppClient.chatJid ) {
  209. txtPresence.text = strTopPanel( isTyping, true ) //показываем надпись "печатает.../остановил печать"
  210. }
  211. }
  212. onMessageReceived: {
  213. txtPresence.text = strTopPanel( false, false ) //скрываем надпись "печатает..."
  214. if( xmppClient.bareJidLastMsg == xmppClient.chatJid ) {
  215. messagesPage.resourceJid = xmppClient.resourceLastMsg
  216. }
  217. }
  218. }
  219. function strTopPanel( isTyping, showTyping )
  220. {
  221. var ret = xmppClient.chatJid
  222. if(messagesPage.resourceJid != "") {
  223. ret += "/" + messagesPage.resourceJid
  224. }
  225. if( showTyping ) {
  226. if( isTyping ) {
  227. ret += " is typing"
  228. timerChangeTop.interval = 5000
  229. timerChangeTop.restart()
  230. } else {
  231. ret += " has stopped typing"
  232. timerChangeTop.interval = 4000
  233. timerChangeTop.restart()
  234. }
  235. }
  236. return ret;
  237. }
  238. Timer {
  239. id: timerChangeTop
  240. onTriggered: {
  241. txtPresence.text = strTopPanel( false, false )
  242. }
  243. }
  244. /* панелька с надписью jid */
  245. Rectangle {
  246. id: topPanelChat
  247. visible: main.inPortrait
  248. z: 11
  249. width: parent.width
  250. height: 40
  251. color: "black"
  252. anchors.top: parent.top;
  253. anchors.left: parent.left;
  254. gradient: gr1
  255. Gradient {
  256. id: gr1
  257. GradientStop { position: 0; color: "#3f3f3f" }
  258. GradientStop { position: 1; color: "#000000" }
  259. }
  260. Gradient {
  261. id: gr2
  262. GradientStop { position: 0; color: "#000000" }
  263. GradientStop { position: 1; color: "#3f3f3f" }
  264. }
  265. Image {
  266. id: imgPresence
  267. anchors.left: parent.left; anchors.leftMargin: 10
  268. anchors.verticalCenter: parent.verticalCenter
  269. height: topPanelChat.height - 10
  270. width: height
  271. source: xmppClient.getPicPresenceByJid( xmppClient.chatJid )
  272. }
  273. Text {
  274. id: txtPresence
  275. anchors.left: imgPresence.right; anchors.leftMargin: 10
  276. anchors.verticalCenter: parent.verticalCenter
  277. color: "white"
  278. font.pixelSize: parent.height/2.5
  279. text: strTopPanel( false, false )
  280. }
  281. Image {
  282. id: imgDownArrow
  283. source: "qrc:/qml/images/small_arrow_black.png"
  284. anchors.right: parent.right; anchors.rightMargin: 15
  285. smooth: true
  286. rotation: -90
  287. }
  288. MouseArea {
  289. anchors.fill: parent
  290. onClicked: {
  291. if(panelListResources.state == "hidden") {
  292. panelListResources.state = "visible"
  293. } else {
  294. panelListResources.state = "hidden"
  295. }
  296. }
  297. onPressedChanged: {
  298. if(pressed) {
  299. topPanelChat.gradient = gr2
  300. } else {
  301. topPanelChat.gradient = gr1
  302. }
  303. }
  304. }
  305. }
  306. /* -----------------( выпадающая панелька с ресурсами jid )----------------- */
  307. Rectangle {
  308. id: panelListResources
  309. z: 10
  310. clip: true
  311. anchors.left: parent.left
  312. width: parent.width
  313. height: 250
  314. color: "black"
  315. opacity: 0.8
  316. state: "hidden"
  317. states: [
  318. State {
  319. name: "hidden"
  320. AnchorChanges{ target: panelListResources; anchors.bottom: messagesPage.top }
  321. PropertyChanges { target: imgDownArrow ; rotation: -90 }
  322. },
  323. State {
  324. name: "visible"
  325. AnchorChanges{ target: panelListResources; anchors.top: topPanelChat.bottom }
  326. PropertyChanges { target: imgDownArrow ; rotation: 90 }
  327. }
  328. ]
  329. transitions: Transition {
  330. ParallelAnimation {
  331. AnchorAnimation { duration: 400; easing.type: Easing.InOutQuad }
  332. PropertyAnimation { duration: 400; property: "rotation" }
  333. }
  334. }
  335. ListView {
  336. id: listViewResources
  337. //anchors.fill: parent
  338. anchors.top: parent.top
  339. anchors.left: parent.left
  340. width: parent.width
  341. height: parent.height - bottomPanel.height
  342. model: listModelResources
  343. clip: true
  344. delegate: Component {
  345. Rectangle {
  346. id: itemResource
  347. height: 60
  348. width: panelListResources.width
  349. color: "transparent"
  350. border.color: "gray"
  351. radius: 5
  352. Text {
  353. id: textResource
  354. text: resource
  355. font.pixelSize: itemResource.height/2
  356. anchors.horizontalCenter: parent.horizontalCenter
  357. anchors.verticalCenter: parent.verticalCenter
  358. color: "white"
  359. font.bold: false
  360. }
  361. states: State {
  362. name: "Current"
  363. when: itemResource.ListView.isCurrentItem
  364. PropertyChanges { target: itemResource; color: "gray" }
  365. PropertyChanges { target: textResource; font.bold: true }
  366. }
  367. MouseArea {
  368. anchors.fill: parent
  369. onClicked: {
  370. itemResource.ListView.view.currentIndex = index
  371. if( index == 0 ) {
  372. messagesPage.resourceJid = ""
  373. } else {
  374. messagesPage.resourceJid = resource
  375. }
  376. for( var i=0; i<listModelResources.count; i++ ) {
  377. if( index == i ) {
  378. listModelResources.get( index ).checked = true
  379. } else {
  380. listModelResources.get( index ).checked = false
  381. }
  382. }
  383. txtPresence.text = strTopPanel( false, false )
  384. panelListResources.state = "hidden"
  385. } //onClicked
  386. } //MouseArea
  387. }
  388. } //Component
  389. }
  390. Rectangle {
  391. id: bottomPanel
  392. anchors.left: parent.left
  393. anchors.bottom: parent.bottom
  394. width: parent.width
  395. height: 25
  396. gradient: Gradient {
  397. GradientStop { position: 0; color: "gray" }
  398. GradientStop { position: 0.5; color: "black" }
  399. GradientStop { position: 1; color: "gray" }
  400. }
  401. MouseArea {
  402. anchors.fill: parent
  403. onClicked: {
  404. panelListResources.state = "hidden"
  405. }
  406. }
  407. }
  408. }
  409. /* --------------------(список сообщений)-------------------- */
  410. ListView {
  411. id: listViewMessages
  412. anchors.top: main.inPortrait == true ? topPanelChat.bottom : parent.top
  413. anchors.topMargin: 5
  414. anchors.bottom: panelWriteText.top; anchors.bottomMargin: 5
  415. anchors.left: parent.left;// anchors.leftMargin: 5
  416. anchors.right: parent.right;// anchors.rightMargin: 5
  417. clip: true
  418. model: xmppClient.messages
  419. delegate: componentWrapperItem
  420. spacing: 5
  421. onCountChanged: {
  422. listViewMessages.positionViewAtIndex(count - 1, ListView.Beginning)
  423. }
  424. onHeightChanged: {
  425. listViewMessages.positionViewAtIndex(count - 1, ListView.Beginning)
  426. }
  427. }
  428. /*--------------------(панелька с вводом текста)--------------------*/
  429. Rectangle {
  430. id: panelWriteText
  431. height: 100
  432. anchors.bottom: main.inPortrait == true ? toolBar.top : parent.bottom;
  433. anchors.left: parent.left;
  434. anchors.right: parent.right;
  435. color: "gray"
  436. Rectangle {
  437. id: wrapperTextEdit
  438. anchors.bottom: parent.bottom; anchors.bottomMargin: 5
  439. anchors.left: parent.left; anchors.leftMargin: 5
  440. anchors.right: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? wrapperImgSmiles.left : wrapperImgSend.left
  441. anchors.top: parent.top; anchors.topMargin: 5
  442. //border.color: "blue"
  443. //border.width: 2
  444. //color: "white"
  445. color: "transparent"
  446. radius: 8
  447. clip: true
  448. /*MyTextEdit2 {
  449. id: txtMessage
  450. wrapMode: TextEdit.Wrap
  451. font.pixelSize: 22
  452. textFormat: TextEdit.PlainText
  453. width: parent.width
  454. height: parent.height
  455. onTextChanged: {
  456. flTyping = true
  457. if( (!timerTextTyping.running) && (flSendMsg==false) ) {
  458. timerTextTyping.restart()
  459. xmppClient.typingStart( xmppClient.chatJid )
  460. flTyping = false
  461. }
  462. }
  463. }*/
  464. Flickable {
  465. id: flickMsg
  466. anchors.fill: parent
  467. contentHeight: txtMessage.height
  468. contentWidth: txtMessage.width
  469. flickableDirection: Flickable.VerticalFlick
  470. clip: true
  471. function ensureVisible(r)
  472. {
  473. if (contentX >= r.x)
  474. contentX = r.x;
  475. else if (contentX+width <= r.x+r.width)
  476. contentX = r.x+r.width-width;
  477. if (contentY >= r.y)
  478. contentY = r.y;
  479. else if (contentY+height <= r.y+r.height)
  480. contentY = r.y+r.height-height;
  481. }
  482. MyTextEdit2 {
  483. id: txtMessage
  484. wrapMode: TextEdit.Wrap
  485. font.pixelSize: 22
  486. textFormat: TextEdit.PlainText
  487. //textFormat: TextEdit.RichText
  488. width: flickMsg.width
  489. height: flickMsg.height
  490. //onCursorRectangleChanged: flickMsg.ensureVisible( cursorRectangle )
  491. onTextChanged: {
  492. flTyping = true
  493. if( (!timerTextTyping.running) && (flSendMsg==false) ) {
  494. timerTextTyping.restart()
  495. xmppClient.typingStart( xmppClient.chatJid, messagesPage.resourceJid )
  496. flTyping = false
  497. }
  498. }
  499. }
  500. } //Flickable
  501. } //wrapperTextEdit
  502. /**/
  503. /* кнопка смайлов для вертикальной ориентации */
  504. Rectangle {
  505. id: wrapperImgSmiles
  506. visible: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? true : false
  507. height: 100
  508. width: 100
  509. anchors.right:wrapperImgSend.left
  510. anchors.verticalCenter: parent.verticalCenter
  511. color: "transparent"
  512. Image {
  513. id: imgFramePressSmiles
  514. source: "qrc:/qml/images/bar_glow.png"
  515. width: imgSmilesMsg.width + 2
  516. height: imgSmilesMsg.height + 2
  517. anchors.centerIn: parent
  518. smooth: true
  519. opacity: 0
  520. Behavior on opacity { NumberAnimation { duration: 150 } }
  521. }
  522. Image {
  523. id: imgSmilesMsg
  524. anchors.centerIn: parent
  525. source: "qrc:/qml/images/bar_smiles.png"
  526. height: 96
  527. width: 96
  528. smooth: true
  529. MouseArea {
  530. anchors.fill: parent
  531. onClicked: {
  532. dlgSmiles.dlgShowHide()
  533. }
  534. onPressedChanged: {
  535. if( pressed ) {
  536. imgFramePressSmiles.opacity = 1
  537. } else {
  538. imgFramePressSmiles.opacity = 0
  539. }
  540. }
  541. }
  542. }
  543. } //wrapperImgSend
  544. /* копка отправки сообщения */
  545. Rectangle {
  546. id: wrapperImgSend
  547. height: 100
  548. width: 100
  549. anchors.right:parent.right
  550. //anchors.rightMargin: 5
  551. anchors.verticalCenter: parent.verticalCenter
  552. color: "transparent"
  553. Image {
  554. id: imgFramePress
  555. source: "qrc:/qml/images/bar_glow.png"
  556. width: imgSendMsg.width + 2
  557. height: imgSendMsg.height + 2
  558. anchors.centerIn: parent
  559. smooth: true
  560. opacity: 0
  561. Behavior on opacity { NumberAnimation { duration: 150 } }
  562. }
  563. Image {
  564. id: imgSendMsg
  565. anchors.centerIn: parent
  566. source: "qrc:/qml/images/msg_send.png"
  567. MouseArea {
  568. anchors.fill: parent
  569. onClicked: {
  570. var ret = xmppClient.sendMyMessage( xmppClient.chatJid, messagesPage.resourceJid, txtMessage.text )
  571. if( ret ) {
  572. flSendMsg = true
  573. timerTextTyping.stop()
  574. txtMessage.text = ""
  575. flTyping = false
  576. flSendMsg = false
  577. notify.notifyMessageSent()
  578. }
  579. }
  580. onPressedChanged: {
  581. if( pressed ) {
  582. imgFramePress.opacity = 1
  583. } else {
  584. imgFramePress.opacity = 0
  585. }
  586. }
  587. }
  588. }
  589. } //wrapperImgSend
  590. } //panelWriteText
  591. /********************************( Toolbar )************************************/
  592. ToolBar {
  593. id: toolBar
  594. visible: main.inPortrait
  595. /****/
  596. ToolButton {
  597. id: toolBarButtonRoster
  598. icon: "qrc:/qml/images/bar_roster.png"
  599. anchors.left: parent.left
  600. anchors.leftMargin: (0.5*(parent.width/4) - 0.5*toolBarButtonRoster.width)
  601. onClicked: {
  602. messagesPage.closePage( "qrc:/qml/RosterPage.qml" )
  603. xmppClient.resetUnreadMessages( xmppClient.chatJid ) //сброс непрочитанных сообщ.
  604. xmppClient.hideChat()
  605. }
  606. pauseAnim: 500
  607. }
  608. ToolButton {
  609. id: toolBarButtonChats
  610. icon: "qrc:/qml/images/bar_open_chats.png"
  611. anchors.left: parent.left
  612. anchors.leftMargin: (1.5*(parent.width/4) - 0.5*toolBarButtonChats.width)
  613. onClicked: {
  614. messagesPage.closePage( "qrc:/qml/ChatsPage.qml" )
  615. xmppClient.resetUnreadMessages( xmppClient.chatJid ) //сброс непрочитанных сообщ.
  616. xmppClient.hideChat()
  617. }
  618. pauseAnim: 600
  619. }
  620. ToolButton {
  621. id: toolBarButtonSmiles
  622. icon: "qrc:/qml/images/bar_smiles.png"
  623. anchors.left: parent.left
  624. anchors.leftMargin: (2.5*(parent.width/4) - 0.5*toolBarButtonSmiles.width)
  625. onClicked: {
  626. dlgSmiles.dlgShowHide()
  627. }
  628. pauseAnim: 700
  629. }
  630. ToolButton {
  631. id: toolBarButtonOptions
  632. icon: "qrc:/qml/images/bar_options.png"
  633. anchors.left: parent.left
  634. anchors.leftMargin: (3.5*(parent.width/4) - 0.5*toolBarButtonOptions.width)
  635. onClicked: {
  636. dlgMsgOptions.dlgShowHide()
  637. }
  638. pauseAnim: 800
  639. }
  640. }
  641. /*********************************************************************/
  642. /*-------------------( смайлы )-------------------*/
  643. DialogSmiles {
  644. id: dlgSmiles
  645. title: "Smiles"
  646. smilesModel: mainSmiles.smilesModel
  647. onSmileSelected: {
  648. txtMessage.text += dlgSmiles.selectedSmile
  649. }
  650. }
  651. /*----------------------( опции чата )----------------------*/
  652. DialogMsgOptions {
  653. id: dlgMsgOptions
  654. onItemClicked: {
  655. if( itemSelected == "clearChat" ) {
  656. xmppClient.clearChat( xmppClient.chatJid )
  657. } else if( itemSelected == "attention" ) {
  658. xmppClient.attentionSend( xmppClient.chatJid, messagesPage.resourceJid )
  659. }
  660. }
  661. }
  662. }