DialogAccountOptions.qml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import QtQuick 1.0
  2. //import InvMA 1.0
  3. Rectangle {
  4. id: dlgAccountOptions
  5. signal itemClicked;
  6. property string itemSelected: ""
  7. function dlgShowHide() {
  8. if( state == "hidden" ) {
  9. state = "visible"
  10. } else {
  11. state = "hidden"
  12. }
  13. }
  14. width: parent.width*0.9
  15. height: parent.height*0.57
  16. radius: 10
  17. color: "white"
  18. border.color: "gray"
  19. border.width: 3
  20. clip: true
  21. smooth: true
  22. state: "hidden"
  23. property string _edit_jid: ""
  24. property string _edit_pass : ""
  25. property bool _edit_default: false
  26. onStateChanged: {
  27. if(state == "visible") {
  28. wrapperTEJid.text = _edit_jid
  29. wrapperTEPass.text = _edit_pass
  30. checkBoxDefault.state = (_edit_default ? "check" : "uncheck")
  31. }
  32. }
  33. Rectangle {
  34. id: headerDlg
  35. anchors.top: parent.top
  36. anchors.left: parent.left
  37. width: parent.width
  38. height: 70
  39. gradient: Gradient {
  40. GradientStop { position: 0; color: "#919191" }
  41. GradientStop { position: 1; color: "#666666" }
  42. }
  43. Text {
  44. anchors.centerIn: parent
  45. font.pixelSize: 28
  46. color: "white"
  47. text: qsTr("Add account")
  48. }
  49. }
  50. Text {
  51. id: txtJid
  52. text: "Jid (login@server.org):"
  53. font.pixelSize: 28
  54. anchors.top: headerDlg.bottom; anchors.topMargin: 20
  55. anchors.left: parent.left; anchors.leftMargin: 10
  56. }
  57. MyTextInput {
  58. id: wrapperTEJid
  59. anchors.top: txtJid.bottom; anchors.topMargin: 10
  60. anchors.left: parent.left; anchors.leftMargin: 10
  61. width: parent.width - 2*anchors.leftMargin
  62. height: 40
  63. font.pixelSize: 28
  64. text: _edit_jid
  65. }
  66. Text {
  67. id: txtPass
  68. text: "Password:"
  69. font.pixelSize: 28
  70. anchors.top: wrapperTEJid.bottom; anchors.topMargin: 20
  71. anchors.left: parent.left; anchors.leftMargin: 10
  72. }
  73. MyTextInput {
  74. id: wrapperTEPass
  75. anchors.top: txtPass.bottom; anchors.topMargin: 10
  76. anchors.left: parent.left; anchors.leftMargin: 10
  77. width: parent.width - 2*anchors.topMargin
  78. height: 40
  79. font.pixelSize: 28
  80. text: _edit_pass
  81. }
  82. Row {
  83. id: checkBoxDefault
  84. anchors.top: wrapperTEPass.bottom; anchors.topMargin: 20
  85. anchors.left: parent.left; anchors.leftMargin: 10
  86. state: _edit_default == true ? "check" : "uncheck"
  87. spacing: 20
  88. states: [
  89. State {
  90. name: "check"
  91. PropertyChanges { target: imgCheckDefault; source: "qrc:/qml/images/bar_ok.png" }
  92. },
  93. State {
  94. name: "uncheck"
  95. PropertyChanges { target: imgCheckDefault; source: "qrc:/qml/images/bar_blank.png" }
  96. }
  97. ]
  98. Image {
  99. id: imgCheckDefault
  100. anchors.verticalCenter: parent.verticalCenter
  101. MouseArea {
  102. anchors.fill: parent
  103. onClicked: {
  104. if( checkBoxDefault.state == "check" ) {
  105. checkBoxDefault.state = "uncheck"
  106. } else {
  107. checkBoxDefault.state = "check"
  108. }
  109. }
  110. }
  111. }
  112. Text {
  113. id: txtCheckBox
  114. anchors.verticalCenter: parent.verticalCenter
  115. text: "Use default"
  116. font.pixelSize: 28
  117. }
  118. }
  119. Row {
  120. anchors.top: checkBoxDefault.bottom; anchors.topMargin: 20
  121. anchors.left: parent.left; anchors.leftMargin: 10
  122. spacing: 20
  123. Button {
  124. id: buttonOk
  125. height: 80
  126. text: qsTr("Ok")
  127. width: dlgAccountOptions.width/2 - 20
  128. onClicked: {
  129. var jid = wrapperTEJid.text
  130. var pass = wrapperTEPass.text
  131. var isDflt = (checkBoxDefault.state == "check" ? 1 : 0 )
  132. if( (jid=="") || (pass=="") ) {
  133. return
  134. }
  135. if( (jid !=_edit_jid) || (pass != _edit_pass) || (isDflt != _edit_default) ) {
  136. cppMeegIMSettings.setAccount( jid, pass, isDflt )
  137. }
  138. cppMeegIMSettings.initListOfAccounts()
  139. wrapperTEJid.text = ""
  140. wrapperTEPass.text = ""
  141. checkBoxDefault.state = "uncheck"
  142. dlgAccOptions.state = "hidden"
  143. }
  144. }
  145. Button {
  146. id: buttonCancel
  147. height: 80
  148. text: qsTr( "Cancel" )
  149. width: dlgAccountOptions.width/2 - 20
  150. onClicked: {
  151. dlgAccOptions.state = "hidden"
  152. }
  153. }
  154. }
  155. property int howLong: 400
  156. states: [
  157. State {
  158. name: "visible"
  159. AnchorChanges { target: dlgAccountOptions; anchors.verticalCenter: parent.verticalCenter }
  160. AnchorChanges { target: dlgAccountOptions; anchors.horizontalCenter: parent.horizontalCenter }
  161. PropertyChanges { target: dlgAccountOptions; scale: 1 }
  162. PropertyChanges { target: dlgAccountOptions; z: 10 }
  163. },
  164. State {
  165. name: "hidden"
  166. AnchorChanges { target: dlgAccountOptions; anchors.top: parent.bottom }
  167. AnchorChanges { target: dlgAccountOptions; anchors.left: parent.right; }
  168. PropertyChanges { target: dlgAccountOptions; anchors.leftMargin: -100 }
  169. PropertyChanges { target: dlgAccountOptions; scale: 0.1 }
  170. PropertyChanges { target: dlgAccountOptions; z: 0 }
  171. }
  172. ]
  173. transitions: [
  174. Transition {
  175. from: "hidden"; to: "visible"
  176. ParallelAnimation {
  177. NumberAnimation { duration: howLong; property: "scale"; easing.type: Easing.InOutQuad }
  178. AnchorAnimation { duration: howLong; easing.type: Easing.InOutQuad }
  179. onRunningChanged: {
  180. if( running == true ) { dlgAccountOptions.visible = true }
  181. }
  182. }
  183. },
  184. Transition {
  185. from: "visible"; to: "hidden"
  186. ParallelAnimation {
  187. NumberAnimation { duration: howLong; property: "scale"; easing.type: Easing.InOutQuad }
  188. AnchorAnimation { duration: howLong; easing.type: Easing.InOutQuad }
  189. onRunningChanged: {
  190. if( running == false ) { dlgAccountOptions.visible = false }
  191. }
  192. }
  193. }
  194. ]
  195. }