Tue, 23 Feb 2016 19:07:31 +0100
Continued porting the web browser.
- finished (momentarily) adding the GreaseMonkey stuff
--- a/WebBrowser/GreaseMonkey/GreaseMonkeyDownloader.py Mon Feb 22 19:57:58 2016 +0100 +++ b/WebBrowser/GreaseMonkey/GreaseMonkeyDownloader.py Tue Feb 23 19:07:31 2016 +0100 @@ -27,20 +27,21 @@ """ finished = pyqtSignal() - def __init__(self, request, manager): + def __init__(self, url, manager): """ Constructor - @param request reference to the request object (QNetworkRequest) + @param url URL to download script from + @type QUrl @param manager reference to the GreaseMonkey manager - (GreaseMonkeyManager) + @type GreaseMonkeyManager """ super(GreaseMonkeyDownloader, self).__init__() self.__manager = manager self.__reply = FollowRedirectReply( - request.url(), WebBrowserWindow.networkAccessManager()) + url, WebBrowserWindow.networkAccessManager()) self.__reply.finished.connect(self.__scriptDownloaded) self.__fileName = ""
--- a/WebBrowser/GreaseMonkey/GreaseMonkeyManager.py Mon Feb 22 19:57:58 2016 +0100 +++ b/WebBrowser/GreaseMonkey/GreaseMonkeyManager.py Tue Feb 23 19:07:31 2016 +0100 @@ -11,9 +11,7 @@ import os -from PyQt5.QtCore import pyqtSignal, QObject, QTimer, QFile, QDir, QSettings, \ - QUrl, QByteArray -from PyQt5.QtNetwork import QNetworkAccessManager +from PyQt5.QtCore import pyqtSignal, QObject, QTimer, QFile, QDir, QSettings import Utilities import Preferences @@ -22,6 +20,7 @@ from .GreaseMonkeyUrlInterceptor import GreaseMonkeyUrlInterceptor +# TODO: GreaseMonkey: needs testing with Qt 5.6 class GreaseMonkeyManager(QObject): """ Class implementing the manager for GreaseMonkey scripts. @@ -64,14 +63,15 @@ self.__configDiaolg = GreaseMonkeyConfigurationDialog(self, parent) self.__configDiaolg.show() - def downloadScript(self, request): + def downloadScript(self, url): """ Public method to download a GreaseMonkey script. - @param request reference to the request (QNetworkRequest) + @param url URL to download script from + @type QUrl """ from .GreaseMonkeyDownloader import GreaseMonkeyDownloader - downloader = GreaseMonkeyDownloader(request, self) + downloader = GreaseMonkeyDownloader(url, self) downloader.finished.connect(self.__downloaderFinished) self.__downloaders.append(downloader)
--- a/WebBrowser/GreaseMonkey/GreaseMonkeyUrlInterceptor.py Mon Feb 22 19:57:58 2016 +0100 +++ b/WebBrowser/GreaseMonkey/GreaseMonkeyUrlInterceptor.py Tue Feb 23 19:07:31 2016 +0100 @@ -3,31 +3,37 @@ # Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de> # +""" +Module implementing a handler for GreaseMonkey related URLs. +""" + from __future__ import unicode_literals -##class GM_UrlInterceptor : public UrlInterceptor -##{ -##public: -## explicit GM_UrlInterceptor(GM_Manager* manager); -## -## void interceptRequest(QWebEngineUrlRequestInfo &info); -## -##private: -## GM_Manager *m_manager; -## -##}; +from ..Network.UrlInterceptor import UrlInterceptor -##GM_UrlInterceptor::GM_UrlInterceptor(GM_Manager *manager) -## : UrlInterceptor(manager) -## , m_manager(manager) -##{ -##} -## -##void GM_UrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) -##{ -## if (info.requestUrl().toString().endsWith(QLatin1String(".user.js"))) { -## m_manager->downloadScript(info.requestUrl()); -## info.block(true); -## } -##} +class GreaseMonkeyUrlInterceptor(UrlInterceptor): + """ + Class implementing a handler for GreaseMonkey related URLs. + """ + def __init__(self, manager): + """ + Constructor + + @param manager reference to the GreaseMonkey manager + @type GreaseMonkeyManager + """ + super(GreaseMonkeyUrlInterceptor, self).__init__(manager) + + self.__manager = manager + + def interceptRequest(self, info): + """ + Public method to handle a GreaseMonkey request. + + @param info request info object + @type QWebEngineUrlRequestInfo + """ + if info.requestUrl().toString.endswith(".user.js"): + self.__manager.downloadScript(info.requestUrl()) + info.block(True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebBrowser/Network/UrlInterceptor.py Tue Feb 23 19:07:31 2016 +0100 @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing an URL interceptor base class. +""" + +from __future__ import unicode_literals + +from PyQt5.QtCore import QObject + +class UrlInterceptor(QObject): + """ + Class implementing an URL interceptor base class. + """ + def __init__(self, parent=None): + """ + Constructor + + @param parent referemce to the parent object + @type QObject + """ + super(UrlInterceptor, self).__init__(parent) + + def interceptRequest(self, info): + """ + Public method to intercept a request. + + @param info request info object + @type QWebEngineUrlRequestInfo + """ + pass
--- a/WebBrowser/WebBrowserView.py Mon Feb 22 19:57:58 2016 +0100 +++ b/WebBrowser/WebBrowserView.py Tue Feb 23 19:07:31 2016 +0100 @@ -144,8 +144,6 @@ self.__clickedFrame = None self.__mw.personalInformationManager().connectPage(self.page()) - # TODO: GreaseMonkey -## self.__mw.greaseMonkeyManager().connectPage(self.page()) # TODO: WebInspector ## self.__inspector = None
--- a/WebBrowser/WebBrowserWindow.py Mon Feb 22 19:57:58 2016 +0100 +++ b/WebBrowser/WebBrowserWindow.py Tue Feb 23 19:07:31 2016 +0100 @@ -94,7 +94,7 @@ ## _syncManager = None ## _speedDial = None _personalInformationManager = None -## _greaseMonkeyManager = None + _greaseMonkeyManager = None _notification = None _featurePermissionManager = None _flashCookieManager = None @@ -248,13 +248,15 @@ self.__setIconDatabasePath() self.__initWebEngineSettings() + # initialize some of our class objects self.passwordManager() + self.historyManager() + self.greaseMonkeyManager() self.__initActions() self.__initMenus() self.__initToolbars() - self.historyManager() # TODO: Sync ## syncMgr = self.syncManager() @@ -1322,24 +1324,23 @@ self.__showPersonalInformationDialog) self.__actions.append(self.personalDataAct) - # TODO: GreaseMonkey -## self.greaseMonkeyAct = E5Action( -## self.tr('GreaseMonkey Scripts'), -## UI.PixmapCache.getIcon("greaseMonkey.png"), -## self.tr('GreaseMonkey Scripts...'), -## 0, 0, -## self, 'webbrowser_greasemonkey') -## self.greaseMonkeyAct.setStatusTip(self.tr( -## 'Configure the GreaseMonkey Scripts')) -## self.greaseMonkeyAct.setWhatsThis(self.tr( -## """<b>GreaseMonkey Scripts...</b>""" -## """<p>Opens a dialog to configure the available GreaseMonkey""" -## """ Scripts.</p>""" -## )) -## if not self.__initShortcutsOnly: -## self.greaseMonkeyAct.triggered.connect( -## self.__showGreaseMonkeyConfigDialog) -## self.__actions.append(self.greaseMonkeyAct) + self.greaseMonkeyAct = E5Action( + self.tr('GreaseMonkey Scripts'), + UI.PixmapCache.getIcon("greaseMonkey.png"), + self.tr('GreaseMonkey Scripts...'), + 0, 0, + self, 'webbrowser_greasemonkey') + self.greaseMonkeyAct.setStatusTip(self.tr( + 'Configure the GreaseMonkey Scripts')) + self.greaseMonkeyAct.setWhatsThis(self.tr( + """<b>GreaseMonkey Scripts...</b>""" + """<p>Opens a dialog to configure the available GreaseMonkey""" + """ Scripts.</p>""" + )) + if not self.__initShortcutsOnly: + self.greaseMonkeyAct.triggered.connect( + self.__showGreaseMonkeyConfigDialog) + self.__actions.append(self.greaseMonkeyAct) self.editMessageFilterAct = E5Action( self.tr('Edit Message Filters'), @@ -1846,9 +1847,9 @@ menu.addAction(self.flashCookiesAct) ## menu.addAction(self.offlineStorageAct) menu.addAction(self.personalDataAct) -## menu.addAction(self.greaseMonkeyAct) + menu.addAction(self.greaseMonkeyAct) menu.addAction(self.featurePermissionAct) -## menu.addSeparator() + menu.addSeparator() menu.addAction(self.editMessageFilterAct) menu.addSeparator() menu.addAction(self.searchEnginesAct) @@ -1988,7 +1989,7 @@ settingstb.addAction(self.flashCookiesAct) ## settingstb.addAction(self.offlineStorageAct) settingstb.addAction(self.personalDataAct) -## settingstb.addAction(self.greaseMonkeyAct) + settingstb.addAction(self.greaseMonkeyAct) settingstb.addAction(self.featurePermissionAct) toolstb = self.addToolBar(self.tr("Tools")) @@ -3373,12 +3374,12 @@ """ self.personalInformationManager().showConfigurationDialog() -## def __showGreaseMonkeyConfigDialog(self): -## """ -## Private slot to show the GreaseMonkey scripts configuration dialog. -## """ -## self.greaseMonkeyManager().showConfigurationDialog() -## + def __showGreaseMonkeyConfigDialog(self): + """ + Private slot to show the GreaseMonkey scripts configuration dialog. + """ + self.greaseMonkeyManager().showConfigurationDialog() + def __showFeaturePermissionDialog(self): """ Private slot to show the feature permission dialog. @@ -3553,19 +3554,19 @@ return cls._personalInformationManager -## @classmethod -## def greaseMonkeyManager(cls): -## """ -## Class method to get a reference to the GreaseMonkey manager. -## -## @return reference to the GreaseMonkey manager (GreaseMonkeyManager) -## """ -## if cls._greaseMonkeyManager is None: -## from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager -## cls._greaseMonkeyManager = GreaseMonkeyManager() -## -## return cls._greaseMonkeyManager -## + @classmethod + def greaseMonkeyManager(cls): + """ + Class method to get a reference to the GreaseMonkey manager. + + @return reference to the GreaseMonkey manager (GreaseMonkeyManager) + """ + if cls._greaseMonkeyManager is None: + from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager + cls._greaseMonkeyManager = GreaseMonkeyManager() + + return cls._greaseMonkeyManager + @classmethod def featurePermissionManager(cls): """
--- a/eric6.e4p Mon Feb 22 19:57:58 2016 +0100 +++ b/eric6.e4p Tue Feb 23 19:07:31 2016 +0100 @@ -26,54 +26,6 @@ <Source>DataViews/PyCoverageDialog.py</Source> <Source>DataViews/PyProfileDialog.py</Source> <Source>DataViews/__init__.py</Source> - <Source>DebugClients/Python/AsyncFile.py</Source> - <Source>DebugClients/Python/AsyncIO.py</Source> - <Source>DebugClients/Python/DCTestResult.py</Source> - <Source>DebugClients/Python/DebugBase.py</Source> - <Source>DebugClients/Python/DebugClient.py</Source> - <Source>DebugClients/Python/DebugClientBase.py</Source> - <Source>DebugClients/Python/DebugClientCapabilities.py</Source> - <Source>DebugClients/Python/DebugClientThreads.py</Source> - <Source>DebugClients/Python/DebugConfig.py</Source> - <Source>DebugClients/Python/DebugProtocol.py</Source> - <Source>DebugClients/Python/DebugThread.py</Source> - <Source>DebugClients/Python/FlexCompleter.py</Source> - <Source>DebugClients/Python/PyProfile.py</Source> - <Source>DebugClients/Python/__init__.py</Source> - <Source>DebugClients/Python/coverage/__init__.py</Source> - <Source>DebugClients/Python/coverage/__main__.py</Source> - <Source>DebugClients/Python/coverage/annotate.py</Source> - <Source>DebugClients/Python/coverage/backunittest.py</Source> - <Source>DebugClients/Python/coverage/backward.py</Source> - <Source>DebugClients/Python/coverage/bytecode.py</Source> - <Source>DebugClients/Python/coverage/cmdline.py</Source> - <Source>DebugClients/Python/coverage/collector.py</Source> - <Source>DebugClients/Python/coverage/config.py</Source> - <Source>DebugClients/Python/coverage/control.py</Source> - <Source>DebugClients/Python/coverage/data.py</Source> - <Source>DebugClients/Python/coverage/debug.py</Source> - <Source>DebugClients/Python/coverage/env.py</Source> - <Source>DebugClients/Python/coverage/execfile.py</Source> - <Source>DebugClients/Python/coverage/files.py</Source> - <Source>DebugClients/Python/coverage/html.py</Source> - <Source>DebugClients/Python/coverage/misc.py</Source> - <Source>DebugClients/Python/coverage/monkey.py</Source> - <Source>DebugClients/Python/coverage/parser.py</Source> - <Source>DebugClients/Python/coverage/phystokens.py</Source> - <Source>DebugClients/Python/coverage/pickle2json.py</Source> - <Source>DebugClients/Python/coverage/plugin.py</Source> - <Source>DebugClients/Python/coverage/plugin_support.py</Source> - <Source>DebugClients/Python/coverage/python.py</Source> - <Source>DebugClients/Python/coverage/pytracer.py</Source> - <Source>DebugClients/Python/coverage/report.py</Source> - <Source>DebugClients/Python/coverage/results.py</Source> - <Source>DebugClients/Python/coverage/summary.py</Source> - <Source>DebugClients/Python/coverage/templite.py</Source> - <Source>DebugClients/Python/coverage/test_helpers.py</Source> - <Source>DebugClients/Python/coverage/version.py</Source> - <Source>DebugClients/Python/coverage/xmlreport.py</Source> - <Source>DebugClients/Python/eric6dbgstub.py</Source> - <Source>DebugClients/Python/getpass.py</Source> <Source>DebugClients/Python3/AsyncFile.py</Source> <Source>DebugClients/Python3/AsyncIO.py</Source> <Source>DebugClients/Python3/DCTestResult.py</Source> @@ -123,6 +75,54 @@ <Source>DebugClients/Python3/coverage/xmlreport.py</Source> <Source>DebugClients/Python3/eric6dbgstub.py</Source> <Source>DebugClients/Python3/getpass.py</Source> + <Source>DebugClients/Python/AsyncFile.py</Source> + <Source>DebugClients/Python/AsyncIO.py</Source> + <Source>DebugClients/Python/DCTestResult.py</Source> + <Source>DebugClients/Python/DebugBase.py</Source> + <Source>DebugClients/Python/DebugClient.py</Source> + <Source>DebugClients/Python/DebugClientBase.py</Source> + <Source>DebugClients/Python/DebugClientCapabilities.py</Source> + <Source>DebugClients/Python/DebugClientThreads.py</Source> + <Source>DebugClients/Python/DebugConfig.py</Source> + <Source>DebugClients/Python/DebugProtocol.py</Source> + <Source>DebugClients/Python/DebugThread.py</Source> + <Source>DebugClients/Python/FlexCompleter.py</Source> + <Source>DebugClients/Python/PyProfile.py</Source> + <Source>DebugClients/Python/__init__.py</Source> + <Source>DebugClients/Python/coverage/__init__.py</Source> + <Source>DebugClients/Python/coverage/__main__.py</Source> + <Source>DebugClients/Python/coverage/annotate.py</Source> + <Source>DebugClients/Python/coverage/backunittest.py</Source> + <Source>DebugClients/Python/coverage/backward.py</Source> + <Source>DebugClients/Python/coverage/bytecode.py</Source> + <Source>DebugClients/Python/coverage/cmdline.py</Source> + <Source>DebugClients/Python/coverage/collector.py</Source> + <Source>DebugClients/Python/coverage/config.py</Source> + <Source>DebugClients/Python/coverage/control.py</Source> + <Source>DebugClients/Python/coverage/data.py</Source> + <Source>DebugClients/Python/coverage/debug.py</Source> + <Source>DebugClients/Python/coverage/env.py</Source> + <Source>DebugClients/Python/coverage/execfile.py</Source> + <Source>DebugClients/Python/coverage/files.py</Source> + <Source>DebugClients/Python/coverage/html.py</Source> + <Source>DebugClients/Python/coverage/misc.py</Source> + <Source>DebugClients/Python/coverage/monkey.py</Source> + <Source>DebugClients/Python/coverage/parser.py</Source> + <Source>DebugClients/Python/coverage/phystokens.py</Source> + <Source>DebugClients/Python/coverage/pickle2json.py</Source> + <Source>DebugClients/Python/coverage/plugin.py</Source> + <Source>DebugClients/Python/coverage/plugin_support.py</Source> + <Source>DebugClients/Python/coverage/python.py</Source> + <Source>DebugClients/Python/coverage/pytracer.py</Source> + <Source>DebugClients/Python/coverage/report.py</Source> + <Source>DebugClients/Python/coverage/results.py</Source> + <Source>DebugClients/Python/coverage/summary.py</Source> + <Source>DebugClients/Python/coverage/templite.py</Source> + <Source>DebugClients/Python/coverage/test_helpers.py</Source> + <Source>DebugClients/Python/coverage/version.py</Source> + <Source>DebugClients/Python/coverage/xmlreport.py</Source> + <Source>DebugClients/Python/eric6dbgstub.py</Source> + <Source>DebugClients/Python/getpass.py</Source> <Source>DebugClients/__init__.py</Source> <Source>Debugger/BreakPointModel.py</Source> <Source>Debugger/BreakPointViewer.py</Source> @@ -1330,6 +1330,7 @@ <Source>WebBrowser/Network/FollowRedirectReply.py</Source> <Source>WebBrowser/Network/LoadRequest.py</Source> <Source>WebBrowser/Network/NetworkManager.py</Source> + <Source>WebBrowser/Network/UrlInterceptor.py</Source> <Source>WebBrowser/Network/__init__.py</Source> <Source>WebBrowser/OpenSearch/DefaultSearchEngines/DefaultSearchEngines_rc.py</Source> <Source>WebBrowser/OpenSearch/DefaultSearchEngines/__init__.py</Source> @@ -1846,14 +1847,14 @@ <Interfaces/> <Others> <Other>.hgignore</Other> - <Other>APIs/Python/zope-2.10.7.api</Other> - <Other>APIs/Python/zope-2.11.2.api</Other> - <Other>APIs/Python/zope-3.3.1.api</Other> <Other>APIs/Python3/PyQt4.bas</Other> <Other>APIs/Python3/PyQt5.bas</Other> <Other>APIs/Python3/QScintilla2.bas</Other> <Other>APIs/Python3/eric6.api</Other> <Other>APIs/Python3/eric6.bas</Other> + <Other>APIs/Python/zope-2.10.7.api</Other> + <Other>APIs/Python/zope-2.11.2.api</Other> + <Other>APIs/Python/zope-3.3.1.api</Other> <Other>APIs/QSS/qss.api</Other> <Other>APIs/Ruby/Ruby-1.8.7.api</Other> <Other>APIs/Ruby/Ruby-1.8.7.bas</Other> @@ -1862,8 +1863,8 @@ <Other>CSSs</Other> <Other>CodeTemplates</Other> <Other>DTDs</Other> + <Other>DebugClients/Python3/coverage/doc</Other> <Other>DebugClients/Python/coverage/doc</Other> - <Other>DebugClients/Python3/coverage/doc</Other> <Other>DesignerTemplates</Other> <Other>Dictionaries</Other> <Other>Documentation/Help</Other>