New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QtWebEngine backend #666
Comments
I'd like this feature a lot. There's only one open source blink-based browser I know of (chromium) so you'll be doubling the number :D |
For the lack of a better place to put this - here's a great example by Kovid Goyal on how to use QtWebChannel: #!/usr/bin/env python3
# vim:fileencoding=utf-8
from PyQt5.Qt import *
qwebchannel_js = QFile(':/qtwebchannel/qwebchannel.js')
if not qwebchannel_js.open(QIODevice.ReadOnly):
raise SystemExit(
'Failed to load qwebchannel.js with error: %s' %
qwebchannel_js.errorString())
qwebchannel_js = bytes(qwebchannel_js.readAll()).decode('utf-8')
def client_script():
script = QWebEngineScript()
script.setSourceCode(qwebchannel_js + '''
new QWebChannel(qt.webChannelTransport, function(channel) {
channel.objects.bridge.print('Hello world!');
});
''')
script.setName('xxx')
script.setWorldId(QWebEngineScript.MainWorld)
script.setInjectionPoint(QWebEngineScript.DocumentReady)
script.setRunsOnSubFrames(True)
return script
class WebPage(QWebEnginePage):
def javaScriptConsoleMessage(self, level, msg, linenumber, source_id):
try:
print('%s:%s: %s' % (source_id, linenumber, msg))
except OSError:
pass
@pyqtSlot(str)
def print(self, text):
print('From JS:', text)
app = QApplication([])
p = WebPage()
v = QWebEngineView()
v.setPage(p)
p.profile().scripts().insert(client_script())
c = QWebChannel(p)
p.setWebChannel(c)
c.registerObject('bridge', p)
v.setHtml('<p>Hello world!')
v.show()
app.exec_() |
Not sure if this is the right place but I just wanted to point out https://wiki.qt.io/New_Features_in_Qt_5.6#Removed_Modules. Not sure what that means for qutebrowser though. |
@vyp See my answer to the Archlinux BBS (and the comment on the Phoronix post quoted there). |
@The-Compiler Oh I didn't know about that, sorry! Also, I'm not blaming you, just trying to point out information which may be helpful. But I guess all this means is that as long as distributions continue to package qtwebkit, this shouldn't be an issue. |
No worries - I just got into a bit of rage-mode there because of the Phoronix commenter 😉
Indeed. And looking at how much still is using QtWebKit, I'm quite sure they'll continue packaging it rather than dropping all that. |
Refactoring notesCurrently working on refactoring everything QtWebKit-specific - some random notes here:
|
The |
@artur-shaik Would you be interested in working on caret browsing for QtWebEngine by any chance? Since the related web actions aren't available like in QtWebKit, you'd need to do it all in JS - you can add a new file to Then you can call functions from that file similar to what I did in b78b89f. |
@The-Compiler, unfortunatly I'm quite busy right now. Not sure how long I will be busy, but if nobody will do it I can try to implement this when I will have some free time. |
Okay, thanks for the update - anyone else with a bit more JS knowledge than me stepping up? 😉 |
There are couple of things that currently don't work with webengine and are not listed above:
|
"Custom URL handlers" is there. I added "Other customizations in WebView/WebPage subclasses" where the mouse buttons are included. |
@The-Compiler |
The caret part would be nice, but I think it involves a lot of javascript as the needed feature doesn't exist for QtWebEngine at all... As for the proxy we're currently dealing with weird proxy-related crashes (see e.g. libproxy/libproxy#45 and #1891 (comment)) so I'd like to avoid adding new code for that currently. |
I don't mind the javascript part. I am ok with javascript, in general. |
I started some work on fullscreen videos in the |
They create a key event handler in webview that checks if the escape key is pressed and then it triggers the ExitFullscreen action. void WebView::_keyReleaseEvent(QKeyEvent *event)
{
if (mApp->plugins()->processKeyRelease(Qz::ON_WebView, this, event)) {
event->accept();
}
switch (event->key()) {
case Qt::Key_Escape:
if (isFullScreen()) {
triggerPageAction(QWebEnginePage::ExitFullScreen);
event->accept();
}
break;
default:
break;
}
} https://github.com/QupZilla/qupzilla/blob/master/src/lib/webengine/webview.cpp (Line 1144) |
Many of the missing features are implemented with the upcoming v0.10.0 release (see the changelog), and I think it's time to close this! 🎉 For the things which are still missing, I opened separate issues, see this search. |
TODO
DNT
/Accept-Language
) (?)Custom cookie handlingCustom cache handling:download
:navigate
:open-editor
:insert-text
:paste-primary
Support for Qt 5.5+(not going to happen, 5.6+ only)qute://*
)qute:settings
/ JS bridgeCustom error pagescreateWindow
)WebView
/WebPage
subclasses):print --pdf
is implemented but untested, normal printing is not implemented - also see Add initial printing support with QtWebEngine >= 5.7.0 QupZilla/qupzilla#2068xfail(run=False)
tests incaret.feature
are so slowNotes about individual features
Hints
The hints (labels to click links via keyboard, see screenshot) are currently implemented in Python, via the QWebElement API (see hints.py and webelem.py).
Since that API doesn't exist anymore with QtWebEngine, a big part of it will have to be reimplemented in Javascript, either using QWebEnginePage::runJavaScript or QWebChannel.
:hint
features (see hints.feature)HintManager
class (see hints.py) into separate classes for finding elements/drawing labels/clicking elementsThe text was updated successfully, but these errors were encountered: