Exemplo n.º 1
0
 def on_report_clicked(self):
     """Prevent empty reports."""
     if (not self._info.toPlainText().strip() and
             not self._contact.toPlainText().strip() and
             self._get_error_type() == 'segv' and
             self._func == 'qt_mainloop'):
         msgbox.msgbox(parent=self, title='Empty crash info',
                       text="Empty reports for fatal crashes are useless "
                       "and mean I'll spend time deleting reports I could "
                       "spend on developing qutebrowser instead.\n\nPlease "
                       "help making qutebrowser better by providing more "
                       "information, or don't report this.",
                       icon=QMessageBox.Critical)
     else:
         super().on_report_clicked()
Exemplo n.º 2
0
    def _handle_ssl_support(self, fatal: bool = False) -> None:
        """Check for full SSL availability.

        If "fatal" is given, show an error and exit.
        """
        if QSslSocket.supportsSsl():
            return

        if qtutils.version_check('5.12.4'):
            version_text = ("If you use OpenSSL 1.0 with a PyQt package from "
                            "PyPI (e.g. on Ubuntu 16.04), you will need to "
                            "build OpenSSL 1.1 from sources and set "
                            "LD_LIBRARY_PATH accordingly.")
        else:
            version_text = ("If you use OpenSSL 1.1 with a PyQt package from "
                            "PyPI (e.g. on Archlinux or Debian Stretch), you "
                            "need to set LD_LIBRARY_PATH to the path of "
                            "OpenSSL 1.0 or use Qt >= 5.12.4.")

        text = ("Could not initialize QtNetwork SSL support. {} This only "
                "affects downloads and :adblock-update.".format(version_text))

        if fatal:
            errbox = msgbox.msgbox(parent=None,
                                   title="SSL error",
                                   text="Could not initialize SSL support.",
                                   icon=QMessageBox.Critical,
                                   plain_text=False)
            errbox.exec_()
            sys.exit(usertypes.Exit.err_init)

        assert not fatal
        log.init.warning(text)
Exemplo n.º 3
0
    def _handle_ssl_support(self, fatal: bool = False) -> None:
        """Check for full SSL availability.

        If "fatal" is given, show an error and exit.
        """
        text = ("Could not initialize QtNetwork SSL support. If you use "
                "OpenSSL 1.1 with a PyQt package from PyPI (e.g. on Archlinux "
                "or Debian Stretch), you need to set LD_LIBRARY_PATH to the "
                "path of OpenSSL 1.0. This only affects downloads.")

        if QSslSocket.supportsSsl():
            return

        if fatal:
            errbox = msgbox.msgbox(parent=None,
                                   title="SSL error",
                                   text="Could not initialize SSL support.",
                                   icon=QMessageBox.Critical,
                                   plain_text=False)
            errbox.exec_()
            sys.exit(usertypes.Exit.err_init)

        if fatal:
            raise AssertionError
        log.init.warning(text)
Exemplo n.º 4
0
def test_plain_text(qtbot, plain_text, expected):
    box = msgbox.msgbox(parent=None,
                        title='foo',
                        text='foo',
                        icon=QMessageBox.Information,
                        plain_text=plain_text)
    qtbot.add_widget(box)
    assert box.textFormat() == expected
Exemplo n.º 5
0
def late_init(save_manager):
    """Initialize the rest of the config after the QApplication is created."""
    global _init_errors
    if _init_errors is not None:
        errbox = msgbox.msgbox(parent=None,
                               title="Error while reading config",
                               text=_init_errors.to_html(),
                               icon=QMessageBox.Warning,
                               plain_text=False)
        errbox.exec_()
    _init_errors = None

    config.instance.init_save_manager(save_manager)
    configfiles.state.init_save_manager(save_manager)
Exemplo n.º 6
0
def late_init(save_manager):
    """Initialize the rest of the config after the QApplication is created."""
    global _init_errors
    if _init_errors is not None:
        errbox = msgbox.msgbox(parent=None,
                               title="Error while reading config",
                               text=_init_errors.to_html(),
                               icon=QMessageBox.Warning,
                               plain_text=False)
        errbox.exec_()
    _init_errors = None

    config.instance.init_save_manager(save_manager)
    configfiles.state.init_save_manager(save_manager)
Exemplo n.º 7
0
def test_finished_signal(qtbot):
    """Make sure we can pass a slot to be called when the dialog finished."""
    signal_triggered = False

    def on_finished():
        nonlocal signal_triggered
        signal_triggered = True

    box = msgbox.msgbox(parent=None, title='foo', text='foo',
                        icon=QMessageBox.Information, on_finished=on_finished)

    qtbot.add_widget(box)

    with qtbot.waitSignal(box.finished):
        box.accept()

    assert signal_triggered
Exemplo n.º 8
0
def _check_backend_modules():
    """Check for the modules needed for QtWebKit/QtWebEngine."""
    imports = _try_import_backends()

    if imports.webkit_available and imports.webengine_available:
        return
    elif not imports.webkit_available and not imports.webengine_available:
        text = ("<p>qutebrowser needs QtWebKit or QtWebEngine, but neither "
                "could be imported!</p>"
                "<p>The errors encountered were:<ul>"
                "<li><b>QtWebKit:</b> {webkit_error}"
                "<li><b>QtWebEngine:</b> {webengine_error}"
                "</ul></p>".format(
                    webkit_error=html.escape(imports.webkit_error),
                    webengine_error=html.escape(imports.webengine_error)))
        errbox = msgbox.msgbox(parent=None,
                               title="No backend library found!",
                               text=text,
                               icon=QMessageBox.Critical,
                               plain_text=False)
        errbox.exec_()
        sys.exit(usertypes.Exit.err_init)
    elif objects.backend == usertypes.Backend.QtWebKit:
        if imports.webkit_available:
            return
        assert imports.webengine_available
        _show_dialog(
            backend=usertypes.Backend.QtWebKit,
            because="QtWebKit could not be imported",
            text="<p><b>The error encountered was:</b><br/>{}</p>".format(
                html.escape(imports.webkit_error))
        )
    elif objects.backend == usertypes.Backend.QtWebEngine:
        if imports.webengine_available:
            return
        assert imports.webkit_available
        _show_dialog(
            backend=usertypes.Backend.QtWebEngine,
            because="QtWebEngine could not be imported",
            text="<p><b>The error encountered was:</b><br/>{}</p>".format(
                html.escape(imports.webengine_error))
        )

    # Should never be reached
    assert False
Exemplo n.º 9
0
def _check_backend_modules():
    """Check for the modules needed for QtWebKit/QtWebEngine."""
    imports = _try_import_backends()

    if imports.webkit_available and imports.webengine_available:
        return
    elif not imports.webkit_available and not imports.webengine_available:
        text = ("<p>qutebrowser needs QtWebKit or QtWebEngine, but neither "
                "could be imported!</p>"
                "<p>The errors encountered were:<ul>"
                "<li><b>QtWebKit:</b> {webkit_error}"
                "<li><b>QtWebEngine:</b> {webengine_error}"
                "</ul></p>".format(
                    webkit_error=html.escape(imports.webkit_error),
                    webengine_error=html.escape(imports.webengine_error)))
        errbox = msgbox.msgbox(parent=None,
                               title="No backend library found!",
                               text=text,
                               icon=QMessageBox.Critical,
                               plain_text=False)
        errbox.exec_()
        sys.exit(usertypes.Exit.err_init)
    elif objects.backend == usertypes.Backend.QtWebKit:
        if imports.webkit_available:
            return
        assert imports.webengine_available
        _show_dialog(
            backend=usertypes.Backend.QtWebKit,
            because="QtWebKit could not be imported",
            text="<p><b>The error encountered was:</b><br/>{}</p>".format(
                html.escape(imports.webkit_error))
        )
    elif objects.backend == usertypes.Backend.QtWebEngine:
        if imports.webengine_available:
            return
        assert imports.webkit_available
        _show_dialog(
            backend=usertypes.Backend.QtWebEngine,
            because="QtWebEngine could not be imported",
            text="<p><b>The error encountered was:</b><br/>{}</p>".format(
                html.escape(imports.webengine_error))
        )

    # Should never be reached
    assert False
Exemplo n.º 10
0
def test_attributes(qtbot):
    """Test basic QMessageBox attributes."""
    title = 'title'
    text = 'text'
    parent = QWidget()
    qtbot.add_widget(parent)
    icon = QMessageBox.Critical
    buttons = QMessageBox.Ok | QMessageBox.Cancel

    box = msgbox.msgbox(parent=parent, title=title, text=text, icon=icon,
                        buttons=buttons)
    qtbot.add_widget(box)
    if sys.platform != 'darwin':
        assert box.windowTitle() == title
    assert box.icon() == icon
    assert box.standardButtons() == buttons
    assert box.text() == text
    assert box.parent() is parent
Exemplo n.º 11
0
def late_init(save_manager: savemanager.SaveManager) -> None:
    """Initialize the rest of the config after the QApplication is created."""
    global _init_errors
    if _init_errors is not None:
        errbox = msgbox.msgbox(parent=None,
                               title="Error while reading config",
                               text=_init_errors.to_html(),
                               icon=QMessageBox.Warning,
                               plain_text=False)
        errbox.exec_()

        if _init_errors.fatal:
            sys.exit(usertypes.Exit.err_init)

    _init_errors = None

    configtypes.Font.set_default_family(config.val.fonts.default_family)
    config.instance.changed.connect(_update_font_default_family)

    config.instance.init_save_manager(save_manager)
    configfiles.state.init_save_manager(save_manager)
Exemplo n.º 12
0
def _handle_ssl_support(fatal=False):
    """Check for full SSL availability.

    If "fatal" is given, show an error and exit.
    """
    text = ("Could not initialize QtNetwork SSL support. If you use "
            "OpenSSL 1.1 with a PyQt package from PyPI (e.g. on Archlinux "
            "or Debian Stretch), you need to set LD_LIBRARY_PATH to the path "
            "of OpenSSL 1.0. This only affects downloads.")

    if QSslSocket.supportsSsl():
        return

    if fatal:
        errbox = msgbox.msgbox(parent=None,
                               title="SSL error",
                               text="Could not initialize SSL support.",
                               icon=QMessageBox.Critical,
                               plain_text=False)
        errbox.exec_()
        sys.exit(usertypes.Exit.err_init)

    assert not fatal
    log.init.warning(text)
Exemplo n.º 13
0
def test_plain_text(qtbot, plain_text, expected):
    box = msgbox.msgbox(parent=None, title='foo', text='foo',
                        icon=QMessageBox.Information, plain_text=plain_text)
    qtbot.add_widget(box)
    assert box.textFormat() == expected