135 |
135 |
136 if self.__initShortcutsOnly: |
136 if self.__initShortcutsOnly: |
137 self.__initActions() |
137 self.__initActions() |
138 else: |
138 else: |
139 self.webProfile(private) |
139 self.webProfile(private) |
140 ## if self.isPrivate(): |
|
141 ## self.__webProfile = QWebEngineProfile(self) |
|
142 ## else: |
|
143 ## self.__webProfile = QWebEngineProfile.defaultProfile() |
|
144 ## self.__webProfile.downloadRequested.connect( |
|
145 ## self.__downloadRequested) |
|
146 ## |
|
147 ## # Setup QWebChannel user script |
|
148 ## script = QWebEngineScript() |
|
149 ## script.setName("_eric_webchannel") |
|
150 ## script.setInjectionPoint(QWebEngineScript.DocumentCreation) |
|
151 ## script.setWorldId(QWebEngineScript.MainWorld) |
|
152 ## script.setRunsOnSubFrames(True) |
|
153 ## script.setSourceCode(Scripts.setupWebChannel()) |
|
154 ## self.__webProfile.scripts().insert(script) |
|
155 |
140 |
156 from .SearchWidget import SearchWidget |
141 from .SearchWidget import SearchWidget |
157 # TODO: QtHelp |
142 # TODO: QtHelp |
158 ## from .HelpTocWidget import HelpTocWidget |
143 ## from .HelpTocWidget import HelpTocWidget |
159 ## from .HelpIndexWidget import HelpIndexWidget |
144 ## from .HelpIndexWidget import HelpIndexWidget |
160 ## from .HelpSearchWidget import HelpSearchWidget |
145 ## from .HelpSearchWidget import HelpSearchWidget |
161 from .WebBrowserView import WebBrowserView |
146 from .WebBrowserView import WebBrowserView |
162 from .WebBrowserTabWidget import WebBrowserTabWidget |
147 from .WebBrowserTabWidget import WebBrowserTabWidget |
163 # TODO: AdBlock |
148 # TODO: AdBlock |
164 ## from .AdBlock.AdBlockIcon import AdBlockIcon |
149 ## from .AdBlock.AdBlockIcon import AdBlockIcon |
165 # TODO: VirusTotal |
150 from .VirusTotal.VirusTotalApi import VirusTotalAPI |
166 ## from .VirusTotal.VirusTotalApi import VirusTotalAPI |
|
167 |
151 |
168 # TODO: allow using Qt Help even if not called from eric6 |
152 # TODO: allow using Qt Help even if not called from eric6 |
169 WebBrowserWindow.setUseQtHelp(self.__fromEric) |
153 WebBrowserWindow.setUseQtHelp(self.__fromEric) |
170 |
154 |
171 if not self.__fromEric: |
155 if not self.__fromEric: |
266 |
250 |
267 self.__initActions() |
251 self.__initActions() |
268 self.__initMenus() |
252 self.__initMenus() |
269 self.__initToolbars() |
253 self.__initToolbars() |
270 |
254 |
271 ## self.historyManager() |
255 self.historyManager() |
272 ## |
256 |
|
257 # TODO: Sync |
273 ## syncMgr = self.syncManager() |
258 ## syncMgr = self.syncManager() |
274 ## syncMgr.syncMessage.connect(self.statusBar().showMessage) |
259 ## syncMgr.syncMessage.connect(self.statusBar().showMessage) |
275 ## syncMgr.syncError.connect(self.statusBar().showMessage) |
260 ## syncMgr.syncError.connect(self.statusBar().showMessage) |
276 ## |
261 ## |
277 self.__tabWidget.newBrowser(home) |
262 self.__tabWidget.newBrowser(home) |
278 self.__tabWidget.currentBrowser().setFocus() |
263 self.__tabWidget.currentBrowser().setFocus() |
279 |
264 |
280 WebBrowserWindow.BrowserWindows.append(self) |
265 WebBrowserWindow.BrowserWindows.append(self) |
281 |
266 |
|
267 # TODO: AdBlock |
282 ## self.__adBlockIcon = AdBlockIcon(self) |
268 ## self.__adBlockIcon = AdBlockIcon(self) |
283 ## self.statusBar().addPermanentWidget(self.__adBlockIcon) |
269 ## self.statusBar().addPermanentWidget(self.__adBlockIcon) |
284 ## self.__adBlockIcon.setEnabled( |
270 ## self.__adBlockIcon.setEnabled( |
285 ## Preferences.getWebBrowser("AdBlockEnabled")) |
271 ## Preferences.getWebBrowser("AdBlockEnabled")) |
286 ## self.__tabWidget.currentChanged[int].connect( |
272 ## self.__tabWidget.currentChanged[int].connect( |
287 ## self.__adBlockIcon.currentChanged) |
273 ## self.__adBlockIcon.currentChanged) |
288 ## self.__tabWidget.sourceChanged.connect( |
274 ## self.__tabWidget.sourceChanged.connect( |
289 ## self.__adBlockIcon.sourceChanged) |
275 ## self.__adBlockIcon.sourceChanged) |
290 ## |
276 ## |
291 ## self.networkIcon = E5NetworkIcon(self) |
277 self.networkIcon = E5NetworkIcon(self) |
292 ## self.statusBar().addPermanentWidget(self.networkIcon) |
278 self.statusBar().addPermanentWidget(self.networkIcon) |
293 ## |
279 |
294 QDesktopServices.setUrlHandler("http", self.__linkActivated) |
280 QDesktopServices.setUrlHandler("http", self.__linkActivated) |
295 QDesktopServices.setUrlHandler("https", self.__linkActivated) |
281 QDesktopServices.setUrlHandler("https", self.__linkActivated) |
296 |
282 |
297 # setup connections |
283 # setup connections |
298 self.__activating = False |
284 self.__activating = False |
315 ## self.__activateCurrentBrowser) |
301 ## self.__activateCurrentBrowser) |
316 |
302 |
317 state = Preferences.getWebBrowser("WebBrowserState") |
303 state = Preferences.getWebBrowser("WebBrowserState") |
318 self.restoreState(state) |
304 self.restoreState(state) |
319 |
305 |
|
306 # TODO: QtHelp |
320 ## self.__initHelpDb() |
307 ## self.__initHelpDb() |
321 |
308 |
322 ## self.__virusTotal = VirusTotalAPI(self) |
309 self.__virusTotal = VirusTotalAPI(self) |
323 ## self.__virusTotal.submitUrlError.connect( |
310 self.__virusTotal.submitUrlError.connect( |
324 ## self.__virusTotalSubmitUrlError) |
311 self.__virusTotalSubmitUrlError) |
325 ## self.__virusTotal.urlScanReport.connect( |
312 self.__virusTotal.urlScanReport.connect( |
326 ## self.__virusTotalUrlScanReport) |
313 self.__virusTotalUrlScanReport) |
327 ## self.__virusTotal.fileScanReport.connect( |
314 self.__virusTotal.fileScanReport.connect( |
328 ## self.__virusTotalFileScanReport) |
315 self.__virusTotalFileScanReport) |
329 ## |
316 |
330 self.__previewer = None |
317 self.__previewer = None |
331 self.__shutdownCalled = False |
318 self.__shutdownCalled = False |
332 |
319 |
333 ## self.flashCookieManager() |
320 self.flashCookieManager() |
334 ## |
321 |
335 # TODO: QtHelp, do these once Qt 5.6 is available |
322 # TODO: QtHelp, do these once Qt 5.6 is available |
336 ## if WebBrowserWindow.UseQtHelp: |
323 ## if WebBrowserWindow.UseQtHelp: |
337 ## QTimer.singleShot(0, self.__lookForNewDocumentation) |
324 ## QTimer.singleShot(0, self.__lookForNewDocumentation) |
338 ## if self.__searchWord is not None: |
325 ## if self.__searchWord is not None: |
339 ## QTimer.singleShot(0, self.__searchForWord) |
326 ## QTimer.singleShot(0, self.__searchForWord) |
340 ## |
327 ## |
341 self.__lastActiveWindow = None |
328 self.__lastActiveWindow = None |
342 e5App().focusChanged[QWidget, QWidget].connect( |
329 e5App().focusChanged[QWidget, QWidget].connect( |
343 self.__appFocusChanged) |
330 self.__appFocusChanged) |
|
331 #TODO: Sync |
344 ## |
332 ## |
345 ## QTimer.singleShot(0, syncMgr.loadSettings) |
333 ## QTimer.singleShot(0, syncMgr.loadSettings) |
346 |
334 |
347 def __del__(self): |
335 def __del__(self): |
348 """ |
336 """ |
1881 ## self.__userAgentMenu = UserAgentMenu(self.tr("Global User Agent")) |
1871 ## self.__userAgentMenu = UserAgentMenu(self.tr("Global User Agent")) |
1882 ## menu.addMenu(self.__userAgentMenu) |
1872 ## menu.addMenu(self.__userAgentMenu) |
1883 ## menu.addAction(self.userAgentManagerAct) |
1873 ## menu.addAction(self.userAgentManagerAct) |
1884 ## menu.addSeparator() |
1874 ## menu.addSeparator() |
1885 |
1875 |
|
1876 # TODO: QtHelp |
1886 ## if WebBrowserWindow.UseQtHelp: |
1877 ## if WebBrowserWindow.UseQtHelp: |
1887 ## menu.addAction(self.manageQtHelpDocsAct) |
1878 ## menu.addAction(self.manageQtHelpDocsAct) |
1888 ## menu.addAction(self.manageQtHelpFiltersAct) |
1879 ## menu.addAction(self.manageQtHelpFiltersAct) |
1889 ## menu.addAction(self.reindexDocumentationAct) |
1880 ## menu.addAction(self.reindexDocumentationAct) |
1890 ## menu.addSeparator() |
1881 ## menu.addSeparator() |
1891 menu.addAction(self.clearPrivateDataAct) |
1882 menu.addAction(self.clearPrivateDataAct) |
1892 menu.addAction(self.clearIconsAct) |
1883 menu.addAction(self.clearIconsAct) |
1893 |
1884 |
1894 ## menu = mb.addMenu(self.tr("&Tools")) |
1885 menu = mb.addMenu(self.tr("&Tools")) |
1895 ## menu.setTearOffEnabled(True) |
1886 menu.setTearOffEnabled(True) |
1896 ## menu.addAction(self.feedsManagerAct) |
1887 ## menu.addAction(self.feedsManagerAct) |
1897 ## menu.addAction(self.siteInfoAct) |
1888 ## menu.addAction(self.siteInfoAct) |
1898 ## menu.addSeparator() |
1889 ## menu.addSeparator() |
1899 ## menu.addAction(self.synchronizationAct) |
1890 ## menu.addAction(self.synchronizationAct) |
1900 ## menu.addSeparator() |
1891 ## menu.addSeparator() |
2065 self.bookmarksToolBar.openUrl.connect(self.openUrl) |
2057 self.bookmarksToolBar.openUrl.connect(self.openUrl) |
2066 self.bookmarksToolBar.newUrl.connect(self.openUrlNewTab) |
2058 self.bookmarksToolBar.newUrl.connect(self.openUrlNewTab) |
2067 self.addToolBarBreak() |
2059 self.addToolBarBreak() |
2068 self.addToolBar(self.bookmarksToolBar) |
2060 self.addToolBar(self.bookmarksToolBar) |
2069 |
2061 |
2070 ## self.addToolBarBreak() |
2062 self.addToolBarBreak() |
2071 ## vttb = self.addToolBar(self.tr("VirusTotal")) |
2063 vttb = self.addToolBar(self.tr("VirusTotal")) |
2072 ## vttb.setObjectName("VirusTotalToolBar") |
2064 vttb.setObjectName("VirusTotalToolBar") |
2073 ## vttb.setIconSize(UI.Config.ToolBarIconSize) |
2065 vttb.setIconSize(UI.Config.ToolBarIconSize) |
2074 ## vttb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) |
2066 vttb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) |
2075 ## self.virustotalScanCurrentAct = vttb.addAction( |
2067 self.virustotalScanCurrentAct = vttb.addAction( |
2076 ## UI.PixmapCache.getIcon("virustotal.png"), |
2068 UI.PixmapCache.getIcon("virustotal.png"), |
2077 ## self.tr("Scan current site"), |
2069 self.tr("Scan current site"), |
2078 ## self.__virusTotalScanCurrentSite) |
2070 self.__virusTotalScanCurrentSite) |
2079 ## self.virustotalIpReportAct = vttb.addAction( |
2071 self.virustotalIpReportAct = vttb.addAction( |
2080 ## UI.PixmapCache.getIcon("virustotal.png"), |
2072 UI.PixmapCache.getIcon("virustotal.png"), |
2081 ## self.tr("IP Address Report"), |
2073 self.tr("IP Address Report"), |
2082 ## self.__virusTotalIpAddressReport) |
2074 self.__virusTotalIpAddressReport) |
2083 ## self.virustotalDomainReportAct = vttb.addAction( |
2075 self.virustotalDomainReportAct = vttb.addAction( |
2084 ## UI.PixmapCache.getIcon("virustotal.png"), |
2076 UI.PixmapCache.getIcon("virustotal.png"), |
2085 ## self.tr("Domain Report"), |
2077 self.tr("Domain Report"), |
2086 ## self.__virusTotalDomainReport) |
2078 self.__virusTotalDomainReport) |
2087 ## if not Preferences.getWebBrowser("VirusTotalEnabled") or \ |
2079 if not Preferences.getWebBrowser("VirusTotalEnabled") or \ |
2088 ## Preferences.getWebBrowser("VirusTotalServiceKey") == "": |
2080 Preferences.getWebBrowser("VirusTotalServiceKey") == "": |
2089 ## self.virustotalScanCurrentAct.setEnabled(False) |
2081 self.virustotalScanCurrentAct.setEnabled(False) |
2090 ## self.virustotalIpReportAct.setEnabled(False) |
2082 self.virustotalIpReportAct.setEnabled(False) |
2091 ## self.virustotalDomainReportAct.setEnabled(False) |
2083 self.virustotalDomainReportAct.setEnabled(False) |
2092 |
2084 |
2093 def __nextTab(self): |
2085 def __nextTab(self): |
2094 """ |
2086 """ |
2095 Private slot used to show the next tab. |
2087 Private slot used to show the next tab. |
2096 """ |
2088 """ |
2801 |
2795 |
2802 self.__tabWidget.preferencesChanged() |
2796 self.__tabWidget.preferencesChanged() |
2803 |
2797 |
2804 self.searchEdit.preferencesChanged() |
2798 self.searchEdit.preferencesChanged() |
2805 |
2799 |
2806 # TODO: VirusTotal |
2800 self.__virusTotal.preferencesChanged() |
2807 ## self.__virusTotal.preferencesChanged() |
2801 if not Preferences.getWebBrowser("VirusTotalEnabled") or \ |
2808 ## if not Preferences.getWebBrowser("VirusTotalEnabled") or \ |
2802 Preferences.getWebBrowser("VirusTotalServiceKey") == "": |
2809 ## Preferences.getWebBrowser("VirusTotalServiceKey") == "": |
2803 self.virustotalScanCurrentAct.setEnabled(False) |
2810 ## self.virustotalScanCurrentAct.setEnabled(False) |
2804 self.virustotalIpReportAct.setEnabled(False) |
2811 ## self.virustotalIpReportAct.setEnabled(False) |
2805 self.virustotalDomainReportAct.setEnabled(False) |
2812 ## self.virustotalDomainReportAct.setEnabled(False) |
2806 else: |
2813 ## else: |
2807 self.virustotalScanCurrentAct.setEnabled(True) |
2814 ## self.virustotalScanCurrentAct.setEnabled(True) |
2808 self.virustotalIpReportAct.setEnabled(True) |
2815 ## self.virustotalIpReportAct.setEnabled(True) |
2809 self.virustotalDomainReportAct.setEnabled(True) |
2816 ## self.virustotalDomainReportAct.setEnabled(True) |
|
2817 |
2810 |
2818 def masterPasswordChanged(self, oldPassword, newPassword): |
2811 def masterPasswordChanged(self, oldPassword, newPassword): |
2819 """ |
2812 """ |
2820 Public slot to handle the change of the master password. |
2813 Public slot to handle the change of the master password. |
2821 |
2814 |
3900 if evt.modifiers() == Qt.KeyboardModifiers(Qt.AltModifier): |
3901 if evt.modifiers() == Qt.KeyboardModifiers(Qt.AltModifier): |
3901 if number == 10: |
3902 if number == 10: |
3902 number = self.__tabWidget.count() |
3903 number = self.__tabWidget.count() |
3903 self.__tabWidget.setCurrentIndex(number - 1) |
3904 self.__tabWidget.setCurrentIndex(number - 1) |
3904 return |
3905 return |
|
3906 # TODO: SpeeedDial |
3905 ## |
3907 ## |
3906 ## if evt.modifiers() == Qt.KeyboardModifiers(Qt.MetaModifier): |
3908 ## if evt.modifiers() == Qt.KeyboardModifiers(Qt.MetaModifier): |
3907 ## url = self.speedDial().urlForShortcut(number - 1) |
3909 ## url = self.speedDial().urlForShortcut(number - 1) |
3908 ## if url.isValid(): |
3910 ## if url.isValid(): |
3909 ## self.__linkActivated(url) |
3911 ## self.__linkActivated(url) |
3910 ## return |
3912 ## return |
3911 |
3913 |
3912 super(WebBrowserWindow, self).keyPressEvent(evt) |
3914 super(WebBrowserWindow, self).keyPressEvent(evt) |
3913 |
3915 |
3914 ## ########################################################################### |
3916 ########################################################################### |
3915 ## ## Interface to VirusTotal below ## |
3917 ## Interface to VirusTotal below ## |
3916 ## ########################################################################### |
3918 ########################################################################### |
3917 ## |
3919 |
3918 ## def __virusTotalScanCurrentSite(self): |
3920 def __virusTotalScanCurrentSite(self): |
3919 ## """ |
3921 """ |
3920 ## Private slot to ask VirusTotal for a scan of the URL of the current |
3922 Private slot to ask VirusTotal for a scan of the URL of the current |
3921 ## browser. |
3923 browser. |
3922 ## """ |
3924 """ |
3923 ## cb = self.currentBrowser() |
3925 cb = self.currentBrowser() |
3924 ## if cb is not None: |
3926 if cb is not None: |
3925 ## url = cb.url() |
3927 url = cb.url() |
3926 ## if url.scheme() in ["http", "https", "ftp"]: |
3928 if url.scheme() in ["http", "https", "ftp"]: |
3927 ## self.requestVirusTotalScan(url) |
3929 self.requestVirusTotalScan(url) |
3928 ## |
3930 |
3929 ## def requestVirusTotalScan(self, url): |
3931 def requestVirusTotalScan(self, url): |
3930 ## """ |
3932 """ |
3931 ## Public method to submit a request to scan an URL by VirusTotal. |
3933 Public method to submit a request to scan an URL by VirusTotal. |
3932 ## |
3934 |
3933 ## @param url URL to be scanned (QUrl) |
3935 @param url URL to be scanned (QUrl) |
3934 ## """ |
3936 """ |
3935 ## self.__virusTotal.submitUrl(url) |
3937 self.__virusTotal.submitUrl(url) |
3936 ## |
3938 |
3937 ## def __virusTotalSubmitUrlError(self, msg): |
3939 def __virusTotalSubmitUrlError(self, msg): |
3938 ## """ |
3940 """ |
3939 ## Private slot to handle an URL scan submission error. |
3941 Private slot to handle an URL scan submission error. |
3940 ## |
3942 |
3941 ## @param msg error message (str) |
3943 @param msg error message (str) |
3942 ## """ |
3944 """ |
3943 ## E5MessageBox.critical( |
3945 E5MessageBox.critical( |
3944 ## self, |
3946 self, |
3945 ## self.tr("VirusTotal Scan"), |
3947 self.tr("VirusTotal Scan"), |
3946 ## self.tr("""<p>The VirusTotal scan could not be""" |
3948 self.tr("""<p>The VirusTotal scan could not be""" |
3947 ## """ scheduled.<p>\n<p>Reason: {0}</p>""").format(msg)) |
3949 """ scheduled.<p>\n<p>Reason: {0}</p>""").format(msg)) |
3948 ## |
3950 |
3949 ## def __virusTotalUrlScanReport(self, url): |
3951 def __virusTotalUrlScanReport(self, url): |
3950 ## """ |
3952 """ |
3951 ## Private slot to initiate the display of the URL scan report page. |
3953 Private slot to initiate the display of the URL scan report page. |
3952 ## |
3954 |
3953 ## @param url URL of the URL scan report page (string) |
3955 @param url URL of the URL scan report page (string) |
3954 ## """ |
3956 """ |
3955 ## self.newTab(url) |
3957 self.newTab(url) |
3956 ## |
3958 |
3957 ## def __virusTotalFileScanReport(self, url): |
3959 def __virusTotalFileScanReport(self, url): |
3958 ## """ |
3960 """ |
3959 ## Private slot to initiate the display of the file scan report page. |
3961 Private slot to initiate the display of the file scan report page. |
3960 ## |
3962 |
3961 ## @param url URL of the file scan report page (string) |
3963 @param url URL of the file scan report page (string) |
3962 ## """ |
3964 """ |
3963 ## self.newTab(url) |
3965 self.newTab(url) |
3964 ## |
3966 |
3965 ## def __virusTotalIpAddressReport(self): |
3967 def __virusTotalIpAddressReport(self): |
3966 ## """ |
3968 """ |
3967 ## Private slot to retrieve an IP address report. |
3969 Private slot to retrieve an IP address report. |
3968 ## """ |
3970 """ |
3969 ## ip, ok = QInputDialog.getText( |
3971 ip, ok = QInputDialog.getText( |
3970 ## self, |
3972 self, |
3971 ## self.tr("IP Address Report"), |
3973 self.tr("IP Address Report"), |
3972 ## self.tr("Enter a valid IPv4 address in dotted quad notation:"), |
3974 self.tr("Enter a valid IPv4 address in dotted quad notation:"), |
3973 ## QLineEdit.Normal) |
3975 QLineEdit.Normal) |
3974 ## if ok and ip: |
3976 if ok and ip: |
3975 ## if ip.count(".") == 3: |
3977 if ip.count(".") == 3: |
3976 ## self.__virusTotal.getIpAddressReport(ip) |
3978 self.__virusTotal.getIpAddressReport(ip) |
3977 ## else: |
3979 else: |
3978 ## E5MessageBox.information( |
3980 E5MessageBox.information( |
3979 ## self, |
3981 self, |
3980 ## self.tr("IP Address Report"), |
3982 self.tr("IP Address Report"), |
3981 ## self.tr("""The given IP address is not in dotted quad""" |
3983 self.tr("""The given IP address is not in dotted quad""" |
3982 ## """ notation.""")) |
3984 """ notation.""")) |
3983 ## |
3985 |
3984 ## def __virusTotalDomainReport(self): |
3986 def __virusTotalDomainReport(self): |
3985 ## """ |
3987 """ |
3986 ## Private slot to retrieve a domain report. |
3988 Private slot to retrieve a domain report. |
3987 ## """ |
3989 """ |
3988 ## domain, ok = QInputDialog.getText( |
3990 domain, ok = QInputDialog.getText( |
3989 ## self, |
3991 self, |
3990 ## self.tr("Domain Report"), |
3992 self.tr("Domain Report"), |
3991 ## self.tr("Enter a valid domain name:"), |
3993 self.tr("Enter a valid domain name:"), |
3992 ## QLineEdit.Normal) |
3994 QLineEdit.Normal) |
3993 ## if ok and domain: |
3995 if ok and domain: |
3994 ## self.__virusTotal.getDomainReport(domain) |
3996 self.__virusTotal.getDomainReport(domain) |
3995 |
3997 |
3996 ########################################################################### |
3998 ########################################################################### |
3997 ## Style sheet handling below ## |
3999 ## Style sheet handling below ## |
3998 ########################################################################### |
4000 ########################################################################### |
3999 |
4001 |