webcontent.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import Qt 4.7
  5. import QtWebKit 1.0
  6. Item {
  7. id: container
  8. function initialize() {}
  9. anchors.fill: parent
  10. SystemPalette { id: activePalette }
  11. Rectangle {
  12. id: topbar
  13. z: 10
  14. width: parent.width; height: 60
  15. anchors.top: parent.top
  16. color: activePalette.window
  17. gradient: Gradient {
  18. GradientStop { position: 0.0; color: "lightgray" }
  19. GradientStop { position: 1.0; color: "gray" }
  20. }
  21. Rectangle {
  22. id: textEdit
  23. anchors { left: parent.left; leftMargin: 10; right: goButton.left; rightMargin: 10; verticalCenter: parent.verticalCenter }
  24. height: 34
  25. color: "white"
  26. radius: 2
  27. TextInput {
  28. id: editUrl
  29. text: view.url
  30. anchors { left: parent.left; margins: 10; verticalCenter: parent.verticalCenter; right: parent.right }
  31. color: "black"
  32. font.pixelSize: parent.height - 13
  33. }
  34. }
  35. Rectangle {
  36. id: goButton
  37. width: 60; height: textEdit.height
  38. anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 }
  39. border { width: 2; color: activePalette.dark }
  40. color: activePalette.button
  41. radius: 4
  42. gradient: Gradient {
  43. GradientStop { position: 0.0; color: "lightgray" }
  44. GradientStop { position: 1.0; color: "gray" }
  45. }
  46. Text {
  47. font { pixelSize: 12; bold: true }
  48. text: "Go"
  49. color: activePalette.buttonText
  50. anchors.centerIn: parent
  51. }
  52. MouseArea {
  53. anchors.fill: parent
  54. onClicked: {
  55. view.url = editUrl.text
  56. pressAnimation.start()
  57. editUrl.closeSoftwareInputPanel()
  58. }
  59. }
  60. SequentialAnimation {
  61. id: pressAnimation
  62. PropertyAnimation { target: goButton; properties: "scale"; to: 0.9; duration: 100 }
  63. PropertyAnimation { target: goButton; properties: "scale"; to: 1.0; duration: 100 }
  64. }
  65. }
  66. }
  67. Flickable {
  68. anchors { left: parent.left; right: parent.right; top: topbar.bottom; bottom: parent.bottom }
  69. contentWidth: view.width
  70. contentHeight: view.height
  71. WebView {
  72. id: view
  73. url: "http://maemo.org/"
  74. onLoadStarted: { progressIndicator.opacity = 0.7 }
  75. onLoadFinished: { progressIndicator.opacity = 0 }
  76. onLoadFailed: { progressIndicator.opacity = 0 }
  77. }
  78. }
  79. Rectangle {
  80. id: progressIndicator
  81. property real progress: view.progress
  82. anchors.bottom: parent.bottom; anchors.bottomMargin: 20
  83. anchors.horizontalCenter: parent.horizontalCenter
  84. width: parent.width - 20; height: 40
  85. color: "white"
  86. Behavior on opacity { NumberAnimation { duration: 700; easing.type: "InOutCubic" } }
  87. opacity: 0
  88. Rectangle {
  89. x: 4
  90. anchors.verticalCenter: parent.verticalCenter
  91. height: parent.height - 8
  92. Behavior on width { NumberAnimation { duration: 200 } }
  93. width: progressIndicator.progress * progressIndicator.width - 8
  94. color: "black"
  95. radius: 3
  96. }
  97. Text {
  98. anchors.centerIn: parent
  99. text: parseInt(progressIndicator.progress * 100) + ' %'
  100. font.bold: true
  101. font.pixelSize: parent.height / 2
  102. style: Text.Raised
  103. color: "#DDDDDD"
  104. }
  105. }
  106. }