demos/declarative/webbrowser/content/Header.qml
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 import Qt 4.7
    42 import Qt 4.7
    43 
    43 
    44 Image {
    44 Image {
       
    45     id: header
       
    46 
    45     property alias editUrl: urlInput.url
    47     property alias editUrl: urlInput.url
       
    48     property bool urlChanged: false
    46 
    49 
    47     source: "pics/titlebar-bg.png"; fillMode: Image.TileHorizontally
    50     source: "pics/titlebar-bg.png"; fillMode: Image.TileHorizontally
    48 
    51 
    49     x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width
    52     x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width
    50        ? -webView.contentX+webView.contentWidth-webView.width : 0
    53        ? -webView.contentX+webView.contentWidth-webView.width : 0
    89                 anchors { left: nextButton.right; right: reloadButton.left }
    92                 anchors { left: nextButton.right; right: reloadButton.left }
    90                 image: "pics/display.png"
    93                 image: "pics/display.png"
    91                 onUrlEntered: {
    94                 onUrlEntered: {
    92                     webBrowser.urlString = url
    95                     webBrowser.urlString = url
    93                     webBrowser.focus = true
    96                     webBrowser.focus = true
       
    97                     header.urlChanged = false
    94                 }
    98                 }
       
    99                 onUrlChanged: header.urlChanged = true
    95             }
   100             }
    96 
   101 
    97             Button {
   102             Button {
    98                 id: reloadButton
   103                 id: reloadButton
    99                 anchors { right: parent.right; rightMargin: 4 }
   104                 anchors { right: parent.right; rightMargin: 4 }
   100                 action: webView.reload; image: "pics/view-refresh.png"; visible: webView.progress == 1.0
   105                 action: webView.reload; image: "pics/view-refresh.png"
       
   106                 visible: webView.progress == 1.0 && !header.urlChanged
   101             }
   107             }
   102 
   108 
   103             Button {
   109             Button {
   104                 id: stopButton
   110                 id: stopButton
   105                 anchors { right: parent.right; rightMargin: 4 }
   111                 anchors { right: parent.right; rightMargin: 4 }
   106                 action: webView.stop; image: "pics/edit-delete.png"; visible: webView.progress < 1.0
   112                 action: webView.stop; image: "pics/edit-delete.png"
       
   113                 visible: webView.progress < 1.0 && !header.urlChanged
       
   114             }
       
   115 
       
   116             Button {
       
   117                 id: goButton
       
   118                 anchors { right: parent.right; rightMargin: 4 }
       
   119                 onClicked: {
       
   120                     webBrowser.urlString = urlInput.url
       
   121                     webBrowser.focus = true
       
   122                     header.urlChanged = false
       
   123                 }
       
   124                 image: "pics/go-jump-locationbar.png"; visible: header.urlChanged
   107             }
   125             }
   108         }
   126         }
   109     }
   127     }
   110 }
   128 }