UrlInput.qml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import QtQuick 2.0
  2. Item {
  3. id: urlInput
  4. property bool urlvisible: true
  5. property double urlwidth: 200
  6. property double posX: 0
  7. property double posY: 0
  8. property color focuscolor: "green"
  9. property color urlcolor: "black"
  10. property color urlBackColor: "silver"
  11. property string url: ""
  12. property double urlFontSize: 14
  13. property bool isValid: false
  14. property int urlRadius: 0
  15. property int urlFocus: 0
  16. signal keyReturnPressed
  17. signal keyUpPressed
  18. signal keyDownPressed
  19. Component.onCompleted: {
  20. }
  21. onUrlFocusChanged: {
  22. }
  23. Rectangle {
  24. x: posX
  25. y: posY
  26. visible: urlInput.urlvisible
  27. width: textInput1.width
  28. height: textInput1.height
  29. radius: urlRadius
  30. color: urlBackColor
  31. }
  32. TextInput {
  33. id: textInput1
  34. x: posX
  35. y: posY
  36. text: url
  37. width: urlwidth
  38. font.pixelSize: urlFontSize
  39. visible: urlInput.urlvisible
  40. focus: (urlInput.urlFocus == 1)?true:false
  41. maximumLength: 128
  42. color: urlcolor
  43. inputMethodHints: Qt.ImhUrlCharactersOnly
  44. Keys.onReleased: {
  45. }
  46. Keys.onPressed: {
  47. if((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
  48. {
  49. url = text;
  50. keyReturnPressed();
  51. }
  52. }
  53. onFocusChanged: {
  54. color = (focus) ? focuscolor : urlcolor;
  55. if(focus) ipFocus = 1;
  56. }
  57. }
  58. }