mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
Add QML portions of userAgent handling. (FML)
This commit is contained in:
parent
f8119daa47
commit
dac9c49175
4 changed files with 37 additions and 18 deletions
|
@ -19,16 +19,17 @@ Item {
|
|||
property string url: ""
|
||||
property string scriptUrl: null
|
||||
property bool useBackground: true
|
||||
property string userAgent: ""
|
||||
|
||||
onUrlChanged: {
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||
}
|
||||
|
||||
onScriptUrlChanged: {
|
||||
if (root.item) {
|
||||
root.item.scriptUrl = root.scriptUrl;
|
||||
} else {
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,14 +37,22 @@ Item {
|
|||
if (root.item) {
|
||||
root.item.useBackground = root.useBackground;
|
||||
} else {
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||
}
|
||||
}
|
||||
|
||||
onUserAgentChanged: {
|
||||
if (root.item) {
|
||||
root.item.userAgent = root.userAgent;
|
||||
} else {
|
||||
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||
}
|
||||
}
|
||||
|
||||
property var item: null
|
||||
|
||||
function load(url, scriptUrl, useBackground) {
|
||||
// Ensure we reset any existing item to "about:blank" to ensure web audio stops: DEV-2375
|
||||
function load(url, scriptUrl, useBackground, userAgent) {
|
||||
// Ensure we reset any existing item toB "about:blank" to ensure web audio stops: DEV-2375
|
||||
if (root.item != null) {
|
||||
root.item.url = "about:blank"
|
||||
root.item.destroy()
|
||||
|
@ -54,11 +63,12 @@ Item {
|
|||
root.item.url = url
|
||||
root.item.scriptUrl = scriptUrl
|
||||
root.item.useBackground = useBackground
|
||||
root.item.userAgent = userAgent
|
||||
})
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||
}
|
||||
|
||||
signal sendToScript(var message);
|
||||
|
|
|
@ -13,10 +13,11 @@ Item {
|
|||
property alias url: webViewCore.url
|
||||
property alias canGoBack: webViewCore.canGoBack
|
||||
property alias webViewCore: webViewCore
|
||||
property alias webViewCoreProfile: webViewCore.profile
|
||||
// property alias webViewCoreProfile: webViewCore.profile
|
||||
property string webViewCoreUserAgent
|
||||
|
||||
property bool useBackground: webViewCore.useBackground
|
||||
property string userAgent: webViewCore.profile.httpUserAgent
|
||||
property string userScriptUrl: ""
|
||||
property string urlTag: "noDownload=false";
|
||||
|
||||
|
@ -34,6 +35,10 @@ Item {
|
|||
permissionPopupBackground.visible = false;
|
||||
}
|
||||
|
||||
onUserAgentChanged: {
|
||||
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||
}
|
||||
|
||||
StylesUIt.HifiConstants {
|
||||
id: hifi
|
||||
}
|
||||
|
@ -74,7 +79,7 @@ Item {
|
|||
|
||||
function onLoadingChanged(loadRequest) {
|
||||
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
||||
|
||||
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||
// Required to support clicking on "hifi://" links
|
||||
var url = loadRequest.url.toString();
|
||||
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||
|
@ -101,7 +106,6 @@ Item {
|
|||
height: parent.height
|
||||
backgroundColor: (flick.useBackground) ? "white" : "transparent"
|
||||
|
||||
profile: HFWebEngineProfile;
|
||||
settings.pluginsEnabled: true
|
||||
settings.touchIconsEnabled: true
|
||||
settings.allowRunningInsecureContent: true
|
||||
|
@ -136,8 +140,10 @@ Item {
|
|||
webChannel.registerObject("eventBridge", eventBridge);
|
||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||
|
||||
if (webViewCoreUserAgent !== undefined) {
|
||||
webViewCore.profile.httpUserAgent = webViewCoreUserAgent
|
||||
if (flick.userAgent !== undefined) {
|
||||
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||
webViewCore.profile.offTheRecord = false;
|
||||
webViewCore.profile.storageName = "qmlWebEngine";
|
||||
} else {
|
||||
webViewCore.profile.httpUserAgent += " (VircadiaInterface)";
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ Item {
|
|||
property alias url: webViewCore.url
|
||||
property alias canGoBack: webViewCore.canGoBack
|
||||
property alias webViewCore: webViewCore
|
||||
property alias webViewCoreProfile: webViewCore.profile
|
||||
property string webViewCoreUserAgent
|
||||
// property alias webViewCoreProfile: webViewCore.profile
|
||||
|
||||
property bool useBackground: webViewCore.useBackground
|
||||
property alias useBackground: webViewCore.useBackground
|
||||
property alias userAgent: webViewCore.userAgent
|
||||
property string userScriptUrl: ""
|
||||
property string urlTag: "noDownload=false";
|
||||
property string urlTag: "noDownload=false"
|
||||
|
||||
signal newViewRequestedCallback(var request)
|
||||
signal loadingChangedCallback(var loadRequest)
|
||||
|
@ -43,10 +43,12 @@ Item {
|
|||
}
|
||||
|
||||
function onLoadingChanged(loadRequest) {
|
||||
webViewCore.profile.httpUserAgent: "LOLICON"
|
||||
}
|
||||
|
||||
ControlsUit.ProxyWebView {
|
||||
id: webViewCore
|
||||
id:
|
||||
profile: WebEngineProfile { httpUserAgent: "TEST2"}
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ Item {
|
|||
property alias flickable: webroot.interactive
|
||||
property alias blurOnCtrlShift: webroot.blurOnCtrlShift
|
||||
property alias useBackground: webroot.useBackground
|
||||
property alias userAgent: webroot.userAgent
|
||||
|
||||
function stop() {
|
||||
webroot.stop();
|
||||
|
@ -37,13 +38,13 @@ Item {
|
|||
}
|
||||
*/
|
||||
|
||||
property alias viewProfile: webroot.webViewCoreProfile
|
||||
// property alias viewProfile: webroot.webViewCoreProfile
|
||||
|
||||
FlickableWebViewCore {
|
||||
id: webroot
|
||||
width: parent.width
|
||||
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
|
||||
|
||||
|
||||
onLoadingChangedCallback: {
|
||||
keyboardRaised = false;
|
||||
punctuationMode = false;
|
||||
|
|
Loading…
Reference in a new issue