def printpage(self, preview=False, count: {'special': 'count'} = None): """Print the current/[count]th tab. Args: preview: Show preview instead of printing. count: The tab index to print, or None. """ if not qtutils.check_print_compat(): # WORKAROUND (remove this when we bump the requirements to 5.3.0) raise cmdexc.CommandError( "Printing on Qt < 5.3.0 on Windows is broken, please upgrade!") tab = self._cntwidget(count) if tab is not None: if preview: diag = QPrintPreviewDialog() diag.setAttribute(Qt.WA_DeleteOnClose) diag.setWindowFlags(diag.windowFlags() | Qt.WindowMaximizeButtonHint | Qt.WindowMinimizeButtonHint) diag.paintRequested.connect(tab.print) diag.exec_() else: diag = QPrintDialog() diag.setAttribute(Qt.WA_DeleteOnClose) diag.open(lambda: tab.print(diag.printer()))
def printpage(self, preview=False, count: {'special': 'count'}=None): """Print the current/[count]th tab. Args: preview: Show preview instead of printing. count: The tab index to print, or None. """ if not qtutils.check_print_compat(): # WORKAROUND (remove this when we bump the requirements to 5.3.0) raise cmdexc.CommandError( "Printing on Qt < 5.3.0 on Windows is broken, please upgrade!") tab = self._cntwidget(count) if tab is not None: if preview: diag = QPrintPreviewDialog() diag.setAttribute(Qt.WA_DeleteOnClose) diag.setWindowFlags(diag.windowFlags() | Qt.WindowMaximizeButtonHint | Qt.WindowMinimizeButtonHint) diag.paintRequested.connect(tab.print) diag.exec_() else: diag = QPrintDialog() diag.setAttribute(Qt.WA_DeleteOnClose) diag.open(lambda: tab.print(diag.printer()))
def on_print_requested(self, frame): """Handle printing when requested via javascript.""" if not qtutils.check_print_compat(): message.error(self._win_id, "Printing on Qt < 5.3.0 on Windows is " "broken, please upgrade!", immediately=True) return printdiag = QPrintDialog() printdiag.setAttribute(Qt.WA_DeleteOnClose) printdiag.open(lambda: frame.print(printdiag.printer()))
def test_check_print_compat(os_name, qversion, expected, monkeypatch): """Test check_print_compat. Args: os_name: The fake os.name to set. qversion: The fake qVersion() to set. expected: The expected return value. """ monkeypatch.setattr('qutebrowser.utils.qtutils.os.name', os_name) monkeypatch.setattr('qutebrowser.utils.qtutils.qVersion', lambda: qversion) assert qtutils.check_print_compat() == expected
def test_check_print_compat(os_name, qversion, expected, monkeypatch): """Test check_print_compat. Args: os_name: The fake os.name to set. qversion: The fake qVersion() to set. expected: The expected return value. """ monkeypatch.setattr(qtutils.os, 'name', os_name) monkeypatch.setattr(qtutils, 'qVersion', lambda: qversion) assert qtutils.check_print_compat() == expected
def _do_check(self): if not qtutils.check_print_compat(): # WORKAROUND (remove this when we bump the requirements to 5.3.0) raise browsertab.WebTabError( "Printing on Qt < 5.3.0 on Windows is broken, please upgrade!")