diff options
| author | Javier <dev.git@javispedro.com> | 2014-12-01 04:13:06 +0100 |
|---|---|---|
| committer | Javier <dev.git@javispedro.com> | 2014-12-01 04:13:06 +0100 |
| commit | 81f91639969de0f3852a3fe73db13b4cb0ecf3b4 (patch) | |
| tree | ac5f3146707e0b46723bfdf13b7ced5cdf16633d /app/qml | |
| parent | be139d8ff95160782b424134a025b30c82083e28 (diff) | |
hackily implement openURL by signalling the URLs via D-Bus to the
settings app, which pops a webview
Diffstat (limited to 'app/qml')
| -rw-r--r-- | app/qml/pages/WebViewPage.qml | 29 | ||||
| -rw-r--r-- | app/qml/pebble.qml | 5 |
2 files changed, 34 insertions, 0 deletions
diff --git a/app/qml/pages/WebViewPage.qml b/app/qml/pages/WebViewPage.qml new file mode 100644 index 0000000..2c6fcf0 --- /dev/null +++ b/app/qml/pages/WebViewPage.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 +import QtQml 2.1 +import QtWebKit 3.0 +import Sailfish.Silica 1.0 + +Page { + id: webviewPage + + property alias url: webview.url + + SilicaWebView { + id: webview + anchors.fill: parent + + onNavigationRequested: { + console.log("navigation requested to " + request.url); + var url = request.url.toString() + if (/^pebblejs:\/\/close/.exec(url)) { + var data = decodeURI(url.substring(17)); + console.log("match with pebble close regexp. data: " + data); + pebbled.webviewClosed(data); + pageStack.pop(); + request.action = WebView.IgnoreRequest; + } else { + request.action = WebView.AcceptRequest; + } + } + } +} diff --git a/app/qml/pebble.qml b/app/qml/pebble.qml index da3bfb5..2ff0839 100644 --- a/app/qml/pebble.qml +++ b/app/qml/pebble.qml @@ -41,5 +41,10 @@ ApplicationWindow PebbledInterface { id: pebbled + + onOpenUrl: { + console.log("got open url: " + url); + pageStack.push(Qt.resolvedUrl("pages/WebViewPage.qml"), {url: url}); + } } } |
