WebBrowser/GreaseMonkey/GreaseMonkeyManager.py

branch
QtWebEngine
changeset 4886
b56735d36159
parent 4767
0bace7c5ebc9
child 4905
09f38f85a3af
equal deleted inserted replaced
4885:362360f9a979 4886:b56735d36159
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import os 12 import os
13 13
14 from PyQt5.QtCore import pyqtSignal, QObject, QTimer, QFile, QDir, QSettings 14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QObject, QTimer, QFile, QDir, \
15 QSettings, QMetaObject, QUrl, Q_ARG
15 16
16 import Utilities 17 import Utilities
17 import Preferences 18 import Preferences
18 19
19 from WebBrowser.WebBrowserWindow import WebBrowserWindow 20 from WebBrowser.WebBrowserWindow import WebBrowserWindow
39 self.__scripts = [] 40 self.__scripts = []
40 self.__downloaders = [] 41 self.__downloaders = []
41 42
42 self.__interceptor = GreaseMonkeyUrlInterceptor(self) 43 self.__interceptor = GreaseMonkeyUrlInterceptor(self)
43 WebBrowserWindow.networkManager().installUrlInterceptor( 44 WebBrowserWindow.networkManager().installUrlInterceptor(
44 self.__interceptor) 45 GreaseMonkeyUrlInterceptor(self))
45 46
46 QTimer.singleShot(0, self.__load) 47 QTimer.singleShot(0, self.__load)
47 48
48 def __del__(self): 49 def __del__(self):
49 """ 50 """
68 Public method to download a GreaseMonkey script. 69 Public method to download a GreaseMonkey script.
69 70
70 @param url URL to download script from 71 @param url URL to download script from
71 @type QUrl 72 @type QUrl
72 """ 73 """
74 QMetaObject.invokeMethod(
75 self, "doDownloadScript", Qt.QueuedConnection,
76 Q_ARG(QUrl, url))
77
78 @pyqtSlot(QUrl)
79 def doDownloadScript(self, url):
73 from .GreaseMonkeyDownloader import GreaseMonkeyDownloader 80 from .GreaseMonkeyDownloader import GreaseMonkeyDownloader
74 downloader = GreaseMonkeyDownloader(url, self) 81 downloader = GreaseMonkeyDownloader(url, self)
75 downloader.finished.connect(self.__downloaderFinished) 82 downloader.finished.connect(self.__downloaderFinished)
76 self.__downloaders.append(downloader) 83 self.__downloaders.append(downloader)
84 ##void GM_Manager::downloadScript(const QUrl &url)
85 ##{
86 ## QMetaObject::invokeMethod(this, "doDownloadScript", Qt::QueuedConnection, Q_ARG(QUrl, url));
87 ##}
88 ##void GM_Manager::doDownloadScript(const QUrl &url)
89 ##{
90 ## new GM_Downloader(url, this);
91 ##}
77 92
78 def __downloaderFinished(self): 93 def __downloaderFinished(self):
79 """ 94 """
80 Private slot to handle the completion of a script download. 95 Private slot to handle the completion of a script download.
81 """ 96 """

eric ide

mercurial