Skip to content

Commit

Permalink
Merge pull request #47 from lduboeuf/fix_clipboard
Browse files Browse the repository at this point in the history
Xenial: fix clipboard not working
  • Loading branch information
mateosalta authored Aug 30, 2023
2 parents df75e96 + 7878165 commit 42dd0a6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions app/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Rectangle {

objectName: "mainView"
property bool loaded: false


property QtObject defaultProfile: WebEngineProfile {
id: webContext
Expand All @@ -44,19 +44,19 @@ Rectangle {
sourceCode: "\n(function() {\nvar css = \"* {font-family: \\\"Ubuntu\\\" !important; font-size: 10pt !important;} ytm-pivot-bar-renderer {display: none !important;}\"\n\n;\n\n\nif (typeof GM_addStyle != \"undefined\") {\n\tGM_addStyle(css);\n} else if (typeof PRO_addStyle != \"undefined\") {\n\tPRO_addStyle(css);\n} else if (typeof addStyle != \"undefined\") {\n\taddStyle(css);\n} else {\n\tvar node = document.createElement(\"style\");\n\tnode.type = \"text/css\";\n\tnode.appendChild(document.createTextNode(css));\n\tvar heads = document.getElementsByTagName(\"head\");\n\tif (heads.length > 0) {\n\t\theads[0].appendChild(node); \n\t} else {\n\t\t// no head yet, stick it whereever\n\t\tdocument.documentElement.appendChild(node);\n\t}\n}\n\n})();"
}
]

httpUserAgent: "Mozilla/5.0 (Linux; Android 11; Ubuntu Touch) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Mobile Safari/537.36"
}

WebView {

id: webview

anchors.fill: parent
backgroundColor: "#111111"
url: "https://m.youtube.com/"


profile: defaultProfile
settings.fullScreenSupportEnabled: true
settings.dnsPrefetchEnabled: true
Expand Down Expand Up @@ -105,7 +105,7 @@ Rectangle {
}
else {
window.showNormal();
}
}
}

onLoadingChanged: {
Expand Down Expand Up @@ -155,14 +155,15 @@ Rectangle {
text: i18n.tr("Copy link")
enabled: webview.contextMenuRequest
onTriggered: {
console.log(webview.contextMenuRequest.linkUrl.toString())

var url = ''
if (webview.contextMenuRequest.linkUrl.toString().length > 0) {
url = webview.contextMenuRequest.linkUrl.toString()
} else {
//when clicking on the video
url = webview.url
url = webview.url.toString()
}
console.log("push to clipboard:", url)

Clipboard.push(url)
webview.contextMenuRequest = null;
Expand Down Expand Up @@ -239,8 +240,8 @@ Rectangle {
}
]
}


Rectangle {
id: splashScreen
color: "#111111"
Expand All @@ -267,7 +268,7 @@ Rectangle {
}

}


Connections {
target: webview
Expand Down Expand Up @@ -323,8 +324,8 @@ Rectangle {
window.visibility = ApplicationWindow.Windowed
}
}


function toggleApplicationLevelFullscreen() {
setFullscreen(visibility !== ApplicationWindow.FullScreen)
}
Expand Down

0 comments on commit 42dd0a6

Please sign in to comment.