SwitchIpPopupForm.ui.qml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import QtQuick 2.4
  2. import QtQuick.Controls 2.3
  3. import QtQuick.Layouts 1.3
  4. Popup {
  5. id: popup
  6. height: 200
  7. dim: true
  8. clip: false
  9. width: 400
  10. modal: true
  11. focus: true
  12. closePolicy: Popup.NoAutoClose
  13. ColumnLayout {
  14. anchors.fill: parent
  15. Text {
  16. Layout.alignment: Qt.AlignCenter
  17. id: switchText
  18. color: "#ffffff"
  19. text: qsTr("Enter the IP to connect:")
  20. horizontalAlignment: Text.AlignHCenter
  21. verticalAlignment: Text.AlignVCenter
  22. font.pixelSize: 20
  23. }
  24. TextField {
  25. Layout.alignment: Qt.AlignCenter
  26. id: switchIpInput
  27. selectByMouse: true
  28. text: qsTr("")
  29. placeholderText: "Enter IP"
  30. horizontalAlignment: Text.AlignHCenter
  31. validator: RegExpValidator {
  32. regExp: /^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$/
  33. }
  34. // @disable-check M222
  35. Keys.onReturnPressed: switchConnectButton.activate()
  36. // @disable-check M222
  37. Keys.onEnterPressed: switchConnectButton.activate()
  38. }
  39. Text {
  40. id: switchStatusText
  41. color: "#df3f3f"
  42. text: qsTr("")
  43. horizontalAlignment: Text.AlignHCenter
  44. verticalAlignment: Text.AlignVCenter
  45. Layout.alignment: Qt.AlignCenter
  46. font.pixelSize: 20
  47. }
  48. RowLayout {
  49. Layout.alignment: Qt.AlignCenter
  50. Button {
  51. Layout.alignment: Qt.AlignLeft
  52. id: switchConnectButton
  53. text: qsTr("Connect")
  54. rightPadding: 8
  55. padding: 12
  56. enabled: switchIpInput.acceptableInput
  57. font.pointSize: 16
  58. // @disable-check M223
  59. onClicked: {
  60. // @disable-check M222
  61. switchConnectButton.activate()
  62. }
  63. // @disable-check M222
  64. function activate() {
  65. // @disable-check M223
  66. if (switchIpInput.acceptableInput) {
  67. // @disable-check M222
  68. _qmlHandler.onSwitchPopupEnterIp(switchIpInput.text)
  69. // @disable-check M222
  70. popup.close()
  71. }
  72. }
  73. }
  74. Button {
  75. Layout.alignment: Qt.AlignRight
  76. id: switchCancelButton
  77. text: qsTr("Cancel")
  78. font.pointSize: 16
  79. // @disable-check M223
  80. onClicked: {
  81. // @disable-check M222
  82. popup.close()
  83. }
  84. }
  85. }
  86. }
  87. }