AccountsPage.qml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. import QtQuick 1.1
  2. MyPage {
  3. id: messagesPage
  4. /********************************************************************************/
  5. colorPage: "white"
  6. Component {
  7. id: componentAccountItem
  8. Rectangle {
  9. id: wrapper
  10. clip: true
  11. width: listViewAccounts.width
  12. height: 90
  13. //color: "white"
  14. gradient: gr_free
  15. Gradient {
  16. id: gr_free
  17. GradientStop { id: gr1; position: 0; color: "white" }
  18. GradientStop { id: gr2; position: 0.5; color: "#ededed" }
  19. GradientStop { id: gr3; position: 1; color: "#d7d7d7" }
  20. }
  21. Gradient {
  22. id: gr_press
  23. GradientStop { position: 0; color: "lightblue" }
  24. GradientStop { position: 1; color: "lightblue" }
  25. GradientStop { position: 0.5; color: "#ededed" }
  26. }
  27. Image {
  28. id: imgAcc
  29. anchors.verticalCenter: parent.verticalCenter
  30. anchors.left: parent.left
  31. anchors.leftMargin: 10
  32. source: accIcon
  33. }
  34. Text {
  35. id: txtAcc
  36. anchors.verticalCenter: parent.verticalCenter
  37. anchors.left: imgAcc.right
  38. anchors.leftMargin: 10
  39. anchors.right: imgDefualt.visible ? imgDefualt.left : parent.right
  40. anchors.rightMargin: 10
  41. text: accJid
  42. font.pixelSize: 36
  43. clip: true
  44. }
  45. Image {
  46. id: imgDefualt
  47. source: "qrc:/qml/images/bar_ok.png"
  48. anchors.right: parent.right; anchors.rightMargin: 5
  49. anchors.verticalCenter: parent.verticalCenter
  50. //anchors.top: parent.top; anchors.topMargin: 5
  51. height: 40
  52. width: 40
  53. smooth: true
  54. visible: accDefault
  55. }
  56. states: State {
  57. name: "Current"
  58. when: (wrapper.ListView.isCurrentItem && (main.accJid != "") )
  59. //PropertyChanges { target: wrapper; color: "lightblue" }
  60. PropertyChanges { target: wrapper; gradient: gr_press }
  61. }
  62. transitions: Transition {
  63. //NumberAnimation { properties: "position"; duration: 300 }
  64. }
  65. MouseArea {
  66. id: maAccItem
  67. anchors.fill: parent
  68. onDoubleClicked: {
  69. wrapper.ListView.view.currentIndex = index
  70. main.accJid = accJid
  71. main.accPass = accPasswd
  72. main.accDefault = accDefault
  73. main.accResource = accResource
  74. main.accHost = accHost
  75. main.accPort = accPort
  76. main.accManualHostPort = accManualHostPort
  77. messagesPage.closePage( "qrc:/qml/AccountAddPage.qml" )
  78. }
  79. onClicked: {
  80. wrapper.ListView.view.currentIndex = index
  81. main.accJid = accJid
  82. main.accPass = accPasswd
  83. main.accDefault = accDefault
  84. main.accResource = accResource
  85. main.accHost = accHost
  86. main.accPort = accPort
  87. main.accManualHostPort = accManualHostPort
  88. }
  89. }
  90. }
  91. }
  92. ListView {
  93. id: listViewAccounts
  94. anchors.top: parent.top
  95. anchors.bottom: toolBar.top
  96. anchors.left: parent.left
  97. anchors.right: parent.right
  98. clip: true
  99. delegate: componentAccountItem
  100. model: settings.accounts
  101. }
  102. Component.onCompleted: {
  103. settings.initListOfAccounts()
  104. main.accJid = ""
  105. }
  106. /********************************( Toolbar )************************************/
  107. ToolBar {
  108. id: toolBar
  109. ToolButton {
  110. id: toolBarButtonRoster
  111. icon: "qrc:/qml/images/bar_roster.png"
  112. anchors.left: parent.left
  113. anchors.leftMargin: (0.5*(parent.width/4) - 0.5*toolBarButtonRoster.width)
  114. onClicked: {
  115. main.initAccount() // инициализация аккуанта на клиента
  116. messagesPage.closePage( "qrc:/qml/RosterPage.qml" )
  117. }
  118. pauseAnim: 500
  119. }
  120. ToolButton {
  121. id: toolBarButtonRemove
  122. icon: "qrc:/qml/images/bar_close.png"
  123. anchors.left: parent.left
  124. anchors.leftMargin: (1.5*(parent.width/4) - 0.5*toolBarButtonRemove.width)
  125. onClicked: {
  126. if( main.accJid != "" ) {
  127. dlgQueryRemove.dlgShowHide()
  128. }
  129. }
  130. pauseAnim: 600
  131. }
  132. ToolButton {
  133. id: toolBarButtonEdit
  134. icon: "qrc:/qml/images/bar_edit.png"
  135. anchors.left: parent.left
  136. anchors.leftMargin: (2.5*(parent.width/4) - 0.5*toolBarButtonEdit.width)
  137. onClicked: {
  138. if( main.accJid != "" ) {
  139. messagesPage.closePage( "qrc:/qml/AccountAddPage.qml" )
  140. }
  141. }
  142. pauseAnim: 700
  143. }
  144. ToolButton {
  145. id: toolBarButtonOptions
  146. icon: "qrc:/qml/images/bar_add.png"
  147. anchors.left: parent.left
  148. anchors.leftMargin: (3.5*(parent.width/4) - 0.5*toolBarButtonOptions.width)
  149. onClicked: {
  150. main.accJid = ""
  151. main.accPass = ""
  152. main.accDefault = false
  153. main.accResource = ""
  154. main.accHost = ""
  155. main.accPort = ""
  156. messagesPage.closePage( "qrc:/qml/AccountAddPage.qml" )
  157. }
  158. pauseAnim: 800
  159. }
  160. }
  161. /*********************************************************************/
  162. DialogQuery {
  163. id: dlgQueryRemove
  164. title: qsTr("Remove account")
  165. text: qsTr("Remove ") + main.accJid + " ?"
  166. onClickedOk: {
  167. settings.removeAccount( main.accJid )
  168. settings.initListOfAccounts()
  169. }
  170. }
  171. /*********************************************************************/
  172. }