78 ## maxMenuFilePathLen = 75 |
78 ## maxMenuFilePathLen = 75 |
79 ## |
79 ## |
80 _fromEric = False |
80 _fromEric = False |
81 UseQtHelp = QTHELP_AVAILABLE |
81 UseQtHelp = QTHELP_AVAILABLE |
82 |
82 |
|
83 _webProfile = None |
83 _networkManager = None |
84 _networkManager = None |
84 ## _cookieJar = None |
85 ## _cookieJar = None |
85 ## _helpEngine = None |
86 ## _helpEngine = None |
86 _bookmarksManager = None |
87 _bookmarksManager = None |
87 _historyManager = None |
88 _historyManager = None |
133 self.__eventKeyboardModifiers = Qt.NoModifier |
134 self.__eventKeyboardModifiers = Qt.NoModifier |
134 |
135 |
135 if self.__initShortcutsOnly: |
136 if self.__initShortcutsOnly: |
136 self.__initActions() |
137 self.__initActions() |
137 else: |
138 else: |
138 if self.isPrivate(): |
139 self.webProfile(private) |
139 self.__webProfile = QWebEngineProfile(self) |
140 ## if self.isPrivate(): |
140 else: |
141 ## self.__webProfile = QWebEngineProfile(self) |
141 self.__webProfile = QWebEngineProfile.defaultProfile() |
142 ## else: |
142 self.__webProfile.downloadRequested.connect( |
143 ## self.__webProfile = QWebEngineProfile.defaultProfile() |
143 self.__downloadRequested) |
144 ## self.__webProfile.downloadRequested.connect( |
144 |
145 ## self.__downloadRequested) |
145 # Setup QWebChannel user script |
146 ## |
146 script = QWebEngineScript() |
147 ## # Setup QWebChannel user script |
147 script.setName("_eric_webchannel") |
148 ## script = QWebEngineScript() |
148 script.setInjectionPoint(QWebEngineScript.DocumentCreation) |
149 ## script.setName("_eric_webchannel") |
149 script.setWorldId(QWebEngineScript.MainWorld) |
150 ## script.setInjectionPoint(QWebEngineScript.DocumentCreation) |
150 script.setRunsOnSubFrames(True) |
151 ## script.setWorldId(QWebEngineScript.MainWorld) |
151 script.setSourceCode(Scripts.setupWebChannel()) |
152 ## script.setRunsOnSubFrames(True) |
152 self.__webProfile.scripts().insert(script) |
153 ## script.setSourceCode(Scripts.setupWebChannel()) |
|
154 ## self.__webProfile.scripts().insert(script) |
153 |
155 |
154 from .SearchWidget import SearchWidget |
156 from .SearchWidget import SearchWidget |
155 # TODO: QtHelp |
157 # TODO: QtHelp |
156 ## from .HelpTocWidget import HelpTocWidget |
158 ## from .HelpTocWidget import HelpTocWidget |
157 ## from .HelpIndexWidget import HelpIndexWidget |
159 ## from .HelpIndexWidget import HelpIndexWidget |
258 self.restoreGeometry(g) |
260 self.restoreGeometry(g) |
259 |
261 |
260 self.__setIconDatabasePath() |
262 self.__setIconDatabasePath() |
261 self.__initWebEngineSettings() |
263 self.__initWebEngineSettings() |
262 |
264 |
|
265 self.passwordManager() |
|
266 |
263 self.__initActions() |
267 self.__initActions() |
264 self.__initMenus() |
268 self.__initMenus() |
265 self.__initToolbars() |
269 self.__initToolbars() |
266 |
270 |
267 ## self.historyManager() |
271 ## self.historyManager() |
4027 |
4031 |
4028 userStyle += WebBrowserTools.readAllFileContents(styleSheetFile)\ |
4032 userStyle += WebBrowserTools.readAllFileContents(styleSheetFile)\ |
4029 .replace("\n", "") |
4033 .replace("\n", "") |
4030 name = "_eric_userstylesheet" |
4034 name = "_eric_userstylesheet" |
4031 |
4035 |
4032 oldScript = self.__webProfile.scripts().findScript(name) |
4036 oldScript = self.webProfile().scripts().findScript(name) |
4033 if not oldScript.isNull(): |
4037 if not oldScript.isNull(): |
4034 self.__webProfile.scripts().remove(oldScript) |
4038 self.webProfile().scripts().remove(oldScript) |
4035 |
4039 |
4036 if userStyle: |
4040 if userStyle: |
4037 script = QWebEngineScript() |
4041 script = QWebEngineScript() |
4038 script.setName(name) |
4042 script.setName(name) |
4039 script.setInjectionPoint(QWebEngineScript.DocumentCreation) |
4043 script.setInjectionPoint(QWebEngineScript.DocumentCreation) |
4040 script.setWorldId(QWebEngineScript.ApplicationWorld) |
4044 script.setWorldId(QWebEngineScript.ApplicationWorld) |
4041 script.setRunsOnSubFrames(True) |
4045 script.setRunsOnSubFrames(True) |
4042 script.setSourceCode(Scripts.setStyleSheet(userStyle)) |
4046 script.setSourceCode(Scripts.setStyleSheet(userStyle)) |
4043 self.__webProfile.scripts().insert(script) |
4047 self.webProfile().scripts().insert(script) |
4044 |
4048 |
4045 ########################################## |
4049 ########################################## |
4046 ## Support for desktop notifications below |
4050 ## Support for desktop notifications below |
4047 ########################################## |
4051 ########################################## |
4048 |
4052 |
4086 |
4090 |
4087 ################################### |
4091 ################################### |
4088 ## Support for download files below |
4092 ## Support for download files below |
4089 ################################### |
4093 ################################### |
4090 |
4094 |
4091 def __downloadRequested(self, download): |
4095 @classmethod |
4092 """ |
4096 def downloadRequested(self, download): |
4093 Private slot to handle a download request. |
4097 """ |
|
4098 Class method to handle a download request. |
4094 |
4099 |
4095 @param download reference to the download data |
4100 @param download reference to the download data |
4096 @type QWebEngineDownloadItem |
4101 @type QWebEngineDownloadItem |
4097 """ |
4102 """ |
4098 pass |
4103 pass |
4099 # TODO: DownloadManager |
4104 # TODO: DownloadManager |
4100 ## self.downloadManager().download(download, mainWindow=self) |
4105 ## self.downloadManager().download(download, mainWindow=self) |
|
4106 |
|
4107 ######################################## |
|
4108 ## Support for web engine profiles below |
|
4109 ######################################## |
|
4110 |
|
4111 @classmethod |
|
4112 def webProfile(cls, private=False): |
|
4113 """ |
|
4114 Class method handling the web engine profile. |
|
4115 |
|
4116 @param private flag indicating the privacy mode |
|
4117 @type bool |
|
4118 @return reference to the web profile object |
|
4119 @rtype QWebEngineProfile |
|
4120 """ |
|
4121 if cls._webProfile is None: |
|
4122 if private: |
|
4123 cls._webProfile = QWebEngineProfile() |
|
4124 else: |
|
4125 cls._webProfile = QWebEngineProfile.defaultProfile() |
|
4126 cls._webProfile.downloadRequested.connect( |
|
4127 cls.downloadRequested) |
|
4128 |
|
4129 # Setup QWebChannel user script |
|
4130 script = QWebEngineScript() |
|
4131 script.setName("_eric_webchannel") |
|
4132 script.setInjectionPoint(QWebEngineScript.DocumentCreation) |
|
4133 script.setWorldId(QWebEngineScript.MainWorld) |
|
4134 script.setRunsOnSubFrames(True) |
|
4135 script.setSourceCode(Scripts.setupWebChannel()) |
|
4136 cls._webProfile.scripts().insert(script) |
|
4137 |
|
4138 return cls._webProfile |