LoginForm.ui.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import QtQuick 2.12
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. Page {
  5. width: 400
  6. height: 400
  7. title: ""
  8. Connections {
  9. target: _qmlHandler
  10. onLoginSetUsername: {
  11. loginUsernameInput.text = username
  12. }
  13. onLoginSetStatus: {
  14. loginStatusText.text = status
  15. }
  16. onLoginEnableLoginButton: {
  17. loginLoginButton.enabled = true
  18. }
  19. onLoginDisableLoginButton: {
  20. loginLoginButton.enabled = false
  21. }
  22. onLoginSignupCheckSaveCheckbox: {
  23. loginSetDefaultCheckbox.checked = true
  24. }
  25. }
  26. ColumnLayout {
  27. anchors.fill: parent
  28. Text {
  29. Layout.alignment: Qt.AlignCenter
  30. id: loginTitle
  31. color: "#ffffff"
  32. text: qsTr("Login")
  33. horizontalAlignment: Text.AlignHCenter
  34. verticalAlignment: Text.AlignVCenter
  35. font.pixelSize: 20
  36. }
  37. TextField {
  38. Layout.alignment: Qt.AlignCenter
  39. id: loginUsernameInput
  40. selectByMouse: true
  41. focus: true
  42. text: qsTr("")
  43. placeholderText: "Username"
  44. horizontalAlignment: Text.AlignHCenter
  45. // @disable-check M222
  46. Keys.onReturnPressed: loginLoginButton.activate()
  47. // @disable-check M222
  48. Keys.onEnterPressed: loginLoginButton.activate()
  49. onTextEdited: loginLoginButton.enabled = (loginUsernameInput.text != ""
  50. && loginPasswordInput.text != "")
  51. }
  52. TextField {
  53. Layout.alignment: Qt.AlignCenter
  54. id: loginPasswordInput
  55. selectByMouse: true
  56. text: qsTr("")
  57. placeholderText: "Password"
  58. horizontalAlignment: Text.AlignHCenter
  59. // @disable-check M222
  60. Keys.onReturnPressed: loginLoginButton.activate()
  61. // @disable-check M222
  62. Keys.onEnterPressed: loginLoginButton.activate()
  63. echoMode: TextInput.Password
  64. onTextEdited: loginLoginButton.enabled = (loginUsernameInput.text != ""
  65. && loginPasswordInput.text != "")
  66. }
  67. CheckBox {
  68. id: loginSetDefaultCheckbox
  69. Layout.alignment: Qt.AlignCenter
  70. checked: false
  71. text: "Save as default user"
  72. }
  73. Text {
  74. id: loginStatusText
  75. color: "#df3f3f"
  76. text: qsTr("")
  77. wrapMode: Text.WordWrap
  78. Layout.preferredWidth: parent.width
  79. horizontalAlignment: Text.AlignHCenter
  80. verticalAlignment: Text.AlignVCenter
  81. Layout.alignment: Qt.AlignCenter
  82. font.pixelSize: 20
  83. }
  84. Button {
  85. Layout.alignment: Qt.AlignCenter
  86. id: loginLoginButton
  87. text: qsTr("Login")
  88. enabled: false
  89. font.pointSize: 16
  90. // @disable-check M223
  91. onClicked: {
  92. // @disable-check M222
  93. loginLoginButton.activate()
  94. }
  95. // @disable-check M222
  96. function activate() {
  97. // @disable-check M223
  98. if (loginLoginButton.enabled) {
  99. // @disable-check M222
  100. _qmlHandler.onLoginLoginButton(
  101. loginUsernameInput.text,
  102. loginPasswordInput.text,
  103. loginSetDefaultCheckbox.checked)
  104. }
  105. }
  106. }
  107. }
  108. }