Skip to content

Instantly share code, notes, and snippets.

@Adenilson
Created January 24, 2013 14:26
Show Gist options
  • Save Adenilson/4622252 to your computer and use it in GitHub Desktop.
Save Adenilson/4622252 to your computer and use it in GitHub Desktop.
WK notifications test
import QtQuick 2.0
import QtWebKit 3.0
import QtWebKit.experimental 1.0
Item {
id: root
width: 800; height: 600
property bool loading: false
property bool active: false
property string url;
property string title;
WebView {
id: webview
anchors.fill: parent
visible: true
onLoadingChanged: {
switch (loadRequest.status) {
case WebView.LoadStartedStatus: {
root.loading = true;
// Required to have input focus inside of webview
// if (!focus)
// forceActiveFocus();
break;
}
case WebView.LoadFailedStatus : {
root.loading = false;
if (loadRequest.errorDomain == WebView.NetworkErrorDomain && loadRequest.errorCode == NetworkReply.OperationCanceledError)
return;
console.log("### Failed to load...")
break;
}
case WebView.LoadSucceededStatus :
root.loading = false;
console.log("### Loaded successfully...")
break;
}
}
onUrlChanged: {
root.url = webview.url
console.log("##### The loaded url is: " + root.url)
}
onTitleChanged: {
root.title = title
console.log("##### webpage title is: " + root.title)
}
onNavigationRequested: {
if (request.mouseButton == Qt.MiddleButton &&
request.keyboardModifiers & Qt.ControlModifier) {
webview.url = request.url
//request.action = WebView.IgnoreRequest
}
}
experimental.onPermissionRequested: {
console.log("####### snowshoe: " + permission.type)
permission.allow = true
}
}
Component.onCompleted: webview.url = Qt.resolvedUrl("http://sandbox.gtaero.net/chrome/notifications.php")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment