demos/declarative/webbrowser/content/Header.qml
changeset 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 import Qt 4.7
       
    43 
       
    44 Image {
       
    45     property alias editUrl: urlInput.url
       
    46 
       
    47     source: "pics/titlebar-bg.png"; fillMode: Image.TileHorizontally
       
    48 
       
    49     x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width
       
    50        ? -webView.contentX+webView.contentWidth-webView.width : 0
       
    51 
       
    52     y: {
       
    53         if (webView.progress < 1.0)
       
    54             return 0;
       
    55         else {
       
    56             webView.contentY < 0 ? -webView.contentY : webView.contentY > height ? -height : -webView.contentY
       
    57         }
       
    58     }
       
    59 
       
    60     Column {
       
    61         width: parent.width
       
    62 
       
    63         Item {
       
    64             width: parent.width; height: 20
       
    65             Text {
       
    66                 anchors.centerIn: parent
       
    67                 text: webView.title; font.pixelSize: 14; font.bold: true
       
    68                 color: "white"; styleColor: "black"; style: Text.Sunken
       
    69             }
       
    70         }
       
    71 
       
    72         Item {
       
    73             width: parent.width; height: 40
       
    74 
       
    75             Button {
       
    76                 id: backButton
       
    77                 action: webView.back; image: "pics/go-previous-view.png"
       
    78                 anchors { left: parent.left; bottom: parent.bottom }
       
    79             }
       
    80 
       
    81             Button {
       
    82                 id: nextButton
       
    83                 anchors.left: backButton.right
       
    84                 action: webView.forward; image: "pics/go-next-view.png"
       
    85             }
       
    86 
       
    87             UrlInput {
       
    88                 id: urlInput
       
    89                 anchors { left: nextButton.right; right: reloadButton.left }
       
    90                 image: "pics/display.png"
       
    91                 onUrlEntered: {
       
    92                     webBrowser.urlString = url
       
    93                     webBrowser.focus = true
       
    94                 }
       
    95             }
       
    96 
       
    97             Button {
       
    98                 id: reloadButton
       
    99                 anchors { right: parent.right; rightMargin: 4 }
       
   100                 action: webView.reload; image: "pics/view-refresh.png"; visible: webView.progress == 1.0
       
   101             }
       
   102 
       
   103             Button {
       
   104                 id: stopButton
       
   105                 anchors { right: parent.right; rightMargin: 4 }
       
   106                 action: webView.stop; image: "pics/edit-delete.png"; visible: webView.progress < 1.0
       
   107             }
       
   108         }
       
   109     }
       
   110 }