IpPopup.ui.qml 2.8 KB

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