DialogMsgOptions.qml 4.2 KB

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