IpPopup.ui.qml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import QtQuick 2.4
  2. import QtQuick.Controls 2.3
  3. import QtQuick.Layouts 1.3
  4. Popup {
  5. id: popup
  6. height: 250
  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. onIpPopupSetIP: {
  17. ipPopupIpInput.text = default_ip
  18. ipPopupConnectButton.enabled = ipPopupIpInput.acceptableInput
  19. }
  20. onIpPopupClose: {
  21. popup.close()
  22. }
  23. onIpPopupOpen: {
  24. popup.open()
  25. }
  26. onIpPopupSetStatus: {
  27. ipPopupStatusText.text = status
  28. }
  29. onIpPopupEnableConnectButton: {
  30. ipPopupConnectButton.enabled = true
  31. }
  32. onIpPopupDisableConnectButton: {
  33. ipPopupConnectButton.enabled = false
  34. }
  35. onIpPopupCheckSaveCheckbox: {
  36. ipPopupSetDefaultCheckbox.checked = true
  37. }
  38. }
  39. ColumnLayout {
  40. anchors.fill: parent
  41. Text {
  42. Layout.alignment: Qt.AlignCenter
  43. id: ipPopupText
  44. color: "#ffffff"
  45. text: qsTr("Enter the IP to connect:")
  46. horizontalAlignment: Text.AlignHCenter
  47. verticalAlignment: Text.AlignVCenter
  48. font.pixelSize: 20
  49. }
  50. TextField {
  51. Layout.alignment: Qt.AlignCenter
  52. id: ipPopupIpInput
  53. selectByMouse: true
  54. focus: true
  55. text: qsTr("")
  56. placeholderText: "IP-Address"
  57. horizontalAlignment: Text.AlignHCenter
  58. validator: RegExpValidator {
  59. 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]))$/
  60. }
  61. // @disable-check M222
  62. Keys.onReturnPressed: ipPopupConnectButton.activate()
  63. // @disable-check M222
  64. Keys.onEnterPressed: ipPopupConnectButton.activate()
  65. onTextEdited: ipPopupConnectButton.enabled = ipPopupIpInput.acceptableInput
  66. }
  67. CheckBox {
  68. id: ipPopupSetDefaultCheckbox
  69. Layout.alignment: Qt.AlignCenter
  70. checked: false
  71. text: "Save as default IP"
  72. }
  73. Text {
  74. id: ipPopupStatusText
  75. color: "#df3f3f"
  76. text: qsTr("")
  77. horizontalAlignment: Text.AlignHCenter
  78. verticalAlignment: Text.AlignVCenter
  79. Layout.alignment: Qt.AlignCenter
  80. font.pixelSize: 20
  81. wrapMode: Text.WordWrap
  82. Layout.preferredWidth: parent.width
  83. }
  84. Button {
  85. Layout.alignment: Qt.AlignCenter
  86. id: ipPopupConnectButton
  87. text: qsTr("Connect")
  88. rightPadding: 8
  89. padding: 12
  90. enabled: false
  91. font.pointSize: 16
  92. // @disable-check M223
  93. onClicked: {
  94. // @disable-check M222
  95. ipPopupConnectButton.activate()
  96. }
  97. // @disable-check M222
  98. function activate() {
  99. // @disable-check M223
  100. if (ipPopupConnectButton.enabled) {
  101. // @disable-check M222
  102. _qmlHandler.onIpPopupConnectButton(
  103. ipPopupIpInput.text,
  104. ipPopupSetDefaultCheckbox.checked)
  105. }
  106. }
  107. }
  108. }
  109. }