DialogMyStatus.qml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import QtQuick 1.0
  2. import meegim 1.0
  3. DialogLiquid {
  4. id: dlgMyStatus
  5. signal myStatusChange
  6. property variant myStatusSet
  7. property string myTextStatus//: main.statText
  8. hideTo: hideToLeft
  9. function setStatus( status, textStatus )
  10. {
  11. var resSet = false
  12. for( var k=0; k<modelListStat.count; k++)
  13. {
  14. var ss = dlgMyStatus.status( modelListStat.get(k).name )
  15. if( ss == status ) {
  16. listViewStatus.currentIndex = k
  17. wrapperTextEdit.text = textStatus
  18. resSet = true
  19. break;
  20. }
  21. }
  22. return resSet
  23. }
  24. width: parent.width*0.9
  25. height: parent.height*0.58
  26. ListModel {
  27. id: modelListStat
  28. ListElement {
  29. name: "online"
  30. image: "qrc:/qml/images/presence-online.png"
  31. }
  32. ListElement {
  33. name: "chat"
  34. image: "qrc:/qml/images/presence-online.png"
  35. }
  36. ListElement {
  37. name: "away"
  38. image: "qrc:/qml/images/presence-away.png"
  39. }
  40. ListElement {
  41. name: "XA"
  42. image: "qrc:/qml/images/presence-away.png"
  43. }
  44. ListElement {
  45. name: "DND"
  46. image: "qrc:/qml/images/presence-busy.png"
  47. }
  48. ListElement {
  49. name: "offline"
  50. image: "qrc:/qml/images/presence-offline.png"
  51. }
  52. }
  53. function status( nameElement )
  54. {
  55. var ret = ""
  56. if( nameElement === "online" ) {
  57. ret = XmppClient.Online
  58. } else if( nameElement === "chat" ) {
  59. ret = XmppClient.Chat
  60. } else if( nameElement === "away" ) {
  61. ret = XmppClient.Away
  62. } else if( nameElement === "XA" ) {
  63. ret = XmppClient.XA
  64. } else if( nameElement === "DND" ) {
  65. ret = XmppClient.DND
  66. } else if( nameElement === "offline" ) {
  67. ret = XmppClient.Offline
  68. }
  69. return ret
  70. }
  71. function textItem( nameElement )
  72. {
  73. var ret = ""
  74. if( nameElement === "online" ) {
  75. ret = qsTr("Available")
  76. } else if( nameElement === "chat" ) {
  77. ret = qsTr("Chatty")
  78. } else if( nameElement === "away" ) {
  79. ret = qsTr("Away")
  80. } else if( nameElement === "XA" ) {
  81. ret = qsTr("Extended away")
  82. } else if( nameElement === "DND" ) {
  83. ret = qsTr("Do not disturb")
  84. } else if( nameElement === "offline" ) {
  85. ret = qsTr("Offline")
  86. }
  87. return ret
  88. }
  89. Component {
  90. id: componentWrapper
  91. Rectangle {
  92. id: wrapper
  93. width: listViewStatus.width
  94. height: 70
  95. //border.color: "gray"
  96. gradient: gr_free
  97. Image {
  98. id: imgStatus
  99. anchors.verticalCenter: parent.verticalCenter
  100. anchors.left: parent.left
  101. anchors.leftMargin: 20
  102. source: image
  103. height: 56; width: height
  104. smooth: true
  105. }
  106. Text {
  107. anchors.verticalCenter: parent.verticalCenter
  108. anchors.left: imgStatus.right
  109. anchors.leftMargin: 20
  110. id: txtStatus
  111. text: textItem( name )
  112. font.pixelSize: 28
  113. }
  114. Gradient {
  115. id: gr_free
  116. GradientStop { id: gr1; position: 0; color: "white" }
  117. GradientStop { id: gr2; position: 0.5; color: "#ededed" }
  118. GradientStop { id: gr3; position: 1; color: "#d7d7d7" }
  119. }
  120. Gradient {
  121. id: gr_press
  122. GradientStop { position: 0; color: "lightblue" }
  123. GradientStop { position: 1; color: "lightblue" }
  124. GradientStop { position: 0.5; color: "#ededed" }
  125. }
  126. MouseArea {
  127. id: mouseAreaItem;
  128. anchors.fill: parent
  129. onClicked: {
  130. wrapper.ListView.view.currentIndex = index
  131. dlgMyStatus.myStatusSet = status( name )
  132. dlgMyStatus.myTextStatus = wrapperTextEdit.text
  133. dlgMyStatus.myStatusChange()
  134. dlgMyStatus.state = "hidden"
  135. }
  136. }
  137. states: State {
  138. name: "Current"
  139. when: wrapper.ListView.isCurrentItem
  140. //PropertyChanges { target: wrapper; color: "lightblue" }
  141. PropertyChanges { target: wrapper; gradient: gr_press }
  142. PropertyChanges { target: imgStatus; anchors.leftMargin: 30 }
  143. }
  144. }
  145. }
  146. property int __marg1 : 3
  147. ListView {
  148. id: listViewStatus
  149. anchors.top: parent.top
  150. anchors.topMargin: __marg1
  151. anchors.left: parent.left
  152. anchors.leftMargin: __marg1
  153. anchors.bottom: wrapperTextEdit.top
  154. anchors.bottomMargin: 10
  155. width: parent.width - 2*__marg1
  156. model: modelListStat
  157. delegate: componentWrapper
  158. clip: true
  159. }
  160. MyTextInput2 {
  161. id: wrapperTextEdit
  162. height: 55
  163. anchors.bottom: parent.bottom; anchors.bottomMargin: 5
  164. anchors.left: parent.left; anchors.leftMargin: 10
  165. anchors.right: parent.right; anchors.rightMargin: 10
  166. text: dlgMyStatus.myTextStatus
  167. placeholderText: qsTr("Status text")
  168. }
  169. }