Permalink
Browse files

Add a backend warning when using QtWebKit

  • Loading branch information...
The-Compiler committed May 30, 2017
1 parent 4cb82af commit 1c6fd6f7250063c5e2d1668afb661ab26430aa57
Showing with 129 additions and 11 deletions.
  1. +28 −11 qutebrowser/app.py
  2. +11 −0 qutebrowser/browser/qutescheme.py
  3. +90 −0 qutebrowser/html/backend-warning.html
@@ -53,7 +53,7 @@
from qutebrowser.keyinput import macros
from qutebrowser.mainwindow import mainwindow, prompt
from qutebrowser.misc import (readline, ipc, savemanager, sessions,
crashsignal, earlyinit)
crashsignal, earlyinit, objects)
from qutebrowser.misc import utilcmds # pylint: disable=unused-import
from qutebrowser.utils import (log, version, message, utils, qtutils, urlutils,
objreg, usertypes, standarddir, error, debug)
@@ -202,7 +202,7 @@ def _process_args(args):
process_pos_args(args.command)
_open_startpage()
_open_quickstart(args)
_open_special_pages(args)
delta = datetime.datetime.now() - earlyinit.START_TIME
log.init.debug("Init finished after {}s".format(delta.total_seconds()))
@@ -319,23 +319,40 @@ def _open_startpage(win_id=None):
tabbed_browser.tabopen(url)
def _open_quickstart(args):
"""Open quickstart if it's the first start.
def _open_special_pages(args):
"""Open special notification pages which are only shown once.
Currently this is:
- Quickstart page if it's the first start.
- Legacy QtWebKit warning if needed.
Args:
args: The argparse namespace.
"""
if args.basedir is not None:
# With --basedir given, don't open quickstart.
# With --basedir given, don't open anything.
return
state_config = objreg.get('state-config')
try:
quickstart_done = state_config['general']['quickstart-done'] == '1'
except KeyError:
quickstart_done = False
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window='last-focused')
# Legacy QtWebKit warning
needs_warning = (objects.backend == usertypes.Backend.QtWebKit and
not qtutils.is_qtwebkit_ng())
warning_shown = state_config['general'].get('backend-warning-shown') == '1'
if not warning_shown and needs_warning:
tabbed_browser.tabopen(QUrl('qute://backend-warning'),
background=False)
state_config['general']['backend-warning-shown'] = '1'
# Quickstart page
quickstart_done = state_config['general'].get('quickstart-done') == '1'
if not quickstart_done:
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window='last-focused')
tabbed_browser.tabopen(
QUrl('https://www.qutebrowser.org/quickstart.html'))
state_config['general']['quickstart-done'] = '1'
@@ -30,6 +30,7 @@
import time
import urllib.parse
import datetime
import pkg_resources
from PyQt5.QtCore import QUrlQuery, QUrl
@@ -431,3 +432,13 @@ def qute_help(url):
else:
data = utils.read_file(path)
return 'text/html', data
@add_handler('backend-warning')
def qute_backend_warning(url):
"""Handler for qute://backend-warning."""
html = jinja.render('backend-warning.html',
distribution=version.distribution(),
Distribution=version.Distribution,
version=pkg_resources.parse_version)
return 'text/html', html
@@ -0,0 +1,90 @@
{% extends "styled.html" %}
{% block style %}
{{super()}}
.note {
font-size: smaller;
color: grey;
}
.mono {
font-family: monospace;
}
{% endblock %}
{% block content %}
<h1>Legacy QtWebKit backend</h1>
<span class="note">Note this warning will only appear once. Use <span class="mono">:open
qute://backend-warning</span> to show it again at a later time.</span>
<p>
You're using qutebrowser with the legacy QtWebKit backend. It's still the
default until a few remaining issues are sorted out. If you can, it's
strongly suggested to switch earlier, as legacy QtWebKit has known security
issues and also breaks things on various websites.
</p>
<h2>Using QtWebEngine instead</h2>
<span class="note">This is usually the better choice if you aren't using Nouveau graphics, and
don't need any features which are currently unavailable with QtWebEngine (like
the <span class="mono">qute://settings</span> page or caret browsing).</span>
{% macro install_webengine(package) -%}
You should be able to install <span class="mono">{{ package }}</span> and start qutebrowser with <span class="mono">--backend webengine</span> to use the new backend.
{%- endmacro %}
{% macro please_open_issue() -%}
If you know more, please <a href="https://github.com/qutebrowser/qutebrowser/issues/new">open an issue</a>!
{%- endmacro %}
<p>
{% if distribution.parsed == Distribution.ubuntu %}
{% if distribution.version >= version('17.04') %}
{{ install_webengine('python3-pyqt5.qtwebengine') }}
{% elif distribution.version >= version('16.04') %}
QtWebEngine is only available in Ubuntu's repositories since 17.04, but you can <a href="https://github.com/qutebrowser/qutebrowser/blob/master/INSTALL.asciidoc#installing-qutebrowser-with-tox">install qutebrowser via tox</a> with <span class="mono">tox -e mkvenv-pypi</span> to use the new backend.
{% else %}
Unfortunately, no easy way is known to install QtWebEngine on Ubuntu &lt; 16.04. {{ please_open_issue() }}
{% endif %}
{% elif distribution.parsed == Distribution.debian %}
{% if distribution.version >= version('9') %}
{{ install_webengine('python3-pyqt5.qtwebengine') }}
{% else %}
Unfortunately, no easy way is known to install QtWebEngine on Debian &lt; 9. {{ please_open_issue() }}
{% endif %}
{% elif distribution.parsed in [Distribution.arch, Distribution.manjaro] %}
{{ install_webengine('qt5-webengine') }}
{% elif distribution.parsed == Distribution.void %}
{{ install_webengine('python-PyQt5-webengine') }}
{% elif distribution.parsed == Distribution.fedora %}
{{ install_webengine('qt5-qtwebengine') }}
{% elif distribution.parsed == Distribution.opensuse %}
{{ install_webengine('libqt5-qtwebengine') }}
{% else %}
There's no information available for your system. {{ please_open_issue() }}
{% endif %}
</p>
<h2>Using QtWebKit-NG instead</h2>
<span class="note" >This is a drop-in replacement for legacy QtWebKit. Note <b>private browsing won't work with it properly</b> until its next release.</span>
<p>
{% if distribution.parsed == Distribution.debian and distribution.version >= version('9') %}
There are unofficial QtWebKit-NG packages <a href="http://repo.paretje.be/unstable/">available</a>.
{% elif distribution.parsed in [Distribution.ubuntu, Distribution.debian] %}
No easy way is known to install QtWebKit-NG on your system.
There are unofficial QtWebKit-NG packages <a href="http://repo.paretje.be/unstable/">available</a>, but they are intended for Debian Unstable.
{{ please_open_issue() }}
{% elif distribution.parsed in [Distribution.arch, Distribution.manjaro] %}
You should be able to install <span class="mono">qt5-webkit-ng</span> via <span class="mono">pacman</span>.
{% elif distribution.parsed == Distribution.gentoo %}
There's an unofficial <a href="https://gist.github.com/annulen/309569fb61e5d64a703c055c1e726f71">ebuild</a> available.
{% else %}
There's no information available for your system. {{ please_open_issue() }}
{% endif %}
</p>
{% endblock %}

0 comments on commit 1c6fd6f

Please sign in to comment.