diff --git a/BUGS b/BUGS index 97f11f3e8..f87a6e633 100644 --- a/BUGS +++ b/BUGS @@ -78,10 +78,6 @@ Upstream Bugs Asked on SO: http://stackoverflow.com/q/23499159/2085149 TODO: report Qt bug -- Printing under windows produced blank pages - https://bugreports.qt-project.org/browse/QTBUG-19571 - If this isn't fixed in Qt 5.3, bug should be reopened. - - QWebElement needs geometries() https://bugreports.qt-project.org/browse/QTBUG-38698 diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 2f14ddc55..f6fcfe776 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -35,7 +35,8 @@ import qutebrowser.utils.message as message import qutebrowser.utils.webelem as webelem import qutebrowser.browser.quickmarks as quickmarks import qutebrowser.utils.log as log -from qutebrowser.utils.misc import check_overflow, shell_escape +from qutebrowser.utils.misc import (check_overflow, shell_escape, + check_print_compat) from qutebrowser.utils.editor import ExternalEditor from qutebrowser.commands.exceptions import CommandError from qutebrowser.commands.userscripts import UserscriptRunner @@ -197,6 +198,9 @@ class CommandDispatcher: Args: count: The tab index to print, or None. """ + if not check_print_compat(): + raise CommandError("Printing on Qt < 5.3.0 on Windows is broken, " + "please upgrade!") tab = self._tabs.cntwidget(count) if tab is not None: preview = QPrintPreviewDialog() @@ -210,9 +214,9 @@ class CommandDispatcher: Args: count: The tab index to print, or None. """ - # QTBUG: We only get blank pages. - # https://bugreports.qt-project.org/browse/QTBUG-19571 - # If this isn't fixed in Qt 5.3, bug should be reopened. + if not check_print_compat(): + raise CommandError("Printing on Qt < 5.3.0 on Windows is broken, " + "please upgrade!") tab = self._tabs.cntwidget(count) if tab is not None: printdiag = QPrintDialog() diff --git a/qutebrowser/browser/webpage.py b/qutebrowser/browser/webpage.py index b986304e8..86263a2a2 100644 --- a/qutebrowser/browser/webpage.py +++ b/qutebrowser/browser/webpage.py @@ -30,7 +30,7 @@ import qutebrowser.utils.message as message import qutebrowser.utils.url as urlutils import qutebrowser.config.config as config import qutebrowser.utils.log as log -from qutebrowser.utils.misc import read_file +from qutebrowser.utils.misc import read_file, check_print_compat from qutebrowser.utils.usertypes import PromptMode @@ -145,6 +145,10 @@ class BrowserPage(QWebPage): def on_print_requested(self, frame): """Handle printing when requested via javascript.""" + if not check_print_compat(): + message.error("Printing on Qt < 5.3.0 on Windows is broken, " + "please upgrade!") + return printdiag = QPrintDialog() printdiag.open(lambda: frame.print(printdiag.printer())) diff --git a/qutebrowser/utils/misc.py b/qutebrowser/utils/misc.py index 27b06c441..014e4eac1 100644 --- a/qutebrowser/utils/misc.py +++ b/qutebrowser/utils/misc.py @@ -397,6 +397,11 @@ def format_size(size, base=1024, suffix=''): return '{:.02f}{}{}'.format(size, prefixes[-1], suffix) +def check_print_compat(): + """Check if printing should work in the given Qt version.""" + return not (os.name == 'nt' and qt_version_check('5.3.0', operator.lt)) + + class EventLoop(QEventLoop): """A thin wrapper around QEventLoop.