LoginForm.ui.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. onLoginSetStatus: {
  10. loginStatusText.text = status
  11. }
  12. }
  13. ColumnLayout {
  14. anchors.fill: parent
  15. Text {
  16. Layout.alignment: Qt.AlignCenter
  17. id: loginTitle
  18. color: "#ffffff"
  19. text: qsTr("Login")
  20. horizontalAlignment: Text.AlignHCenter
  21. verticalAlignment: Text.AlignVCenter
  22. font.pixelSize: 20
  23. }
  24. TextField {
  25. Layout.alignment: Qt.AlignCenter
  26. id: loginUsernameInput
  27. selectByMouse: true
  28. focus: true
  29. text: qsTr("")
  30. placeholderText: "Username"
  31. horizontalAlignment: Text.AlignHCenter
  32. // @disable-check M222
  33. Keys.onReturnPressed: loginLoginButton.activate()
  34. // @disable-check M222
  35. Keys.onEnterPressed: loginLoginButton.activate()
  36. }
  37. TextField {
  38. Layout.alignment: Qt.AlignCenter
  39. id: loginPasswordInput
  40. selectByMouse: true
  41. text: qsTr("")
  42. placeholderText: "Password"
  43. horizontalAlignment: Text.AlignHCenter
  44. // @disable-check M222
  45. Keys.onReturnPressed: loginLoginButton.activate()
  46. // @disable-check M222
  47. Keys.onEnterPressed: loginLoginButton.activate()
  48. echoMode: TextInput.Password
  49. }
  50. Text {
  51. id: loginStatusText
  52. color: "#df3f3f"
  53. text: qsTr("")
  54. horizontalAlignment: Text.AlignHCenter
  55. verticalAlignment: Text.AlignVCenter
  56. Layout.alignment: Qt.AlignCenter
  57. font.pixelSize: 20
  58. }
  59. Button {
  60. Layout.alignment: Qt.AlignCenter
  61. id: loginLoginButton
  62. text: qsTr("Login")
  63. enabled: (loginUsernameInput.text != ""
  64. && loginPasswordInput.text != "")
  65. font.pointSize: 16
  66. // @disable-check M223
  67. onClicked: {
  68. // @disable-check M222
  69. loginLoginButton.activate()
  70. }
  71. // @disable-check M222
  72. function activate() {
  73. // @disable-check M223
  74. if (loginLoginButton.enabled) {
  75. // @disable-check M222
  76. _qmlHandler.onLoginLoginButton(loginUsernameInput.text, loginPasswordInput.text)
  77. }
  78. }
  79. }
  80. }
  81. }