diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2010-06-10 04:29:21 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2010-06-10 04:29:21 (GMT) |
commit | 2115bbae2387335f8ea29e0ffee70e00d4a15dc1 (patch) | |
tree | 026bb4b5fba958ae0c7989cab21d2e482ddc9ac1 /demos | |
parent | fa9c32829025121ab203565dd86a1c55028f40aa (diff) | |
download | Qt-2115bbae2387335f8ea29e0ffee70e00d4a15dc1.zip Qt-2115bbae2387335f8ea29e0ffee70e00d4a15dc1.tar.gz Qt-2115bbae2387335f8ea29e0ffee70e00d4a15dc1.tar.bz2 |
Add go button to webbrowser example.
Task-number: QTBUG-11310
Diffstat (limited to 'demos')
-rw-r--r-- | demos/declarative/webbrowser/content/Button.qml | 10 | ||||
-rw-r--r-- | demos/declarative/webbrowser/content/Header.qml | 22 | ||||
-rw-r--r-- | demos/declarative/webbrowser/content/UrlInput.qml | 7 | ||||
-rw-r--r-- | demos/declarative/webbrowser/content/pics/go-jump-locationbar.png | bin | 0 -> 714 bytes | |||
-rw-r--r-- | demos/declarative/webbrowser/webbrowser.qml | 1 |
5 files changed, 36 insertions, 4 deletions
diff --git a/demos/declarative/webbrowser/content/Button.qml b/demos/declarative/webbrowser/content/Button.qml index 4642cc7..2a2e7ef 100644 --- a/demos/declarative/webbrowser/content/Button.qml +++ b/demos/declarative/webbrowser/content/Button.qml @@ -45,15 +45,21 @@ Item { property alias image: icon.source property variant action + signal clicked + width: 40; height: parent.height Image { id: icon; anchors.centerIn: parent - opacity: if(action != undefined) {action.enabled ? 1.0 : 0.4} else 0 + opacity: if (action != undefined) { action.enabled ? 1.0 : 0.4 } else 1 } MouseArea { anchors { fill: parent; topMargin: -10; bottomMargin: -10 } - onClicked: action.trigger() + onClicked: { + if (action != undefined) + action.trigger() + parent.clicked() + } } } diff --git a/demos/declarative/webbrowser/content/Header.qml b/demos/declarative/webbrowser/content/Header.qml index 2c9d0fb..5abf440 100644 --- a/demos/declarative/webbrowser/content/Header.qml +++ b/demos/declarative/webbrowser/content/Header.qml @@ -42,7 +42,10 @@ import Qt 4.7 Image { + id: header + property alias editUrl: urlInput.url + property bool urlChanged: false source: "pics/titlebar-bg.png"; fillMode: Image.TileHorizontally @@ -91,19 +94,34 @@ Image { onUrlEntered: { webBrowser.urlString = url webBrowser.focus = true + header.urlChanged = false } + onUrlChanged: header.urlChanged = true } Button { id: reloadButton anchors { right: parent.right; rightMargin: 4 } - action: webView.reload; image: "pics/view-refresh.png"; visible: webView.progress == 1.0 + action: webView.reload; image: "pics/view-refresh.png" + visible: webView.progress == 1.0 && !header.urlChanged } Button { id: stopButton anchors { right: parent.right; rightMargin: 4 } - action: webView.stop; image: "pics/edit-delete.png"; visible: webView.progress < 1.0 + action: webView.stop; image: "pics/edit-delete.png" + visible: webView.progress < 1.0 && !header.urlChanged + } + + Button { + id: goButton + anchors { right: parent.right; rightMargin: 4 } + onClicked: { + webBrowser.urlString = urlInput.url + webBrowser.focus = true + header.urlChanged = false + } + image: "pics/go-jump-locationbar.png"; visible: header.urlChanged } } } diff --git a/demos/declarative/webbrowser/content/UrlInput.qml b/demos/declarative/webbrowser/content/UrlInput.qml index b57fae6..9992456 100644 --- a/demos/declarative/webbrowser/content/UrlInput.qml +++ b/demos/declarative/webbrowser/content/UrlInput.qml @@ -48,6 +48,7 @@ Item { property alias url: urlText.text signal urlEntered(string url) + signal urlChanged width: parent.height; height: parent.height @@ -69,18 +70,24 @@ Item { id: urlText horizontalAlignment: TextEdit.AlignLeft font.pixelSize: 14; focusOnPress: true + + onTextChanged: container.urlChanged() + Keys.onEscapePressed: { urlText.text = webView.url webView.focus = true } + Keys.onEnterPressed: { container.urlEntered(urlText.text) webView.focus = true } + Keys.onReturnPressed: { container.urlEntered(urlText.text) webView.focus = true } + anchors { left: parent.left; right: parent.right; leftMargin: 18; rightMargin: 18 verticalCenter: parent.verticalCenter diff --git a/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png b/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png Binary files differnew file mode 100644 index 0000000..636fe38 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index a923c92..53ba6da 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -55,6 +55,7 @@ Rectangle { FlickableWebView { id: webView url: webBrowser.urlString + onProgressChanged: header.urlChanged = false anchors { top: headerSpace.bottom; left: parent.left; right: parent.right; bottom: parent.bottom } } |