Advertisement
Guest User

Untitled

a guest
May 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. import QtQuick 2.5
  2. import QtQuick.Controls 1.4
  3. import QtQuick.Controls.Styles 1.4
  4. import QtQml.Models 2.1
  5. import QtQuick.Window 2.1
  6.  
  7. Window {
  8. id: root
  9. visible: true
  10. width: 800
  11. height: 600
  12.  
  13. ListView {
  14. id: view
  15. // width: 640
  16. // height: 480
  17. anchors.fill: parent
  18. snapMode: ListView.SnapOneItem
  19. highlightRangeMode: ListView.ApplyRange
  20. highlightMoveDuration: 250
  21. focus: false
  22. orientation: ListView.Horizontal
  23. boundsBehavior: Flickable.StopAtBounds
  24. // interactive: false
  25.  
  26. Item {
  27. id: settings
  28. property int fontSize: 24
  29. property int padding: 10
  30. }
  31.  
  32. model: ObjectModel {
  33. Rectangle {
  34. // anchors.fill: view
  35. width: view.width
  36. height: view.height
  37. color: "#fde9b2"
  38.  
  39. TextField {
  40. id: ip
  41. anchors.centerIn: parent
  42. width: 300
  43. font.pointSize: settings.fontSize
  44. placeholderText: "127.0.0.1"
  45.  
  46. validator: RegExpValidator { regExp: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ }
  47.  
  48. onAcceptableInputChanged: {
  49. if(acceptableInput) {
  50. connect.visible = true
  51. } else {
  52. connect.visible = false
  53. }
  54. }
  55.  
  56. Label {
  57. text: "Server IP:"
  58. anchors.right: parent.left
  59. anchors.verticalCenter: parent.verticalCenter
  60. anchors.rightMargin: settings.padding
  61. font: parent.font
  62. }
  63. }
  64.  
  65. TextField {
  66. id: login
  67. anchors.top: ip.bottom
  68. anchors.left: ip.left
  69. anchors.right: ip.right
  70. anchors.topMargin: settings.padding
  71. placeholderText: "You login"
  72. font: ip.font
  73. Label {
  74. text: "Login:"
  75. anchors.right: parent.left
  76. anchors.rightMargin: settings.padding
  77. anchors.verticalCenter: parent.verticalCenter
  78. font: parent.font
  79. }
  80.  
  81. }
  82.  
  83. Button {
  84. id: connect
  85. text: "Connect"
  86. visible: false
  87. anchors.top: login.bottom
  88. anchors.horizontalCenter: parent.horizontalCenter
  89. anchors.topMargin: settings.padding
  90. style: ButtonStyle {
  91. label: Text {
  92. renderType: Text.NativeRendering
  93. verticalAlignment: Text.AlignVCenter
  94. horizontalAlignment: Text.AlignHCenter
  95. font: ip.font
  96. text: control.text
  97. }
  98. }
  99. onClicked: {
  100. console.log(ip.text);
  101. view.currentIndex = 1
  102. view.update()
  103. }
  104. }
  105. }
  106.  
  107. Rectangle {
  108. width: view.width
  109. height: view.height
  110. color: "#ddfdb3"
  111.  
  112. TextField {
  113. id: message
  114. anchors.bottom: parent.bottom
  115. anchors.left: parent.left
  116. anchors.right: send.right
  117. }
  118.  
  119. Button {
  120. id: send
  121. width: 100
  122. anchors.bottom: parent.bottom
  123. anchors.right: parent.right
  124. text: "Send"
  125. onClicked: view.currentIndex = 0
  126. }
  127.  
  128. Rectangle {
  129. width: 200
  130. anchors.top: parent.top
  131. anchors.right: parent.right
  132. anchors.bottom: send.top
  133. color: "#ffffff"
  134. }
  135. }
  136.  
  137.  
  138. }
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement