IpPopup.ui.qml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. anchors.centerIn: Overlay.overlay
  14. Connections {
  15. target: _qmlHandler
  16. onIpPopupClose: {
  17. popup.close()
  18. }
  19. onIpPopupOpen: {
  20. popup.open();
  21. }
  22. onIpPopupSetStatus: {
  23. ipPopupStatusText.text = status
  24. }
  25. onIpPopupEnableConnectButton: {
  26. ipPopupConnectButton.enabled = true
  27. }
  28. onIpPopupDisableConnectButton: {
  29. ipPopupConnectButton.enabled = false
  30. }
  31. }
  32. ColumnLayout {
  33. anchors.fill: parent
  34. Text {
  35. Layout.alignment: Qt.AlignCenter
  36. id: ipPopupText
  37. color: "#ffffff"
  38. text: qsTr("Enter the IP to connect:")
  39. horizontalAlignment: Text.AlignHCenter
  40. verticalAlignment: Text.AlignVCenter
  41. font.pixelSize: 20
  42. }
  43. TextField {
  44. Layout.alignment: Qt.AlignCenter
  45. id: ipPopupIpInput
  46. selectByMouse: true
  47. focus: true
  48. text: qsTr("")
  49. placeholderText: "IP-Address"
  50. horizontalAlignment: Text.AlignHCenter
  51. validator: RegExpValidator {
  52. 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]))$/
  53. }
  54. // @disable-check M222
  55. Keys.onReturnPressed: ipPopupConnectButton.activate()
  56. // @disable-check M222
  57. Keys.onEnterPressed: ipPopupConnectButton.activate()
  58. onTextEdited: ipPopupConnectButton.enabled = ipPopupIpInput.acceptableInput
  59. }
  60. Text {
  61. id: ipPopupStatusText
  62. color: "#df3f3f"
  63. text: qsTr("")
  64. horizontalAlignment: Text.AlignHCenter
  65. verticalAlignment: Text.AlignVCenter
  66. Layout.alignment: Qt.AlignCenter
  67. font.pixelSize: 20
  68. }
  69. Button {
  70. Layout.alignment: Qt.AlignCenter
  71. id: ipPopupConnectButton
  72. text: qsTr("Connect")
  73. rightPadding: 8
  74. padding: 12
  75. enabled: false
  76. font.pointSize: 16
  77. // @disable-check M223
  78. onClicked: {
  79. // @disable-check M222
  80. ipPopupConnectButton.activate()
  81. }
  82. // @disable-check M222
  83. function activate() {
  84. // @disable-check M223
  85. if (ipPopupConnectButton.enabled) {
  86. // @disable-check M222
  87. _qmlHandler.onIpPopupConnectButton(ipPopupIpInput.text)
  88. }
  89. }
  90. }
  91. }
  92. }