Example #1
0
    def acceptNavigationRequest(self, url: QUrl,
                                type_: QWebEnginePage.NavigationType,
                                is_main_frame: bool) -> bool:
        if not is_main_frame:
            return super().acceptNavigationRequest(url, type_, is_main_frame)

        if (type_ != QWebEnginePage.NavigationTypeTyped
                and url.authority() != self.url().authority()):
            # The web is only allowed pages on the same origin
            # Cross origin pages would open in browser
            if url.scheme() in ("http", "https"):
                QDesktopServices.openUrl(url)

            return False

        return super().acceptNavigationRequest(url, type_, is_main_frame)
Example #2
0
    def update_content(self, item):
        if not item.data:
            self.clear()
            return

        html = u""
        for k in sorted(item.data):
            v = item.data[k]
            if v is not None:
                html += "<strong>%s</strong>: " % k
                if isinstance(v, str):
                    url = QUrl(v)
                    if url.isValid() and url.scheme():
                        v = '<a href="%s">%s</a>' % (v, v)
                html += "{}<br>".format(v)
        self.setHtml(html)
Example #3
0
    def navigate_to_url(self):  # Does not receive the Url
        q = QUrl(self.urlbar.text())
        if q.scheme() == "":
            q.setScheme("http")

        self.tabs.currentWidget().setUrl(q)
Example #4
0
    def navigate_to_url(self):  # Does not receive the Url
        q = QUrl(self.urlbar.text())
        if q.scheme() == "":
            q.setScheme("http")

        self.browser.setUrl(q)
Example #5
0
File: help.py Project: djdt/pewpew
 def loadResource(self, type: int, name: QtCore.QUrl) -> Any:
     if name.scheme() == "qthelp":
         return self.engine.fileData(name)
     return super().loadResource(type, name)