LoginForm.ui.qml 3.5 KB

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