86 |
86 |
87 self.__rwhvqt = None |
87 self.__rwhvqt = None |
88 self.installEventFilter(self) |
88 self.installEventFilter(self) |
89 |
89 |
90 # TODO: Speeddial |
90 # TODO: Speeddial |
91 ## import Helpviewer.HelpWindow |
91 ## import WebBrowser.WebBrowserWindow |
92 ## self.__speedDial = Helpviewer.HelpWindow.HelpWindow.speedDial() |
92 ## self.__speedDial = WebBrowser.WebBrowserWindow.WebBrowserWindow.speedDial() |
93 |
93 |
94 self.__page = WebBrowserPage(self) |
94 self.__page = WebBrowserPage(self) |
95 self.setPage(self.__page) |
95 self.setPage(self.__page) |
96 |
96 |
97 self.__mw = mainWindow |
97 self.__mw = mainWindow |
103 self.__menu = QMenu(self) |
103 self.__menu = QMenu(self) |
104 self.__clickedPos = QPoint() |
104 self.__clickedPos = QPoint() |
105 |
105 |
106 self.__currentZoom = 100 |
106 self.__currentZoom = 100 |
107 self.__zoomLevels = WebBrowserView.ZoomLevels[:] |
107 self.__zoomLevels = WebBrowserView.ZoomLevels[:] |
108 ## |
|
109 ## self.__javaScriptBinding = None |
|
110 ## self.__javaScriptEricObject = None |
|
111 |
108 |
112 ## self.__mw.zoomTextOnlyChanged.connect(self.__applyZoom) |
109 ## self.__mw.zoomTextOnlyChanged.connect(self.__applyZoom) |
113 |
110 |
114 ## self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) |
111 ## self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) |
115 ## self.linkClicked.connect(self.setSource) |
112 ## self.linkClicked.connect(self.setSource) |
123 self.loadProgress.connect(self.__loadProgress) |
120 self.loadProgress.connect(self.__loadProgress) |
124 self.loadFinished.connect(self.__loadFinished) |
121 self.loadFinished.connect(self.__loadFinished) |
125 |
122 |
126 ## self.page().setForwardUnsupportedContent(True) |
123 ## self.page().setForwardUnsupportedContent(True) |
127 ## self.page().unsupportedContent.connect(self.__unsupportedContent) |
124 ## self.page().unsupportedContent.connect(self.__unsupportedContent) |
128 |
|
129 ## self.page().frameCreated.connect(self.__addExternalBinding) |
|
130 ## self.__addExternalBinding(self.page().mainFrame()) |
|
131 |
125 |
132 ## self.page().databaseQuotaExceeded.connect(self.__databaseQuotaExceeded) |
126 ## self.page().databaseQuotaExceeded.connect(self.__databaseQuotaExceeded) |
133 |
127 |
134 self.__mw.openSearchManager().currentEngineChanged.connect( |
128 self.__mw.openSearchManager().currentEngineChanged.connect( |
135 self.__currentEngineChanged) |
129 self.__currentEngineChanged) |
328 self.tr( |
322 self.tr( |
329 """<p>Could not start an application""" |
323 """<p>Could not start an application""" |
330 """ for URL <b>{0}</b>.</p>""") |
324 """ for URL <b>{0}</b>.</p>""") |
331 .format(name.toString())) |
325 .format(name.toString())) |
332 return |
326 return |
333 ## elif name.scheme() == "javascript": |
|
334 ## scriptSource = QUrl.fromPercentEncoding(name.toString( |
|
335 ## QUrl.FormattingOptions(QUrl.TolerantMode | QUrl.RemoveScheme))) |
|
336 ## self.page().mainFrame().evaluateJavaScript(scriptSource) |
|
337 ## return |
|
338 else: |
327 else: |
339 if name.toString().endswith(".pdf") or \ |
328 if name.toString().endswith(".pdf") or \ |
340 name.toString().endswith(".PDF") or \ |
329 name.toString().endswith(".PDF") or \ |
341 name.toString().endswith(".chm") or \ |
330 name.toString().endswith(".chm") or \ |
342 name.toString().endswith(".CHM"): |
331 name.toString().endswith(".CHM"): |
687 .setData(hitTest.linkUrl()) |
676 .setData(hitTest.linkUrl()) |
688 menu.addAction( |
677 menu.addAction( |
689 UI.PixmapCache.getIcon("mailSend.png"), |
678 UI.PixmapCache.getIcon("mailSend.png"), |
690 self.tr("Send Link"), |
679 self.tr("Send Link"), |
691 self.__sendLink).setData(hitTest.linkUrl()) |
680 self.__sendLink).setData(hitTest.linkUrl()) |
692 # TODO: VirusTotal |
681 if Preferences.getWebBrowser("VirusTotalEnabled") and \ |
693 ## if Preferences.getWebBrowser("VirusTotalEnabled") and \ |
682 Preferences.getWebBrowser("VirusTotalServiceKey") != "": |
694 ## Preferences.getWebBrowser("VirusTotalServiceKey") != "": |
683 menu.addAction( |
695 ## menu.addAction( |
684 UI.PixmapCache.getIcon("virustotal.png"), |
696 ## UI.PixmapCache.getIcon("virustotal.png"), |
685 self.tr("Scan Link with VirusTotal"), |
697 ## self.tr("Scan Link with VirusTotal"), |
686 self.__virusTotal).setData(hitTest.linkUrl()) |
698 ## self.__virusTotal).setData(hitTest.linkUrl()) |
|
699 |
687 |
700 def __createImageContextMenu(self, menu, hitTest): |
688 def __createImageContextMenu(self, menu, hitTest): |
701 """ |
689 """ |
702 Private method to populate the context menu for images. |
690 Private method to populate the context menu for images. |
703 |
691 |
733 ## menu.addSeparator() |
721 ## menu.addSeparator() |
734 ## menu.addAction( |
722 ## menu.addAction( |
735 ## UI.PixmapCache.getIcon("adBlockPlus.png"), |
723 ## UI.PixmapCache.getIcon("adBlockPlus.png"), |
736 ## self.tr("Block Image"), self.__blockImage)\ |
724 ## self.tr("Block Image"), self.__blockImage)\ |
737 ## .setData(hitTest.imageUrl().toString()) |
725 ## .setData(hitTest.imageUrl().toString()) |
738 # TODO: VirusTotal |
726 if Preferences.getWebBrowser("VirusTotalEnabled") and \ |
739 ## if Preferences.getWebBrowser("VirusTotalEnabled") and \ |
727 Preferences.getWebBrowser("VirusTotalServiceKey") != "": |
740 ## Preferences.getWebBrowser("VirusTotalServiceKey") != "": |
728 menu.addAction( |
741 ## menu.addAction( |
729 UI.PixmapCache.getIcon("virustotal.png"), |
742 ## UI.PixmapCache.getIcon("virustotal.png"), |
730 self.tr("Scan Image with VirusTotal"), |
743 ## self.tr("Scan Image with VirusTotal"), |
731 self.__virusTotal).setData(hitTest.imageUrl()) |
744 ## self.__virusTotal).setData(hitTest.imageUrl()) |
|
745 |
732 |
746 def __createMediaContextMenu(self, menu, hitTest): |
733 def __createMediaContextMenu(self, menu, hitTest): |
747 """ |
734 """ |
748 Private method to populate the context menu for media elements. |
735 Private method to populate the context menu for media elements. |
749 |
736 |
1027 # TODO: AdBlock |
1014 # TODO: AdBlock |
1028 ## def __blockImage(self): |
1015 ## def __blockImage(self): |
1029 ## """ |
1016 ## """ |
1030 ## Private slot to add a block rule for an image URL. |
1017 ## Private slot to add a block rule for an image URL. |
1031 ## """ |
1018 ## """ |
1032 ## import Helpviewer.HelpWindow |
1019 ## import WebBrowser.WebBrowserWindow |
1033 ## act = self.sender() |
1020 ## act = self.sender() |
1034 ## url = act.data() |
1021 ## url = act.data() |
1035 ## dlg = Helpviewer.HelpWindow.HelpWindow.adBlockManager().showDialog() |
1022 ## dlg = WebBrowser.WebBrowserWindow.WebBrowserWindow.adBlockManager().showDialog() |
1036 ## dlg.addCustomRule(url) |
1023 ## dlg.addCustomRule(url) |
1037 |
1024 |
1038 # TODO: DownloadManager |
1025 # TODO: DownloadManager |
1039 ## def __downloadMedia(self): |
1026 ## def __downloadMedia(self): |
1040 ## """ |
1027 ## """ |
1058 """ |
1045 """ |
1059 from .Tools import Scripts |
1046 from .Tools import Scripts |
1060 script = Scripts.toggleMediaMute(self.__clickedPos) |
1047 script = Scripts.toggleMediaMute(self.__clickedPos) |
1061 self.page().runJavaScript(script) |
1048 self.page().runJavaScript(script) |
1062 |
1049 |
1063 # TODO: VirusTotal |
1050 def __virusTotal(self): |
1064 ## def __virusTotal(self): |
1051 """ |
1065 ## """ |
1052 Private slot to scan the selected URL with VirusTotal. |
1066 ## Private slot to scan the selected URL with VirusTotal. |
1053 """ |
1067 ## """ |
1054 act = self.sender() |
1068 ## act = self.sender() |
1055 url = act.data() |
1069 ## url = act.data() |
1056 self.__mw.requestVirusTotalScan(url) |
1070 ## self.__mw.requestVirusTotalScan(url) |
|
1071 |
1057 |
1072 def __searchRequested(self, act): |
1058 def __searchRequested(self, act): |
1073 """ |
1059 """ |
1074 Private slot to search for some text with a selected search engine. |
1060 Private slot to search for some text with a selected search engine. |
1075 |
1061 |
1150 dlg = AddBookmarkDialog() |
1136 dlg = AddBookmarkDialog() |
1151 dlg.setUrl(bytes(self.url().toEncoded()).decode()) |
1137 dlg.setUrl(bytes(self.url().toEncoded()).decode()) |
1152 dlg.setTitle(self.title()) |
1138 dlg.setTitle(self.title()) |
1153 dlg.setDescription(description) |
1139 dlg.setDescription(description) |
1154 dlg.exec_() |
1140 dlg.exec_() |
1155 ## from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
|
1156 ## dlg = AddBookmarkDialog() |
|
1157 ## dlg.setUrl(bytes(self.url().toEncoded()).decode()) |
|
1158 ## dlg.setTitle(self.title()) |
|
1159 ## meta = self.page().mainFrame().metaData() |
|
1160 ## if "description" in meta: |
|
1161 ## dlg.setDescription(meta["description"][0]) |
|
1162 ## dlg.exec_() |
|
1163 |
1141 |
1164 def dragEnterEvent(self, evt): |
1142 def dragEnterEvent(self, evt): |
1165 """ |
1143 """ |
1166 Protected method called by a drag enter event. |
1144 Protected method called by a drag enter event. |
1167 |
1145 |