DialogMucOptions.qml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. hideTo: hideToRight
  10. height: parent.height*0.3
  11. ListModel {
  12. id: modelListOptions
  13. ListElement {
  14. name: "clearChat"
  15. image: "qrc:/qml/images/menu_clear.png"
  16. submenu: false
  17. submenuback: false
  18. }
  19. }
  20. function textItem( nameElement )
  21. {
  22. var ret = ""
  23. if( nameElement === "clearChat" ) {
  24. ret = qsTr("Clear chat")
  25. } else if( nameElement === "attention" ) {
  26. ret = qsTr("Send attention")
  27. }
  28. return ret
  29. }
  30. Component {
  31. id: componentWrapper
  32. Rectangle {
  33. id: wrapper
  34. width: listViewOptions.width-4
  35. height: 70
  36. border.color: "gray"
  37. anchors.horizontalCenter: parent.horizontalCenter
  38. Image {
  39. id: imgItem
  40. anchors.verticalCenter: parent.verticalCenter
  41. anchors.left: parent.left
  42. anchors.leftMargin: 20
  43. source: image
  44. height: 56; width: height
  45. smooth: true
  46. }
  47. Text {
  48. id: txtItem
  49. anchors.verticalCenter: parent.verticalCenter
  50. anchors.left: imgItem.right
  51. anchors.leftMargin: 20
  52. text: textItem( name )
  53. font.pixelSize: 28
  54. }
  55. Image {
  56. anchors.verticalCenter: parent.verticalCenter
  57. anchors.right: parent.right
  58. anchors.rightMargin: 10
  59. visible: submenu
  60. source: "qrc:/qml/images/small_arrow_black.png"
  61. rotation: submenuback ? 0 : 180
  62. }
  63. MouseArea {
  64. id: mouseAreaItem;
  65. anchors.fill: parent
  66. onClicked: {
  67. wrapper.ListView.view.currentIndex = index
  68. if( submenuback ) {
  69. currListModel = prevListModel
  70. prevListModel = undefined
  71. animChangeMenu.running = true
  72. } else if( submenu ) {
  73. prevListModel = listViewOptions.model
  74. if( name == "contact" ) {
  75. currListModel = modelListContact
  76. }
  77. animChangeMenu.running = true
  78. } else {
  79. dlgOptionsRoster.state = "hidden"
  80. dlgOptionsRoster.itemSelected = name
  81. dlgOptionsRoster.itemClicked()
  82. }
  83. }
  84. }
  85. states: State {
  86. name: "Current"
  87. when: wrapper.ListView.isCurrentItem
  88. PropertyChanges { target: wrapper; color: "lightblue" }
  89. }
  90. }
  91. }
  92. property int __marg1 : 3
  93. ListView {
  94. id: listViewOptions
  95. anchors.top: parent.top
  96. anchors.topMargin: __marg1
  97. anchors.left: parent.left
  98. anchors.leftMargin: __marg1
  99. anchors.bottom: parent.bottom
  100. anchors.bottomMargin: __marg1
  101. width: parent.width - __marg1*2
  102. model: modelListOptions
  103. delegate: componentWrapper
  104. clip: true
  105. }
  106. SequentialAnimation {
  107. id: animChangeMenu
  108. running: false
  109. PropertyAnimation {
  110. target: listViewOptions
  111. property: "anchors.bottomMargin"
  112. from: __marg1
  113. to: listViewOptions.height
  114. duration: 300
  115. }
  116. ScriptAction {
  117. script: {
  118. listViewOptions.model = currListModel
  119. }
  120. }
  121. PropertyAnimation {
  122. target: listViewOptions
  123. property: "anchors.bottomMargin"
  124. from: listViewOptions.height
  125. to: __marg1
  126. duration: 300
  127. }
  128. }
  129. }