Verified Commit 37cd7b69 authored by Jonah Brüchert's avatar Jonah Brüchert
Browse files

feature: Add action for showing the desktop site

parent 51407074
......@@ -37,25 +37,37 @@ WebEngineView {
/**
* User agent used on mobile devices
*/
property string mobileUserAgent: "Mozilla/5.0 (Linux; Plasma Mobile, like Android 9.0 ) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.128 Mobile Safari/537.36"
readonly property string mobileUserAgent: "Mozilla/5.0 (Linux; Plasma Mobile, like Android 9.0 ) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.116 Mobile Safari/537.36"
/**
* User agent used on desktop devices,
* Defaults to QtWebEngine's default (it is only supported on desktop devices by Qt currently)
*/
property string desktopUserAgent: profile.httpUserAgent
readonly property string desktopUserAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.14.0 Chrome/75.0.3770.116 Safari/537.36"
width: pageWidth
height: pageHeight
profile {
httpUserAgent: {
if (Kirigami.Settings.isMobile)
return mobileUserAgent
else
return desktopUserAgent
state: Kirigami.Settings.isMobile ? "mobile" : "desktop"
states: [
State {
name: "mobile"
PropertyChanges {
target: webEngineView
profile.httpUserAgent: mobileUserAgent
}
},
State {
name: "desktop"
PropertyChanges {
target: webEngineView
profile.httpUserAgent: desktopUserAgent
}
}
]
profile {
offTheRecord: rootPage.privateMode
onDownloadRequested: {
......
......@@ -273,6 +273,27 @@ Kirigami.ApplicationWindow {
request.bookmarked = true;
browserManager.addBookmark(request);
}
},
Kirigami.Action {
icon.name: "computer"
text: i18n("Show desktop site")
checkable: true
checked: {
if (currentWebView.state === "mobile") {
false
} else if (currentWebView.state === "desktop") {
true
}
}
onTriggered: {
if (currentWebView.state === "desktop") {
currentWebView.state = "mobile"
} else if (currentWebView.state === "mobile") {
currentWebView.state = "desktop"
}
currentWebView.reload()
}
}
]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment