예제 #1
0
    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()))
예제 #2
0
    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()))
예제 #3
0
 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()))
예제 #4
0
 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()))
예제 #5
0
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
예제 #6
0
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
예제 #7
0
 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!")
예제 #8
0
 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!")