示例#1
0
 def __init__(self, vertical, parent=None):
     QWebView.__init__(self, parent)
     s = self.settings()
     s.setAttribute(s.JavascriptEnabled, False)
     self.vertical = vertical
     self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
     self.linkClicked.connect(self.link_activated)
     self._link_clicked = False
     self.setAttribute(Qt.WA_OpaquePaintEvent, False)
     palette = self.palette()
     self.setAcceptDrops(False)
     palette.setBrush(QPalette.Base, Qt.transparent)
     self.page().setPalette(palette)
     self.css = P('templates/book_details.css', data=True).decode('utf-8')
     for x, icon in [('remove_format', 'trash.png'),
                     ('save_format', 'save.png'),
                     ('restore_format', 'edit-undo.png'),
                     ('copy_link', 'edit-copy.png'),
                     ('manage_author', 'user_profile.png'),
                     ('compare_format', 'diff.png')]:
         ac = QAction(QIcon(I(icon)), '', self)
         ac.current_fmt = None
         ac.current_url = None
         ac.triggered.connect(getattr(self, '%s_triggerred' % x))
         setattr(self, '%s_action' % x, ac)
     self.setFocusPolicy(Qt.NoFocus)
示例#2
0
文件: tab.py 项目: daffodil/retext
    def __init__(self, editBox, editorPositionToSourceLineFunc,
                 sourceLineToEditorPositionFunc):

        QWebView.__init__(self)

        self.editBox = editBox

        if not globalSettings.handleWebLinks:
            self.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks)
            self.page().linkClicked.connect(QDesktopServices.openUrl)
        self.settings().setAttribute(
            QWebSettings.LocalContentCanAccessFileUrls, False)
        self.settings().setDefaultTextEncoding('utf-8')
        # Avoid caching of CSS
        self.settings().setObjectCacheCapacities(0, 0, 0)

        self.syncscroll = SyncScroll(self.page().mainFrame(),
                                     editorPositionToSourceLineFunc,
                                     sourceLineToEditorPositionFunc)

        # Events relevant to sync scrolling
        self.editBox.cursorPositionChanged.connect(
            self._handleCursorPositionChanged)
        self.editBox.verticalScrollBar().valueChanged.connect(
            self.syncscroll.handleEditorScrolled)
        self.editBox.resized.connect(self._handleEditorResized)

        # Scroll the preview when the mouse wheel is used to scroll
        # beyond the beginning/end of the editor
        self.editBox.scrollLimitReached.connect(self._handleWheelEvent)
示例#3
0
    def __init__(self, *args, **kwargs):
        QWebView.__init__(self, *args, **kwargs)

        self._drag_drop_handler = None
        self._loaded = False
        self._loading = False

        # It is common to use drag&drop with this widget
        self.setAcceptDrops(True)

        self_ref = weakref.ref(self)

        def post_load(ok):
            self_ = self_ref()
            if not self_ or not ok:
                return

            self_._loaded = True
            self_._loading = False

        def during_load():
            self_ = self_ref()
            if not self_:
                return

            self_.loading = True

        self.loadFinished.connect(functools.partial(post_load))
        self.loadStarted.connect(during_load)
示例#4
0
        def __init__(self, parent=None):
            QWebView.__init__(self, parent)
            self.setWindowFlags(Qt.Popup)
            self.setFixedSize(600, 400)
            self.manager = Rpc.RpcNetworkAccessManager(
                self.page().networkAccessManager())
            self.page().setNetworkAccessManager(self.manager)
            self.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks)
            self.linkClicked[QUrl].connect(self.openLink)

            # Determine appropiate position for the popup
            screenHeight = QApplication.desktop().screenGeometry().height()
            screenWidth = QApplication.desktop().screenGeometry().width()
            pos = parent.parent().mapToGlobal(parent.pos())

            # Fix y coordinate
            y = pos.y() + parent.height()
            if y + self.height() > screenHeight:
                y = pos.y() - self.height()
                if y < 0:
                    y = screenHeight - self.height()
            # Fix x coordinate
            x = pos.x()
            if x < 0:
                x = 0
            elif x + self.width() > screenWidth:
                x = screenWidth - self.width()

            self.move(x, y)

            self._label = ''
            self._help = ''
            self._filter = ()
            self._type = None
示例#5
0
 def __init__(self, vertical, parent=None):
     QWebView.__init__(self, parent)
     s = self.settings()
     s.setAttribute(s.JavascriptEnabled, False)
     self.vertical = vertical
     self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
     self.linkClicked.connect(self.link_activated)
     self._link_clicked = False
     self.setAttribute(Qt.WA_OpaquePaintEvent, False)
     palette = self.palette()
     self.setAcceptDrops(False)
     palette.setBrush(QPalette.Base, Qt.transparent)
     self.page().setPalette(palette)
     self.css = P("templates/book_details.css", data=True).decode("utf-8")
     for x, icon in [
         ("remove_format", "trash.png"),
         ("save_format", "save.png"),
         ("restore_format", "edit-undo.png"),
         ("copy_link", "edit-copy.png"),
         ("manage_author", "user_profile.png"),
         ("compare_format", "diff.png"),
     ]:
         ac = QAction(QIcon(I(icon)), "", self)
         ac.current_fmt = None
         ac.current_url = None
         ac.triggered.connect(getattr(self, "%s_triggerred" % x))
         setattr(self, "%s_action" % x, ac)
示例#6
0
 def __init__(self, vertical, parent=None):
     QWebView.__init__(self, parent)
     s = self.settings()
     s.setAttribute(s.JavascriptEnabled, False)
     self.vertical = vertical
     self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
     self.linkClicked.connect(self.link_activated)
     self._link_clicked = False
     self.setAttribute(Qt.WA_OpaquePaintEvent, False)
     palette = self.palette()
     self.setAcceptDrops(False)
     palette.setBrush(QPalette.Base, Qt.transparent)
     self.page().setPalette(palette)
     for x, icon in [
         ('remove_format', 'trash.png'), ('save_format', 'save.png'),
         ('restore_format', 'edit-undo.png'), ('copy_link','edit-copy.png'),
         ('compare_format', 'diff.png'),
         ('set_cover_format', 'default_cover.png'),
     ]:
         ac = QAction(QIcon(I(icon)), '', self)
         ac.current_fmt = None
         ac.current_url = None
         ac.triggered.connect(getattr(self, '%s_triggerred'%x))
         setattr(self, '%s_action'%x, ac)
     self.manage_action = QAction(self)
     self.manage_action.current_fmt = self.manage_action.current_url = None
     self.manage_action.triggered.connect(self.manage_action_triggered)
     self.remove_item_action = ac = QAction(QIcon(I('minus.png')), '...', self)
     ac.data = (None, None, None)
     ac.triggered.connect(self.remove_item_triggered)
     self.setFocusPolicy(Qt.NoFocus)
示例#7
0
    def __init__(self, *args):
        QWebView.__init__(self, *args)
        self.gui = None
        self.tags = ''
        self.create_browser = None

        self._page = NPWebPage()
        self.setPage(self._page)
        self.cookie_jar = QNetworkCookieJar()
        self.page().networkAccessManager().setCookieJar(self.cookie_jar)

        http_proxy = get_proxies().get('http', None)
        if http_proxy:
            proxy_parts = urlparse(http_proxy)
            proxy = QNetworkProxy()
            proxy.setType(QNetworkProxy.HttpProxy)
            if proxy_parts.username:
                proxy.setUser(proxy_parts.username)
            if proxy_parts.password:
                proxy.setPassword(proxy_parts.password)
            if proxy_parts.hostname:
                proxy.setHostName(proxy_parts.hostname)
            if proxy_parts.port:
                proxy.setPort(proxy_parts.port)
            self.page().networkAccessManager().setProxy(proxy)

        self.page().setForwardUnsupportedContent(True)
        self.page().unsupportedContent.connect(self.start_download)
        self.page().downloadRequested.connect(self.start_download)
        self.page().networkAccessManager().sslErrors.connect(self.ignore_ssl_errors)
示例#8
0
文件: tab.py 项目: yiqideren/retext
	def __init__(self, editBox,
	             editorPositionToSourceLineFunc,
	             sourceLineToEditorPositionFunc):

		QWebView.__init__(self)

		self.editBox = editBox

		if not globalSettings.handleWebLinks:
			self.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks)
			self.page().linkClicked.connect(QDesktopServices.openUrl)
		self.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, False)
		self.settings().setDefaultTextEncoding('utf-8')
		# Avoid caching of CSS
		self.settings().setObjectCacheCapacities(0,0,0)

		self.syncscroll = SyncScroll(self.page().mainFrame(),
					     editorPositionToSourceLineFunc,
					     sourceLineToEditorPositionFunc)

		# Events relevant to sync scrolling
		self.editBox.cursorPositionChanged.connect(self._handleCursorPositionChanged)
		self.editBox.verticalScrollBar().valueChanged.connect(self.syncscroll.handleEditorScrolled)
		self.editBox.resized.connect(self._handleEditorResized)

		# Scroll the preview when the mouse wheel is used to scroll
		# beyond the beginning/end of the editor
		self.editBox.scrollLimitReached.connect(self._handleWheelEvent)
示例#9
0
 def __init__(self, window):
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path("leftpane.js"), "r") as f:
         self.js = f.read()
     # We don't want plugins for this simple pane
     self.settings().setAttribute(QWebSettings.PluginsEnabled, False)
     self.reset()
示例#10
0
  def __init__(self, parent=None):
    QWebView.__init__(self, parent)
    self.setAcceptDrops(True)

    self.requestQueue = []
    self.isProcessingExclusively = False

    self.modelLoadersLoaded = False
示例#11
0
文件: preview.py 项目: GRiker/calibre
 def __init__(self, parent=None):
     QWebView.__init__(self, parent)
     self.inspector = QWebInspector(self)
     w = QApplication.instance().desktop().availableGeometry(self).width()
     self._size_hint = QSize(int(w/3), int(w/2))
     self._page = WebPage(self)
     self.setPage(self._page)
     self.inspector.setPage(self._page)
     self.clear()
示例#12
0
 def __init__(self, parent=None):
     QWebView.__init__(self, parent)
     self.inspector = QWebInspector(self)
     w = QApplication.instance().desktop().availableGeometry(self).width()
     self._size_hint = QSize(int(w / 3), int(w / 2))
     self._page = WebPage(self)
     self.setPage(self._page)
     self.inspector.setPage(self._page)
     self.clear()
示例#13
0
    def __init__(self, parent=None):
        QWebView.__init__(self, parent)
        self.setAcceptDrops(True)

        self._page = Q3DWebPage(self)
        self.setPage(self._page)

        # security settings - allow access to remote urls (for Icon)
        self.settings().setAttribute(
            QWebSettings.LocalContentCanAccessRemoteUrls, True)
示例#14
0
 def __init__(self, url):
     self.app = QApplication(sys.argv)
     QWebView.__init__(self)
     self.setPage(SilentWebPage())
     self._loaded = False # Used within _wait_load.
     self.loadFinished.connect(self._loadFinished)
     # The version of webkit I have prints some stuff to stdout which I do not want.
     # See https://bugreports.qt-project.org/browse/QTBUG-31074
     with suppress_stdout_stderr():
         self.load(QUrl(url))
         #self.show()
         self._wait_load()
示例#15
0
 def __init__(self, parent):
     QWebView.__init__(self, parent)
     self._page = Page()
     self._page.elem_clicked.connect(self.elem_clicked)
     self.setPage(self._page)
     raw = '''
     body { background-color: white  }
     .calibre_toc_hover:hover { cursor: pointer !important; border-top: solid 5px green !important }
     '''
     raw = '::selection {background:#ffff00; color:#000;}\n'+raw
     data = 'data:text/css;charset=utf-8;base64,'
     data += b64encode(raw.encode('utf-8'))
     self.settings().setUserStyleSheetUrl(QUrl(data))
示例#16
0
    def __init__(self, parent=None):
        QWebView.__init__(self, parent)
        self.setAcceptDrops(False)
        self.setMaximumWidth(300)
        self.setMinimumWidth(300)

        palette = self.palette()
        palette.setBrush(QPalette.Base, Qt.transparent)
        self.page().setPalette(palette)
        self.setAttribute(Qt.WA_OpaquePaintEvent, False)

        self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
        self.linkClicked.connect(self.link_clicked)
示例#17
0
    def __init__(self, parent=None):
        QWebView.__init__(self, parent)
        self.setAcceptDrops(False)
        self.setMaximumWidth(300)
        self.setMinimumWidth(300)

        palette = self.palette()
        palette.setBrush(QPalette.Base, Qt.transparent)
        self.page().setPalette(palette)
        self.setAttribute(Qt.WA_OpaquePaintEvent, False)

        self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
        self.linkClicked.connect(self.link_clicked)
示例#18
0
 def __init__(self, parent):
     QWebView.__init__(self, parent)
     self._page = Page()
     self._page.elem_clicked.connect(self.elem_clicked)
     self.setPage(self._page)
     raw = '''
     body { background-color: white  }
     .calibre_toc_hover:hover { cursor: pointer !important; border-top: solid 5px green !important }
     '''
     raw = '::selection {background:#ffff00; color:#000;}\n' + raw
     data = 'data:text/css;charset=utf-8;base64,'
     data += b64encode(raw.encode('utf-8'))
     self.settings().setUserStyleSheetUrl(QUrl(data))
示例#19
0
 def __init__(self, parent, networkmanager):
     QWebView.__init__(self, parent)
     page = MyWebPage(self, networkmanager)
     self.setPage(page)
     self.edit_mode_on = False
     self.loading = False
     self.progressVal = 0
     self.timer = QTimer(self)
     self.timer.timeout.connect(self.reload)
     page.contentsChanged.connect(self.resetTimer)
     self.loadStarted.connect(self.onLoadStart)
     self.loadFinished.connect(self.onLoadFinish)
     self.loadProgress.connect(self.onLoadProgress)
     self.linkClicked.connect(self.openLink)
示例#20
0
    def __init__(self, parent=None):
        QWebView.__init__(self, parent)
        self.setAcceptDrops(True)

        self._page = Q3DWebPage(self)
        self.setPage(self._page)

        # security setting for Icon, Model File and point cloud layer
        self.settings().setAttribute(
            QWebSettings.LocalContentCanAccessRemoteUrls, True)

        # web inspector setting
        if DEBUG_MODE:
            self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled,
                                         True)
示例#21
0
文件: webview.py 项目: blropb/qt-test
    def __init__(self):
        QWebView.__init__(self)
        settings = self.settings()
        settings.setAttribute(settings.AutoLoadImages, False)

        self.authorize = False
        self.feed_list = []
        self.page_loaded = False
        self.scroll_down = False
        self.page_height = 0
        self.run_timer = True
        self.trg_func = self.cap
        self.textpage = None

        self.loadFinished.connect(self.set_textpage)
示例#22
0
文件: webview.py 项目: blropb/qt-test
    def __init__(self):
        QWebView.__init__(self)
        settings = self.settings()
        settings.setAttribute(settings.AutoLoadImages, False)

        self.authorize = False
        self.feed_list = []
        self.page_loaded = False
        self.scroll_down = False
        self.page_height = 0
        self.run_timer = True
        self.trg_func = self.cap
        self.textpage = None

        self.loadFinished.connect(self.set_textpage)
示例#23
0
 def __init__(self, parent=None):
     # QWebView
     self.view = QWebView.__init__(self, parent)
     #self.view.setPage(MyBrowser())
     self.setWindowTitle('Loading...')
     self.titleChanged.connect(self.adjustTitle)
     #super(Browser).connect(self.ui.webView,QtCore.SIGNAL("titleChanged (const QString&)"), self.adjustTitle)
     self.timer = None
示例#24
0
 def __init__(self, proxy_type=None, proxy_addr=None, proxy_port=None):
     self.app = QApplication(sys.argv)
     QWebView.__init__(self)
     self._loaded = False
     self.loadFinished.connect(self._loadFinished)
     # Sets the proxy if any
     if proxy_addr and proxy_port and proxy_type:
         proxy = QtNetwork.QNetworkProxy()
         if proxy_type == "http":
             proxy.setType(QtNetwork.QNetworkProxy.HttpProxy)
         elif proxy_type == "socks5":
             proxy.setType(QtNetwork.QNetworkProxy.Socks5Proxy)
         proxy.setHostName(proxy_addr)
         proxy.setPort(int(proxy_port))
         QtNetwork.QNetworkProxy.setApplicationProxy(proxy)
     if not os.path.exists("./screenshots"):
         os.makedirs("./screenshots")
示例#25
0
 def __init__(self, window):
     self.configure_proxy()
     QWebView.__init__(self)
     self.window = window
     with open(Resources.get_path('scudcloud.js'), 'r') as f:
         self.default_js = f.read()
     if self.window.disable_snippets:
         with open(Resources.get_path('disable_snippets.js'), 'r') as f:
             self.disable_snippets_js = f.read()
     self.setPage(Browser())
     self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
     self.urlChanged.connect(self._urlChanged)
     self.loadStarted.connect(self._loadStarted)
     self.loadFinished.connect(self._loadFinished)
     self.linkClicked.connect(self._linkClicked)
     self.page().featurePermissionRequested.connect(self.permissionRequested)
     self.addActions()
示例#26
0
	def __init__(self, tab,
	             editorPositionToSourceLineFunc,
	             sourceLineToEditorPositionFunc):

		QWebView.__init__(self)
		self.tab = tab

		self.syncscroll = SyncScroll(self.page().mainFrame(),
		                             editorPositionToSourceLineFunc,
		                             sourceLineToEditorPositionFunc)
		ReTextWebPreview.__init__(self, tab.editBox)

		self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
		self.page().linkClicked.connect(self._handleLinkClicked)
		self.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, False)
		# Avoid caching of CSS
		self.settings().setObjectCacheCapacities(0,0,0)
示例#27
0
文件: v5.py 项目: w4lker/Antix
 def __init__(self,
              base_url=None,
              gui=False,
              user_agent=None,
              proxy=None,
              allowed_media=None,
              allowed_regex='.*?',
              timeout=20,
              delay=5,
              enable_plugins=True):  #, cache_file=None):
     """
     base_url is the domain that will be crawled
     gui is whether to show webkit window or run headless
     user_agent is used to set the user-agent when downloading content
     proxy is a QNetworkProxy to download through
     allowed_media are the media extensions to allow
     allowed_regex is a regular expressions of URLS to allow
     timeout is the maximum amount of seconds to wait for a request
     delay is the minimum amount of seconds to wait between requests
     """
     self.app = QApplication(sys.argv)  # must instantiate first
     QWebView.__init__(self)
     webpage = WebPage(user_agent or random.choice(settings.user_agents))
     allowed_media = allowed_media or ['css', 'js']
     manager = NetworkAccessManager(proxy, allowed_media, allowed_regex)
     self.manager = manager
     manager.finished.connect(self.finished)
     webpage.setNetworkAccessManager(manager)
     self.setPage(webpage)
     self.setHtml(
         '<html><head></head><body>No content loaded</body></html>',
         QUrl('http://localhost'))
     self.timeout = timeout
     self.delay = delay
     #self.cache = pdict.PersistentDict(cache_file or settings.cache_file) # cache to store webpages
     self.base_url = base_url
     self.jquery_lib = None
     #enable flash plugin etc.
     self.settings().setAttribute(QWebSettings.PluginsEnabled,
                                  enable_plugins)
     #XXXQTimer.singleShot(0, self.run) # start crawling when all events processed
     if gui: self.show()
     #self.show()
     self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
     self.page().linkClicked.connect(self.linkClick)
示例#28
0
    def __init__(self, MainWindow):
        # QWebView
        self.view = QWebView.__init__(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.isUntitled = True

        self.MainWindow = MainWindow

        self.setWindowTitle('Loading...')
        self.titleChanged.connect(self.adjustTitle)
示例#29
0
文件: base.py 项目: averrin/demesne
 def __init__(self, inspect=False):
     QWebView.__init__(self)
     self.wi = EtherIntegration()
     self.hp = EtherUrl()
     self.api = API()
     self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
     self.linkClicked.connect(self.lc)
     self.titleChanged.connect(self.tc)
     self.setRenderHint(QPainter.HighQualityAntialiasing)
     self.setRenderHint(QPainter.SmoothPixmapTransform)
     self.setRenderHint(QPainter.Antialiasing)
     settings = self.page().settings()
     settings.setFontFamily(QWebSettings.StandardFont, self.wi.parent.config.options.webview.main_font)
     settings.setFontSize(QWebSettings.DefaultFontSize, 24)
     if inspect:
         self.page().settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
     palette = QPalette()
     palette.setBrush(QPalette.Base, QBrush(QColor(self.wi.parent.config.options.webview.bg_color)))
     self.page().setPalette(palette)
    def __init__(self, window):
        QWebView.__init__(self)
        self.document_is_ready = False
        self.window = window
        self.setAcceptDrops(True)

        # Get settings
        self.settings_obj = settings.get_settings()

        # Add self as listener to project data updates (used to update the timeline)
        get_app().updates.add_listener(self)

        # set url from configuration (QUrl takes absolute paths for file system paths, create from QFileInfo)
        self.setUrl(
            QUrl.fromLocalFile(QFileInfo(self.html_path).absoluteFilePath()))

        # Connect signal of javascript initialization to our javascript reference init function
        self.page().mainFrame().javaScriptWindowObjectCleared.connect(
            self.setup_js_data)
示例#31
0
    def __init__(self, mainwinref, url, layout, zoomfactor, parent=None):
        module_logger.info("Inside 'ArcaneBrowser' constructor.")

        QWebView.__init__(self, parent)

        self.mainwinref = mainwinref

        #url = "https://google.com"

        self.view = QWebView()

        self.view.setFixedSize(1700, 1000)

        self.view.setZoomFactor(zoomfactor)  #zoom

        self.view.setUrl(QUrl(url))

        layout.addWidget(self.view)

        module_logger.info("Done.")
示例#32
0
    def __init__(self, tab, editorPositionToSourceLineFunc,
                 sourceLineToEditorPositionFunc):

        QWebView.__init__(self)
        self.tab = tab

        self.syncscroll = SyncScroll(self.page().mainFrame(),
                                     editorPositionToSourceLineFunc,
                                     sourceLineToEditorPositionFunc)
        ReTextWebPreview.__init__(self, tab.editBox)

        self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
        self.page().linkClicked.connect(self._handleLinkClicked)
        self.settings().setAttribute(
            QWebSettings.LocalContentCanAccessFileUrls, False)
        # Avoid caching of CSS
        self.settings().setObjectCacheCapacities(0, 0, 0)

        self.cache = QNetworkDiskCache()
        cacheDirectory = QStandardPaths.writableLocation(
            QStandardPaths.CacheLocation)
        self.cache.setCacheDirectory(cacheDirectory)
        self.page().networkAccessManager().setCache(self.cache)
示例#33
0
 def __init__(self, vertical, parent=None):
     QWebView.__init__(self, parent)
     s = self.settings()
     s.setAttribute(s.JavascriptEnabled, False)
     self.vertical = vertical
     self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks)
     self.linkClicked.connect(self.link_activated)
     self._link_clicked = False
     self.setAttribute(Qt.WA_OpaquePaintEvent, False)
     palette = self.palette()
     self.setAcceptDrops(False)
     palette.setBrush(QPalette.Base, Qt.transparent)
     self.page().setPalette(palette)
     self.css = P('templates/book_details.css', data=True).decode('utf-8')
     for x, icon in [
         ('remove_format', 'trash.png'), ('save_format', 'save.png'),
         ('restore_format', 'edit-undo.png'), ('copy_link','edit-copy.png'),
         ('manage_author', 'user_profile.png'), ('compare_format', 'diff.png')]:
         ac = QAction(QIcon(I(icon)), '', self)
         ac.current_fmt = None
         ac.current_url = None
         ac.triggered.connect(getattr(self, '%s_triggerred'%x))
         setattr(self, '%s_action'%x, ac)
     self.setFocusPolicy(Qt.NoFocus)
示例#34
0
    def __init__(self, parent=None, debug=True):
        QWebView.__init__(self, parent=parent)

        cache = QNetworkDiskCache()
        cache.setCacheDirectory("cache")
        self.page().networkAccessManager().setCache(cache)
        self.page().networkAccessManager()

        if debug:
            QWebSettings.globalSettings().setAttribute(
                QWebSettings.DeveloperExtrasEnabled, True)

        self.initialized = False

        self.page().mainFrame().addToJavaScriptWindowObject("qtWidget", self)

        basePath = os.path.abspath(os.path.dirname(__file__))
        url = 'file://' + basePath + '/qOSM.html'
        self.load(QUrl(url))

        self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)

        self.loadFinished.connect(self.onLoadFinished)
        self.linkClicked.connect(QDesktopServices.openUrl)
示例#35
0
    def __init__(self, card, *args, **kwargs):
        QWebView.__init__(self, *args, **kwargs)

        self.card = card

        self.setHtml(card.content)
示例#36
0
    def __init__(self, parent=None):
        QWebView.__init__(self, parent)
        self.base_url = None
        self._parent = weakref.ref(parent)
        self.readonly = False

        self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)

        extra_shortcuts = {
            'ToggleBold': 'Bold',
            'ToggleItalic': 'Italic',
            'ToggleUnderline': 'Underline',
        }

        for wac, name, icon, text, checkable in [
            ('ToggleBold', 'bold', 'format-text-bold', _('Bold'), True),
            ('ToggleItalic', 'italic', 'format-text-italic', _('Italic'),
             True),
            ('ToggleUnderline', 'underline', 'format-text-underline',
             _('Underline'), True),
            ('ToggleStrikethrough', 'strikethrough',
             'format-text-strikethrough', _('Strikethrough'), True),
            ('ToggleSuperscript', 'superscript', 'format-text-superscript',
             _('Superscript'), True),
            ('ToggleSubscript', 'subscript', 'format-text-subscript',
             _('Subscript'), True),
            ('InsertOrderedList', 'ordered_list', 'format-list-ordered',
             _('Ordered list'), True),
            ('InsertUnorderedList', 'unordered_list', 'format-list-unordered',
             _('Unordered list'), True),
            ('AlignLeft', 'align_left', 'format-justify-left', _('Align left'),
             False),
            ('AlignCenter', 'align_center', 'format-justify-center',
             _('Align center'), False),
            ('AlignRight', 'align_right', 'format-justify-right',
             _('Align right'), False),
            ('AlignJustified', 'align_justified', 'format-justify-fill',
             _('Align justified'), False),
            ('Undo', 'undo', 'edit-undo', _('Undo'), False),
            ('Redo', 'redo', 'edit-redo', _('Redo'), False),
            ('RemoveFormat', 'remove_format', 'edit-clear',
             _('Remove formatting'), False),
            ('Copy', 'copy', 'edit-copy', _('Copy'), False),
            ('Paste', 'paste', 'edit-paste', _('Paste'), False),
            ('Cut', 'cut', 'edit-cut', _('Cut'), False),
            ('Indent', 'indent', 'format-indent-more',
             _('Increase indentation'), False),
            ('Outdent', 'outdent', 'format-indent-less',
             _('Decrease indentation'), False),
            ('SelectAll', 'select_all', 'edit-select-all', _('Select all'),
             False),
        ]:
            ac = PageAction(wac, icon, text, checkable, self)
            setattr(self, 'action_' + name, ac)
            ss = extra_shortcuts.get(wac, None)
            if ss:
                ac.setShortcut(QKeySequence(getattr(QKeySequence, ss)))
            if wac == 'RemoveFormat':
                ac.triggered.connect(self.remove_format_cleanup,
                                     type=Qt.QueuedConnection)

        self.action_color = QAction(QIcon(I('format-text-color.png')),
                                    _('Foreground color'), self)
        self.action_color.triggered.connect(self.foreground_color)

        self.action_background = QAction(QIcon(I('format-fill-color.png')),
                                         _('Background color'), self)
        self.action_background.triggered.connect(self.background_color)

        self.action_block_style = QAction(QIcon(I('format-text-heading.png')),
                                          _('Style text block'), self)
        self.action_block_style.setToolTip(_('Style the selected text block'))
        self.block_style_menu = QMenu(self)
        self.action_block_style.setMenu(self.block_style_menu)
        self.block_style_actions = []
        for text, name in [
            (_('Normal'), 'p'),
            (_('Heading') + ' 1', 'h1'),
            (_('Heading') + ' 2', 'h2'),
            (_('Heading') + ' 3', 'h3'),
            (_('Heading') + ' 4', 'h4'),
            (_('Heading') + ' 5', 'h5'),
            (_('Heading') + ' 6', 'h6'),
            (_('Pre-formatted'), 'pre'),
            (_('Blockquote'), 'blockquote'),
            (_('Address'), 'address'),
        ]:
            ac = BlockStyleAction(text, name, self)
            self.block_style_menu.addAction(ac)
            self.block_style_actions.append(ac)

        self.action_insert_link = QAction(QIcon(I('insert-link.png')),
                                          _('Insert link or image'), self)
        self.action_insert_hr = QAction(QIcon(I('format-text-hr.png')),
                                        _('Insert separator'), self)
        self.action_insert_link.triggered.connect(self.insert_link)
        self.action_insert_hr.triggered.connect(self.insert_hr)
        self.pageAction(QWebPage.ToggleBold).changed.connect(
            self.update_link_action)
        self.action_insert_link.setEnabled(False)
        self.action_insert_hr.setEnabled(False)
        self.action_clear = QAction(QIcon(I('trash.png')), _('Clear'), self)
        self.action_clear.triggered.connect(self.clear_text)

        self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
        self.page().linkClicked.connect(self.link_clicked)
        secure_web_page(self.page().settings())

        self.setHtml('')
        self.set_readonly(False)
        self.page().contentsChanged.connect(self.data_changed)
示例#37
0
 def __init__(self):
     # QWebView
     self.view = QWebView.__init__(self)
     # self.view.setPage(MyBrowser())
     self.setWindowTitle('Loading...')
     self.titleChanged.connect(self.adjustTitle)
示例#38
0
 def __init__(self):
     # QWebView
     self.view = QWebView.__init__(self)
     # self.view.setPage(MyBrowser())
     self.setWindowTitle('Loading...')
     self.titleChanged.connect(self.adjustTitle)
示例#39
0
 def __init__(self, book_info, parent=None):
     QWebView.__init__(self, parent)
     self.book_info = book_info
示例#40
0
 def __init__(self):
     self.app = QApplication(sys.argv)
     QWebView.__init__(self)
     self._loaded = False
     self.loadFinished.connect(self.load_finished)
示例#41
0
 def __init__(self):
     QWebView.__init__(self)
     self.loadFinished.connect(self._result_available)
示例#42
0
 def __init__(self, parent):
     QWebView.__init__(self)
     self.father = parent
     self.setStyleSheet("background: white;")
示例#43
0
    def __init__(self, parent=None):
        QWebView.__init__(self, parent)
        self._parent = weakref.ref(parent)
        self.readonly = False

        self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)

        extra_shortcuts = {
                'ToggleBold': 'Bold',
                'ToggleItalic': 'Italic',
                'ToggleUnderline': 'Underline',
        }

        for wac, name, icon, text, checkable in [
                ('ToggleBold', 'bold', 'format-text-bold', _('Bold'), True),
                ('ToggleItalic', 'italic', 'format-text-italic', _('Italic'),
                    True),
                ('ToggleUnderline', 'underline', 'format-text-underline',
                    _('Underline'), True),
                ('ToggleStrikethrough', 'strikethrough', 'format-text-strikethrough',
                    _('Strikethrough'), True),
                ('ToggleSuperscript', 'superscript', 'format-text-superscript',
                    _('Superscript'), True),
                ('ToggleSubscript', 'subscript', 'format-text-subscript',
                    _('Subscript'), True),
                ('InsertOrderedList', 'ordered_list', 'format-list-ordered',
                    _('Ordered list'), True),
                ('InsertUnorderedList', 'unordered_list', 'format-list-unordered',
                    _('Unordered list'), True),

                ('AlignLeft', 'align_left', 'format-justify-left',
                    _('Align left'), False),
                ('AlignCenter', 'align_center', 'format-justify-center',
                    _('Align center'), False),
                ('AlignRight', 'align_right', 'format-justify-right',
                    _('Align right'), False),
                ('AlignJustified', 'align_justified', 'format-justify-fill',
                    _('Align justified'), False),
                ('Undo', 'undo', 'edit-undo', _('Undo'), False),
                ('Redo', 'redo', 'edit-redo', _('Redo'), False),
                ('RemoveFormat', 'remove_format', 'trash', _('Remove formatting'), False),
                ('Copy', 'copy', 'edit-copy', _('Copy'), False),
                ('Paste', 'paste', 'edit-paste', _('Paste'), False),
                ('Cut', 'cut', 'edit-cut', _('Cut'), False),
                ('Indent', 'indent', 'format-indent-more',
                    _('Increase Indentation'), False),
                ('Outdent', 'outdent', 'format-indent-less',
                    _('Decrease Indentation'), False),
                ('SelectAll', 'select_all', 'edit-select-all',
                    _('Select all'), False),
            ]:
            ac = PageAction(wac, icon, text, checkable, self)
            setattr(self, 'action_'+name, ac)
            ss = extra_shortcuts.get(wac, None)
            if ss:
                ac.setShortcut(QKeySequence(getattr(QKeySequence, ss)))
            if wac == 'RemoveFormat':
                ac.triggered.connect(self.remove_format_cleanup,
                        type=Qt.QueuedConnection)

        self.action_color = QAction(QIcon(I('format-text-color.png')), _('Foreground color'),
                self)
        self.action_color.triggered.connect(self.foreground_color)

        self.action_background = QAction(QIcon(I('format-fill-color.png')),
                _('Background color'), self)
        self.action_background.triggered.connect(self.background_color)

        self.action_block_style = QAction(QIcon(I('format-text-heading.png')),
                _('Style text block'), self)
        self.action_block_style.setToolTip(
                _('Style the selected text block'))
        self.block_style_menu = QMenu(self)
        self.action_block_style.setMenu(self.block_style_menu)
        self.block_style_actions = []
        for text, name in [
                (_('Normal'), 'p'),
                (_('Heading') +' 1', 'h1'),
                (_('Heading') +' 2', 'h2'),
                (_('Heading') +' 3', 'h3'),
                (_('Heading') +' 4', 'h4'),
                (_('Heading') +' 5', 'h5'),
                (_('Heading') +' 6', 'h6'),
                (_('Pre-formatted'), 'pre'),
                (_('Blockquote'), 'blockquote'),
                (_('Address'), 'address'),
                ]:
            ac = BlockStyleAction(text, name, self)
            self.block_style_menu.addAction(ac)
            self.block_style_actions.append(ac)

        self.action_insert_link = QAction(QIcon(I('insert-link.png')),
                _('Insert link or image'), self)
        self.action_insert_link.triggered.connect(self.insert_link)
        self.pageAction(QWebPage.ToggleBold).changed.connect(self.update_link_action)
        self.action_insert_link.setEnabled(False)
        self.action_clear = QAction(QIcon(I('edit-clear.png')), _('Clear'), self)
        self.action_clear.triggered.connect(self.clear_text)

        self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
        self.page().linkClicked.connect(self.link_clicked)

        self.setHtml('')
        self.set_readonly(False)
示例#44
0
 def __init__(self):
     QWebView.__init__(self)
     self.loadFinished.connect(self._loadComplete)
示例#45
0
 def __init__(self, parent=None):
     QWebView.__init__(self, parent)
     self.settings = QWebSettings.globalSettings()
     self.settings.setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True)