WebBrowser/JavaScript/ExternalJsObject.py

branch
QtWebEngine
changeset 4749
750577d35452
parent 4745
285bfd224a1b
child 4861
d419f153925d
equal deleted inserted replaced
4745:285bfd224a1b 4749:750577d35452
7 Module implementing the JavaScript external object being the endpoint of 7 Module implementing the JavaScript external object being the endpoint of
8 a web channel. 8 a web channel.
9 """ 9 """
10 10
11 # 11 #
12 # This code was ported from QupZilla. 12 # This code was ported from QupZilla and modified.
13 # Copyright (C) David Rosca <nowrep@gmail.com> 13 # Copyright (C) David Rosca <nowrep@gmail.com>
14 # 14 #
15 15
16 from __future__ import unicode_literals 16 from __future__ import unicode_literals
17 17
18 from PyQt5.QtCore import pyqtSlot, QObject, QUrl 18 from PyQt5.QtCore import pyqtSlot, QObject, QUrl, QByteArray
19
20 from .AutoFillJsObject import AutoFillJsObject
21 19
22 import WebBrowser.WebBrowserWindow 20 import WebBrowser.WebBrowserWindow
23 21
24 22
25 class ExternalJsObject(QObject): 23 class ExternalJsObject(QObject):
34 @type WebBrowserPage 32 @type WebBrowserPage
35 """ 33 """
36 super(ExternalJsObject, self).__init__(page) 34 super(ExternalJsObject, self).__init__(page)
37 35
38 self.__page = page 36 self.__page = page
39 self.__autoFill = AutoFillJsObject(self)
40 37
41 def page(self): 38 def page(self):
42 """ 39 """
43 Public method returning a reference to the web page object. 40 Public method returning a reference to the web page object.
44 41
60 57
61 # TODO: SpeedDial 58 # TODO: SpeedDial
62 ## return WebBrowser.WebBrowserWindow.WebBrowserWindow.speedDial() 59 ## return WebBrowser.WebBrowserWindow.WebBrowserWindow.speedDial()
63 return None 60 return None
64 61
65 @pyqtSlot(result=QObject)
66 def autoFill(self):
67 """
68 Public method returning a reference to the auto fill object.
69
70 @return reference to the auto fill object
71 @rtype AutoFillJsObject
72 """
73 return self.__autoFill
74
75 @pyqtSlot(str) 62 @pyqtSlot(str)
76 def AddSearchProvider(self, engineUrl): 63 def AddSearchProvider(self, engineUrl):
77 """ 64 """
78 Public slot to add a search provider. 65 Public slot to add a search provider.
79 66
80 @param engineUrl engineUrl of the XML file defining the search provider 67 @param engineUrl engineUrl of the XML file defining the search provider
81 @type str 68 @type str
82 """ 69 """
83 WebBrowser.WebBrowserWindow.WebBrowserWindow.openSearchManager()\ 70 WebBrowser.WebBrowserWindow.WebBrowserWindow.openSearchManager()\
84 .addEngine(QUrl(engineUrl)) 71 .addEngine(QUrl(engineUrl))
85 ## 72
86 ##int ExternalJsObject::IsSearchProviderInstalled(const QString &engineURL) 73 @pyqtSlot(str, str, str, QByteArray)
87 ##{ Slot 74 def formSubmitted(self, urlStr, userName, password, data):
88 ## qDebug() << "NOT IMPLEMENTED: IsSearchProviderInstalled()" << engineURL; 75 """
89 ## return 0; 76 Public slot passing form data to the password manager.
90 ##} 77
78 @param urlStr form submission URL
79 @type str
80 @param userName name of the user
81 @type str
82 @param password user password
83 @type str
84 @param data data to be submitted
85 @type QByteArray
86 """
87 import WebBrowser.WebBrowserWindow
88 WebBrowser.WebBrowserWindow.WebBrowserWindow.passwordManager()\
89 .formSubmitted(urlStr, userName, password, data,
90 self.page())

eric ide

mercurial