DialogOptionsRoster.qml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. import QtQuick 1.1
  2. import InvMA 1.0
  3. DialogLiquid {
  4. id: dlgOptionsRoster
  5. signal itemClicked;
  6. property string itemSelected: ""
  7. property variant prevListModel
  8. property variant currListModel
  9. property bool isOnline: false
  10. hideTo: hideToRight
  11. ListModel {
  12. id: modelListOptions
  13. ListElement {
  14. name: "accounts"
  15. image: "qrc:/qml/images/accounts.png"
  16. submenu: false
  17. submenuback: false
  18. activeOnlyOnline: false
  19. }
  20. ListElement {
  21. name: "contact"
  22. image: "qrc:/qml/images/contact_menu.png"
  23. submenu: true
  24. submenuback: false
  25. activeOnlyOnline: false
  26. }
  27. ListElement {
  28. name: "offlinejid"
  29. image: "qrc:/qml/images/onlinepeople.png"
  30. submenu: false
  31. submenuback: false
  32. activeOnlyOnline: false
  33. }
  34. /*ListElement {
  35. name: "groups"
  36. image: "qrc:/qml/images/presence-online.png"
  37. submenu: false
  38. submenuback: false
  39. }*/
  40. ListElement {
  41. name: "myvcard"
  42. image: "qrc:/qml/images/myvcard.png"
  43. submenu: false
  44. submenuback: false
  45. activeOnlyOnline: true
  46. }
  47. ListElement {
  48. name: "subscribes"
  49. image: "qrc:/qml/images/menu_auth.png"
  50. submenu: false
  51. submenuback: false
  52. activeOnlyOnline: true
  53. }
  54. ListElement {
  55. name: "enterroom"
  56. image: "qrc:/qml/images/menu_muc.png"
  57. submenu: false
  58. submenuback: false
  59. activeOnlyOnline: true
  60. }
  61. ListElement {
  62. name: "settings"
  63. image: "qrc:/qml/images/settings.png"
  64. submenu: false
  65. submenuback: false
  66. activeOnlyOnline: false
  67. }
  68. ListElement {
  69. name: "about"
  70. image: "qrc:/qml/images/info.png"
  71. submenu: false
  72. submenuback: false
  73. activeOnlyOnline: false
  74. }
  75. ListElement {
  76. name: "quit"
  77. image: "qrc:/qml/images/app_close.png"
  78. submenu: false
  79. submenuback: false
  80. activeOnlyOnline: false
  81. }
  82. }
  83. ListModel {
  84. id: modelListContact
  85. ListElement {
  86. name: "back"
  87. image: "qrc:/qml/images/menu_back.png"
  88. submenu: true
  89. submenuback: true
  90. activeOnlyOnline: false
  91. }
  92. ListElement {
  93. name: "vcard"
  94. image: "qrc:/qml/images/vcard.png"
  95. submenu: false
  96. submenuback: false
  97. activeOnlyOnline: true
  98. }
  99. ListElement {
  100. name: "contactadd"
  101. image: "qrc:/qml/images/contact_add.png"
  102. submenu: false
  103. submenuback: false
  104. activeOnlyOnline: true
  105. }
  106. ListElement {
  107. name: "contactedit"
  108. image: "qrc:/qml/images/contact_edit.png"
  109. submenu: false
  110. submenuback: false
  111. activeOnlyOnline: true
  112. }
  113. ListElement {
  114. name: "contactremove"
  115. image: "qrc:/qml/images/contact_remove.png"
  116. submenu: false
  117. submenuback: false
  118. activeOnlyOnline: true
  119. }
  120. ListElement {
  121. name: "contactsubscribe"
  122. image: "qrc:/qml/images/subscribe_accept.png"
  123. submenu: false
  124. submenuback: false
  125. activeOnlyOnline: true
  126. }
  127. ListElement {
  128. name: "contactunsubscribe"
  129. image: "qrc:/qml/images/subscribe_reject.png"
  130. submenu: false
  131. submenuback: false
  132. activeOnlyOnline: true
  133. }
  134. }
  135. function textItem( nameElement )
  136. {
  137. var ret = ""
  138. if( nameElement === "accounts" ) {
  139. ret = qsTr("Accounts")
  140. } else if( nameElement === "contact" ) {
  141. ret = qsTr("Contact")
  142. } else if( nameElement === "contactadd" ) {
  143. ret = qsTr("Add contact")
  144. } else if( nameElement === "contactedit" ) {
  145. ret = qsTr("Rename contact")
  146. } else if( nameElement === "contactremove" ) {
  147. ret = qsTr("Remove contact")
  148. } else if( nameElement === "offlinejid" ) {
  149. //ret = qsTr("Show/Hide offline")
  150. if( xmppClient.showOffline ) {
  151. ret = qsTr("Hide offline")
  152. } else {
  153. ret = qsTr("Show offline")
  154. }
  155. } else if( nameElement === "groups" ) {
  156. //ret = qsTr("Show/Hide groups")
  157. } else if( nameElement === "about" ) {
  158. ret = qsTr("About")
  159. } else if( nameElement === "settings" ) {
  160. ret = qsTr("Settings")
  161. } else if( nameElement === "vcard" ) {
  162. ret = qsTr("vCard")
  163. } else if( nameElement === "myvcard" ) {
  164. ret = qsTr("My vCard")
  165. } else if( nameElement === "quit" ) {
  166. ret = qsTr("Quit")
  167. } else if( nameElement === "back" ) {
  168. ret = qsTr("Back")
  169. } else if( nameElement === "contactsubscribe" ) {
  170. ret = qsTr("Request authorization")
  171. } else if( nameElement === "contactunsubscribe" ) {
  172. ret = qsTr("Unsubscribe")
  173. } else if( nameElement === "subscribes" ) {
  174. ret = qsTr("Received requests")
  175. } else if( nameElement === "enterroom" ) {
  176. ret = qsTr("Join groupchat")
  177. }
  178. return ret
  179. }
  180. Component {
  181. id: componentWrapper
  182. Rectangle {
  183. id: wrapper
  184. width: listViewOptions.width-4
  185. height: 70
  186. border.color: "gray"
  187. anchors.horizontalCenter: parent.horizontalCenter
  188. Image {
  189. id: imgItem
  190. anchors.verticalCenter: parent.verticalCenter
  191. anchors.left: parent.left
  192. anchors.leftMargin: 20
  193. source: image
  194. height: 56; width: height
  195. smooth: true
  196. opacity: activeOnlyOnline ? ( isOnline ? 1 : 0.7 ) : 1
  197. }
  198. Text {
  199. id: txtItem
  200. anchors.verticalCenter: parent.verticalCenter
  201. anchors.left: imgItem.right
  202. anchors.leftMargin: 20
  203. text: textItem( name )
  204. font.pixelSize: 28
  205. color: activeOnlyOnline ? ( isOnline ? "black" : "gray" ) : "black"
  206. }
  207. Image {
  208. anchors.verticalCenter: parent.verticalCenter
  209. anchors.right: parent.right
  210. anchors.rightMargin: 10
  211. visible: submenu
  212. source: "qrc:/qml/images/small_arrow_black.png"
  213. rotation: submenuback ? 0 : 180
  214. }
  215. MouseArea {
  216. id: mouseAreaItem;
  217. anchors.fill: parent
  218. enabled: activeOnlyOnline ? ( isOnline ? true : false ) : true
  219. onClicked: {
  220. wrapper.ListView.view.currentIndex = index
  221. if( submenuback ) {
  222. currListModel = prevListModel
  223. prevListModel = undefined
  224. animChangeMenu.running = true
  225. } else if( submenu ) {
  226. prevListModel = listViewOptions.model
  227. if( name == "contact" ) {
  228. currListModel = modelListContact
  229. }
  230. animChangeMenu.running = true
  231. } else {
  232. dlgOptionsRoster.state = "hidden"
  233. dlgOptionsRoster.itemSelected = name
  234. dlgOptionsRoster.itemClicked()
  235. }
  236. }
  237. }
  238. states: State {
  239. name: "Current"
  240. when: wrapper.ListView.isCurrentItem
  241. PropertyChanges { target: wrapper; color: "lightblue" }
  242. }
  243. }
  244. }
  245. property int __marg1 : 3
  246. ListView {
  247. id: listViewOptions
  248. anchors.top: parent.top
  249. anchors.topMargin: __marg1
  250. anchors.left: parent.left
  251. anchors.leftMargin: __marg1
  252. anchors.bottom: parent.bottom
  253. anchors.bottomMargin: __marg1
  254. width: parent.width - __marg1*2
  255. model: modelListOptions
  256. delegate: componentWrapper
  257. clip: true
  258. }
  259. /*onStateChanged: {
  260. if( (state == "visible") && (listViewOptions.model !== listViewOptions) ) {
  261. listViewOptions.model = listViewOptions
  262. }
  263. }*/
  264. SequentialAnimation {
  265. id: animChangeMenu
  266. running: false
  267. PropertyAnimation {
  268. target: listViewOptions
  269. property: "anchors.bottomMargin"
  270. from: __marg1
  271. to: listViewOptions.height
  272. duration: 300
  273. }
  274. ScriptAction {
  275. script: {
  276. listViewOptions.model = currListModel
  277. }
  278. }
  279. PropertyAnimation {
  280. target: listViewOptions
  281. property: "anchors.bottomMargin"
  282. from: listViewOptions.height
  283. to: __marg1
  284. duration: 300
  285. }
  286. }
  287. }