8 Module implementing the helpbrowser using QWebView. |
8 Module implementing the helpbrowser using QWebView. |
9 """ |
9 """ |
10 |
10 |
11 from __future__ import unicode_literals |
11 from __future__ import unicode_literals |
12 try: |
12 try: |
13 str = unicode # __IGNORE_WARNING__ |
13 str = unicode |
14 except (NameError): |
14 except NameError: |
15 pass |
15 pass |
16 |
16 |
17 from PyQt4.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, \ |
17 from PyQt4.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, \ |
18 QUrl, QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, QRect, QFile, \ |
18 QUrl, QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, QRect, QFile, \ |
19 QPoint, QByteArray, qVersion |
19 QPoint, QByteArray, qVersion |
356 html = html.replace( |
356 html = html.replace( |
357 "@FAVICON@", imageBuffer.buffer().toBase64()) |
357 "@FAVICON@", imageBuffer.buffer().toBase64()) |
358 html = html.replace("@TITLE@", title.encode("utf8")) |
358 html = html.replace("@TITLE@", title.encode("utf8")) |
359 html = html.replace("@H1@", info.errorString.encode("utf8")) |
359 html = html.replace("@H1@", info.errorString.encode("utf8")) |
360 html = html.replace( |
360 html = html.replace( |
361 "@H2@", self.trUtf8("When connecting to: {0}.") |
361 "@H2@", self.tr("When connecting to: {0}.") |
362 .format(urlString).encode("utf8")) |
362 .format(urlString).encode("utf8")) |
363 html = html.replace( |
363 html = html.replace( |
364 "@LI-1@", |
364 "@LI-1@", |
365 self.trUtf8("Check the address for errors such as " |
365 self.tr("Check the address for errors such as " |
366 "<b>ww</b>.example.org instead of " |
366 "<b>ww</b>.example.org instead of " |
367 "<b>www</b>.example.org").encode("utf8")) |
367 "<b>www</b>.example.org").encode("utf8")) |
368 html = html.replace( |
368 html = html.replace( |
369 "@LI-2@", |
369 "@LI-2@", |
370 self.trUtf8( |
370 self.tr( |
371 "If the address is correct, try checking the network " |
371 "If the address is correct, try checking the network " |
372 "connection.").encode("utf8")) |
372 "connection.").encode("utf8")) |
373 html = html.replace( |
373 html = html.replace( |
374 "@LI-3@", |
374 "@LI-3@", |
375 self.trUtf8( |
375 self.tr( |
376 "If your computer or network is protected by a firewall " |
376 "If your computer or network is protected by a firewall " |
377 "or proxy, make sure that the browser is permitted to " |
377 "or proxy, make sure that the browser is permitted to " |
378 "access the network.").encode("utf8")) |
378 "access the network.").encode("utf8")) |
379 html = html.replace( |
379 html = html.replace( |
380 "@LI-4@", |
380 "@LI-4@", |
381 self.trUtf8("If your cache policy is set to offline browsing," |
381 self.tr("If your cache policy is set to offline browsing," |
382 "only pages in the local cache are available.") |
382 "only pages in the local cache are available.") |
383 .encode("utf8")) |
383 .encode("utf8")) |
384 html = html.replace( |
384 html = html.replace( |
385 "@BUTTON@", self.trUtf8("Try Again").encode("utf8")) |
385 "@BUTTON@", self.tr("Try Again").encode("utf8")) |
386 errorPage.content = html |
386 errorPage.content = html |
387 return True |
387 return True |
388 |
388 |
389 return QWebPage.extension(self, extension, option, output) |
389 return QWebPage.extension(self, extension, option, output) |
390 |
390 |
840 name.toLocalFile().endswith(".CHM"): |
840 name.toLocalFile().endswith(".CHM"): |
841 started = QDesktopServices.openUrl(name) |
841 started = QDesktopServices.openUrl(name) |
842 if not started: |
842 if not started: |
843 E5MessageBox.critical( |
843 E5MessageBox.critical( |
844 self, |
844 self, |
845 self.trUtf8("eric5 Web Browser"), |
845 self.tr("eric5 Web Browser"), |
846 self.trUtf8( |
846 self.tr( |
847 """<p>Could not start a viewer""" |
847 """<p>Could not start a viewer""" |
848 """ for file <b>{0}</b>.</p>""") |
848 """ for file <b>{0}</b>.</p>""") |
849 .format(name.path())) |
849 .format(name.path())) |
850 return |
850 return |
851 elif name.scheme() in ["mailto"]: |
851 elif name.scheme() in ["mailto"]: |
852 started = QDesktopServices.openUrl(name) |
852 started = QDesktopServices.openUrl(name) |
853 if not started: |
853 if not started: |
854 E5MessageBox.critical( |
854 E5MessageBox.critical( |
855 self, |
855 self, |
856 self.trUtf8("eric5 Web Browser"), |
856 self.tr("eric5 Web Browser"), |
857 self.trUtf8( |
857 self.tr( |
858 """<p>Could not start an application""" |
858 """<p>Could not start an application""" |
859 """ for URL <b>{0}</b>.</p>""") |
859 """ for URL <b>{0}</b>.</p>""") |
860 .format(name.toString())) |
860 .format(name.toString())) |
861 return |
861 return |
862 elif name.scheme() == "javascript": |
862 elif name.scheme() == "javascript": |
1081 frameAtPos = self.page().frameAt(evt.pos()) |
1081 frameAtPos = self.page().frameAt(evt.pos()) |
1082 hit = self.page().mainFrame().hitTestContent(evt.pos()) |
1082 hit = self.page().mainFrame().hitTestContent(evt.pos()) |
1083 if not hit.linkUrl().isEmpty(): |
1083 if not hit.linkUrl().isEmpty(): |
1084 menu.addAction( |
1084 menu.addAction( |
1085 UI.PixmapCache.getIcon("openNewTab.png"), |
1085 UI.PixmapCache.getIcon("openNewTab.png"), |
1086 self.trUtf8("Open Link in New Tab\tCtrl+LMB"), |
1086 self.tr("Open Link in New Tab\tCtrl+LMB"), |
1087 self.__openLinkInNewTab).setData(hit.linkUrl()) |
1087 self.__openLinkInNewTab).setData(hit.linkUrl()) |
1088 menu.addSeparator() |
1088 menu.addSeparator() |
1089 menu.addAction( |
1089 menu.addAction( |
1090 UI.PixmapCache.getIcon("download.png"), |
1090 UI.PixmapCache.getIcon("download.png"), |
1091 self.trUtf8("Save Lin&k"), self.__downloadLink) |
1091 self.tr("Save Lin&k"), self.__downloadLink) |
1092 menu.addAction( |
1092 menu.addAction( |
1093 UI.PixmapCache.getIcon("bookmark22.png"), |
1093 UI.PixmapCache.getIcon("bookmark22.png"), |
1094 self.trUtf8("Bookmark this Link"), self.__bookmarkLink)\ |
1094 self.tr("Bookmark this Link"), self.__bookmarkLink)\ |
1095 .setData(hit.linkUrl()) |
1095 .setData(hit.linkUrl()) |
1096 menu.addSeparator() |
1096 menu.addSeparator() |
1097 menu.addAction( |
1097 menu.addAction( |
1098 UI.PixmapCache.getIcon("editCopy.png"), |
1098 UI.PixmapCache.getIcon("editCopy.png"), |
1099 self.trUtf8("Copy Link to Clipboard"), self.__copyLink) |
1099 self.tr("Copy Link to Clipboard"), self.__copyLink) |
1100 menu.addAction( |
1100 menu.addAction( |
1101 UI.PixmapCache.getIcon("mailSend.png"), |
1101 UI.PixmapCache.getIcon("mailSend.png"), |
1102 self.trUtf8("Send Link"), |
1102 self.tr("Send Link"), |
1103 self.__sendLink).setData(hit.linkUrl()) |
1103 self.__sendLink).setData(hit.linkUrl()) |
1104 if Preferences.getHelp("VirusTotalEnabled") and \ |
1104 if Preferences.getHelp("VirusTotalEnabled") and \ |
1105 Preferences.getHelp("VirusTotalServiceKey") != "": |
1105 Preferences.getHelp("VirusTotalServiceKey") != "": |
1106 menu.addAction( |
1106 menu.addAction( |
1107 UI.PixmapCache.getIcon("virustotal.png"), |
1107 UI.PixmapCache.getIcon("virustotal.png"), |
1108 self.trUtf8("Scan Link with VirusTotal"), |
1108 self.tr("Scan Link with VirusTotal"), |
1109 self.__virusTotal).setData(hit.linkUrl()) |
1109 self.__virusTotal).setData(hit.linkUrl()) |
1110 |
1110 |
1111 if not hit.imageUrl().isEmpty(): |
1111 if not hit.imageUrl().isEmpty(): |
1112 if not menu.isEmpty(): |
1112 if not menu.isEmpty(): |
1113 menu.addSeparator() |
1113 menu.addSeparator() |
1114 menu.addAction( |
1114 menu.addAction( |
1115 UI.PixmapCache.getIcon("openNewTab.png"), |
1115 UI.PixmapCache.getIcon("openNewTab.png"), |
1116 self.trUtf8("Open Image in New Tab"), |
1116 self.tr("Open Image in New Tab"), |
1117 self.__openLinkInNewTab).setData(hit.imageUrl()) |
1117 self.__openLinkInNewTab).setData(hit.imageUrl()) |
1118 menu.addSeparator() |
1118 menu.addSeparator() |
1119 menu.addAction( |
1119 menu.addAction( |
1120 UI.PixmapCache.getIcon("download.png"), |
1120 UI.PixmapCache.getIcon("download.png"), |
1121 self.trUtf8("Save Image"), self.__downloadImage) |
1121 self.tr("Save Image"), self.__downloadImage) |
1122 menu.addAction( |
1122 menu.addAction( |
1123 self.trUtf8("Copy Image to Clipboard"), self.__copyImage) |
1123 self.tr("Copy Image to Clipboard"), self.__copyImage) |
1124 menu.addAction( |
1124 menu.addAction( |
1125 UI.PixmapCache.getIcon("editCopy.png"), |
1125 UI.PixmapCache.getIcon("editCopy.png"), |
1126 self.trUtf8("Copy Image Location to Clipboard"), |
1126 self.tr("Copy Image Location to Clipboard"), |
1127 self.__copyLocation).setData(hit.imageUrl().toString()) |
1127 self.__copyLocation).setData(hit.imageUrl().toString()) |
1128 menu.addAction( |
1128 menu.addAction( |
1129 UI.PixmapCache.getIcon("mailSend.png"), |
1129 UI.PixmapCache.getIcon("mailSend.png"), |
1130 self.trUtf8("Send Image Link"), |
1130 self.tr("Send Image Link"), |
1131 self.__sendLink).setData(hit.imageUrl()) |
1131 self.__sendLink).setData(hit.imageUrl()) |
1132 menu.addSeparator() |
1132 menu.addSeparator() |
1133 menu.addAction( |
1133 menu.addAction( |
1134 UI.PixmapCache.getIcon("adBlockPlus.png"), |
1134 UI.PixmapCache.getIcon("adBlockPlus.png"), |
1135 self.trUtf8("Block Image"), self.__blockImage)\ |
1135 self.tr("Block Image"), self.__blockImage)\ |
1136 .setData(hit.imageUrl().toString()) |
1136 .setData(hit.imageUrl().toString()) |
1137 if Preferences.getHelp("VirusTotalEnabled") and \ |
1137 if Preferences.getHelp("VirusTotalEnabled") and \ |
1138 Preferences.getHelp("VirusTotalServiceKey") != "": |
1138 Preferences.getHelp("VirusTotalServiceKey") != "": |
1139 menu.addAction( |
1139 menu.addAction( |
1140 UI.PixmapCache.getIcon("virustotal.png"), |
1140 UI.PixmapCache.getIcon("virustotal.png"), |
1141 self.trUtf8("Scan Image with VirusTotal"), |
1141 self.tr("Scan Image with VirusTotal"), |
1142 self.__virusTotal).setData(hit.imageUrl()) |
1142 self.__virusTotal).setData(hit.imageUrl()) |
1143 |
1143 |
1144 element = hit.element() |
1144 element = hit.element() |
1145 if not element.isNull(): |
1145 if not element.isNull(): |
1146 if self.__isMediaElement(element): |
1146 if self.__isMediaElement(element): |
1154 videoUrl = QUrl(element.evaluateJavaScript("this.currentSrc")) |
1154 videoUrl = QUrl(element.evaluateJavaScript("this.currentSrc")) |
1155 |
1155 |
1156 if paused: |
1156 if paused: |
1157 menu.addAction( |
1157 menu.addAction( |
1158 UI.PixmapCache.getIcon("mediaPlaybackStart.png"), |
1158 UI.PixmapCache.getIcon("mediaPlaybackStart.png"), |
1159 self.trUtf8("Play"), self.__pauseMedia) |
1159 self.tr("Play"), self.__pauseMedia) |
1160 else: |
1160 else: |
1161 menu.addAction( |
1161 menu.addAction( |
1162 UI.PixmapCache.getIcon("mediaPlaybackPause.png"), |
1162 UI.PixmapCache.getIcon("mediaPlaybackPause.png"), |
1163 self.trUtf8("Pause"), self.__pauseMedia) |
1163 self.tr("Pause"), self.__pauseMedia) |
1164 if muted: |
1164 if muted: |
1165 menu.addAction( |
1165 menu.addAction( |
1166 UI.PixmapCache.getIcon("audioVolumeHigh.png"), |
1166 UI.PixmapCache.getIcon("audioVolumeHigh.png"), |
1167 self.trUtf8("Unmute"), self.__muteMedia) |
1167 self.tr("Unmute"), self.__muteMedia) |
1168 else: |
1168 else: |
1169 menu.addAction( |
1169 menu.addAction( |
1170 UI.PixmapCache.getIcon("audioVolumeMuted.png"), |
1170 UI.PixmapCache.getIcon("audioVolumeMuted.png"), |
1171 self.trUtf8("Mute"), self.__muteMedia) |
1171 self.tr("Mute"), self.__muteMedia) |
1172 menu.addSeparator() |
1172 menu.addSeparator() |
1173 menu.addAction( |
1173 menu.addAction( |
1174 UI.PixmapCache.getIcon("editCopy.png"), |
1174 UI.PixmapCache.getIcon("editCopy.png"), |
1175 self.trUtf8("Copy Media Address to Clipboard"), |
1175 self.tr("Copy Media Address to Clipboard"), |
1176 self.__copyLocation).setData(videoUrl.toString()) |
1176 self.__copyLocation).setData(videoUrl.toString()) |
1177 menu.addAction( |
1177 menu.addAction( |
1178 UI.PixmapCache.getIcon("mailSend.png"), |
1178 UI.PixmapCache.getIcon("mailSend.png"), |
1179 self.trUtf8("Send Media Address"), self.__sendLink)\ |
1179 self.tr("Send Media Address"), self.__sendLink)\ |
1180 .setData(videoUrl) |
1180 .setData(videoUrl) |
1181 menu.addAction( |
1181 menu.addAction( |
1182 UI.PixmapCache.getIcon("download.png"), |
1182 UI.PixmapCache.getIcon("download.png"), |
1183 self.trUtf8("Save Media"), self.__downloadMedia)\ |
1183 self.tr("Save Media"), self.__downloadMedia)\ |
1184 .setData(videoUrl) |
1184 .setData(videoUrl) |
1185 |
1185 |
1186 if element.tagName().lower() in ["input", "textarea"]: |
1186 if element.tagName().lower() in ["input", "textarea"]: |
1187 if menu.isEmpty(): |
1187 if menu.isEmpty(): |
1188 pageMenu = self.page().createStandardContextMenu() |
1188 pageMenu = self.page().createStandardContextMenu() |
1219 menu.addAction(self.mw.saveAsAct) |
1219 menu.addAction(self.mw.saveAsAct) |
1220 menu.addSeparator() |
1220 menu.addSeparator() |
1221 |
1221 |
1222 if frameAtPos and self.page().mainFrame() != frameAtPos: |
1222 if frameAtPos and self.page().mainFrame() != frameAtPos: |
1223 self.__clickedFrame = frameAtPos |
1223 self.__clickedFrame = frameAtPos |
1224 fmenu = QMenu(self.trUtf8("This Frame")) |
1224 fmenu = QMenu(self.tr("This Frame")) |
1225 frameUrl = self.__clickedFrame.url() |
1225 frameUrl = self.__clickedFrame.url() |
1226 if frameUrl.isValid(): |
1226 if frameUrl.isValid(): |
1227 fmenu.addAction( |
1227 fmenu.addAction( |
1228 self.trUtf8("Show &only this frame"), |
1228 self.tr("Show &only this frame"), |
1229 self.__loadClickedFrame) |
1229 self.__loadClickedFrame) |
1230 fmenu.addAction( |
1230 fmenu.addAction( |
1231 UI.PixmapCache.getIcon("openNewTab.png"), |
1231 UI.PixmapCache.getIcon("openNewTab.png"), |
1232 self.trUtf8("Show in new &tab"), |
1232 self.tr("Show in new &tab"), |
1233 self.__openLinkInNewTab).setData(self.__clickedFrame.url()) |
1233 self.__openLinkInNewTab).setData(self.__clickedFrame.url()) |
1234 fmenu.addSeparator() |
1234 fmenu.addSeparator() |
1235 fmenu.addAction( |
1235 fmenu.addAction( |
1236 UI.PixmapCache.getIcon("print.png"), |
1236 UI.PixmapCache.getIcon("print.png"), |
1237 self.trUtf8("&Print"), self.__printClickedFrame) |
1237 self.tr("&Print"), self.__printClickedFrame) |
1238 fmenu.addAction( |
1238 fmenu.addAction( |
1239 UI.PixmapCache.getIcon("printPreview.png"), |
1239 UI.PixmapCache.getIcon("printPreview.png"), |
1240 self.trUtf8("Print Preview"), self.__printPreviewClickedFrame) |
1240 self.tr("Print Preview"), self.__printPreviewClickedFrame) |
1241 fmenu.addAction( |
1241 fmenu.addAction( |
1242 UI.PixmapCache.getIcon("printPdf.png"), |
1242 UI.PixmapCache.getIcon("printPdf.png"), |
1243 self.trUtf8("Print as PDF"), self.__printPdfClickedFrame) |
1243 self.tr("Print as PDF"), self.__printPdfClickedFrame) |
1244 fmenu.addSeparator() |
1244 fmenu.addSeparator() |
1245 fmenu.addAction( |
1245 fmenu.addAction( |
1246 UI.PixmapCache.getIcon("zoomIn.png"), |
1246 UI.PixmapCache.getIcon("zoomIn.png"), |
1247 self.trUtf8("Zoom &in"), self.__zoomInClickedFrame) |
1247 self.tr("Zoom &in"), self.__zoomInClickedFrame) |
1248 fmenu.addAction( |
1248 fmenu.addAction( |
1249 UI.PixmapCache.getIcon("zoomReset.png"), |
1249 UI.PixmapCache.getIcon("zoomReset.png"), |
1250 self.trUtf8("Zoom &reset"), self.__zoomResetClickedFrame) |
1250 self.tr("Zoom &reset"), self.__zoomResetClickedFrame) |
1251 fmenu.addAction( |
1251 fmenu.addAction( |
1252 UI.PixmapCache.getIcon("zoomOut.png"), |
1252 UI.PixmapCache.getIcon("zoomOut.png"), |
1253 self.trUtf8("Zoom &out"), self.__zoomOutClickedFrame) |
1253 self.tr("Zoom &out"), self.__zoomOutClickedFrame) |
1254 fmenu.addSeparator() |
1254 fmenu.addSeparator() |
1255 fmenu.addAction( |
1255 fmenu.addAction( |
1256 self.trUtf8("Show frame so&urce"), |
1256 self.tr("Show frame so&urce"), |
1257 self.__showClickedFrameSource) |
1257 self.__showClickedFrameSource) |
1258 |
1258 |
1259 menu.addMenu(fmenu) |
1259 menu.addMenu(fmenu) |
1260 menu.addSeparator() |
1260 menu.addSeparator() |
1261 |
1261 |
1262 menu.addAction( |
1262 menu.addAction( |
1263 UI.PixmapCache.getIcon("bookmark22.png"), |
1263 UI.PixmapCache.getIcon("bookmark22.png"), |
1264 self.trUtf8("Bookmark this Page"), self.addBookmark) |
1264 self.tr("Bookmark this Page"), self.addBookmark) |
1265 menu.addAction( |
1265 menu.addAction( |
1266 UI.PixmapCache.getIcon("mailSend.png"), |
1266 UI.PixmapCache.getIcon("mailSend.png"), |
1267 self.trUtf8("Send Page Link"), self.__sendLink).setData(self.url()) |
1267 self.tr("Send Page Link"), self.__sendLink).setData(self.url()) |
1268 menu.addSeparator() |
1268 menu.addSeparator() |
1269 self.__userAgentMenu = UserAgentMenu(self.trUtf8("User Agent"), |
1269 self.__userAgentMenu = UserAgentMenu(self.tr("User Agent"), |
1270 url=self.url()) |
1270 url=self.url()) |
1271 menu.addMenu(self.__userAgentMenu) |
1271 menu.addMenu(self.__userAgentMenu) |
1272 menu.addSeparator() |
1272 menu.addSeparator() |
1273 menu.addAction(self.mw.backAct) |
1273 menu.addAction(self.mw.backAct) |
1274 menu.addAction(self.mw.forwardAct) |
1274 menu.addAction(self.mw.forwardAct) |
1280 menu.addSeparator() |
1280 menu.addSeparator() |
1281 if self.selectedText(): |
1281 if self.selectedText(): |
1282 menu.addAction(self.mw.copyAct) |
1282 menu.addAction(self.mw.copyAct) |
1283 menu.addAction( |
1283 menu.addAction( |
1284 UI.PixmapCache.getIcon("mailSend.png"), |
1284 UI.PixmapCache.getIcon("mailSend.png"), |
1285 self.trUtf8("Send Text"), |
1285 self.tr("Send Text"), |
1286 self.__sendLink).setData(self.selectedText()) |
1286 self.__sendLink).setData(self.selectedText()) |
1287 menu.addAction(self.mw.findAct) |
1287 menu.addAction(self.mw.findAct) |
1288 menu.addSeparator() |
1288 menu.addSeparator() |
1289 if self.selectedText(): |
1289 if self.selectedText(): |
1290 self.__searchMenu = menu.addMenu(self.trUtf8("Search with...")) |
1290 self.__searchMenu = menu.addMenu(self.tr("Search with...")) |
1291 |
1291 |
1292 from .OpenSearch.OpenSearchEngineAction import \ |
1292 from .OpenSearch.OpenSearchEngineAction import \ |
1293 OpenSearchEngineAction |
1293 OpenSearchEngineAction |
1294 engineNames = self.mw.openSearchManager().allEnginesNames() |
1294 engineNames = self.mw.openSearchManager().allEnginesNames() |
1295 for engineName in engineNames: |
1295 for engineName in engineNames: |
1312 googleTranslatorUrl = QUrl( |
1312 googleTranslatorUrl = QUrl( |
1313 "http://translate.google.com/#auto|{0}|{1}".format( |
1313 "http://translate.google.com/#auto|{0}|{1}".format( |
1314 langCode, self.selectedText())) |
1314 langCode, self.selectedText())) |
1315 menu.addAction( |
1315 menu.addAction( |
1316 UI.PixmapCache.getIcon("translate.png"), |
1316 UI.PixmapCache.getIcon("translate.png"), |
1317 self.trUtf8("Google Translate"), self.__openLinkInNewTab)\ |
1317 self.tr("Google Translate"), self.__openLinkInNewTab)\ |
1318 .setData(googleTranslatorUrl) |
1318 .setData(googleTranslatorUrl) |
1319 wiktionaryUrl = QUrl( |
1319 wiktionaryUrl = QUrl( |
1320 "http://{0}.wiktionary.org/wiki/Special:Search?search={1}" |
1320 "http://{0}.wiktionary.org/wiki/Special:Search?search={1}" |
1321 .format(langCode, self.selectedText())) |
1321 .format(langCode, self.selectedText())) |
1322 menu.addAction( |
1322 menu.addAction( |
1323 UI.PixmapCache.getIcon("wikipedia.png"), |
1323 UI.PixmapCache.getIcon("wikipedia.png"), |
1324 self.trUtf8("Dictionary"), self.__openLinkInNewTab)\ |
1324 self.tr("Dictionary"), self.__openLinkInNewTab)\ |
1325 .setData(wiktionaryUrl) |
1325 .setData(wiktionaryUrl) |
1326 menu.addSeparator() |
1326 menu.addSeparator() |
1327 |
1327 |
1328 guessedUrl = QUrl.fromUserInput(self.selectedText().strip()) |
1328 guessedUrl = QUrl.fromUserInput(self.selectedText().strip()) |
1329 if self.__isUrlValid(guessedUrl): |
1329 if self.__isUrlValid(guessedUrl): |
1330 menu.addAction( |
1330 menu.addAction( |
1331 self.trUtf8("Go to web address"), |
1331 self.tr("Go to web address"), |
1332 self.__openLinkInNewTab).setData(guessedUrl) |
1332 self.__openLinkInNewTab).setData(guessedUrl) |
1333 menu.addSeparator() |
1333 menu.addSeparator() |
1334 |
1334 |
1335 element = hit.element() |
1335 element = hit.element() |
1336 if not element.isNull() and \ |
1336 if not element.isNull() and \ |
1337 element.tagName().lower() == "input" and \ |
1337 element.tagName().lower() == "input" and \ |
1338 element.attribute("type", "text") == "text": |
1338 element.attribute("type", "text") == "text": |
1339 menu.addAction(self.trUtf8("Add to web search toolbar"), |
1339 menu.addAction(self.tr("Add to web search toolbar"), |
1340 self.__addSearchEngine).setData(element) |
1340 self.__addSearchEngine).setData(element) |
1341 menu.addSeparator() |
1341 menu.addSeparator() |
1342 |
1342 |
1343 menu.addAction( |
1343 menu.addAction( |
1344 UI.PixmapCache.getIcon("webInspector.png"), |
1344 UI.PixmapCache.getIcon("webInspector.png"), |
1345 self.trUtf8("Web Inspector..."), self.__webInspector) |
1345 self.tr("Web Inspector..."), self.__webInspector) |
1346 |
1346 |
1347 menu.exec_(evt.globalPos()) |
1347 menu.exec_(evt.globalPos()) |
1348 |
1348 |
1349 def __isUrlValid(self, url): |
1349 def __isUrlValid(self, url): |
1350 """ |
1350 """ |
1957 if pixmap.save(imageBuffer, "PNG"): |
1957 if pixmap.save(imageBuffer, "PNG"): |
1958 html = html.replace("@FAVICON@", imageBuffer.buffer().toBase64()) |
1958 html = html.replace("@FAVICON@", imageBuffer.buffer().toBase64()) |
1959 html = html.replace("@TITLE@", title.encode("utf8")) |
1959 html = html.replace("@TITLE@", title.encode("utf8")) |
1960 html = html.replace("@H1@", reply.errorString().encode("utf8")) |
1960 html = html.replace("@H1@", reply.errorString().encode("utf8")) |
1961 html = html.replace( |
1961 html = html.replace( |
1962 "@H2@", self.trUtf8("When connecting to: {0}.") |
1962 "@H2@", self.tr("When connecting to: {0}.") |
1963 .format(urlString).encode("utf8")) |
1963 .format(urlString).encode("utf8")) |
1964 html = html.replace( |
1964 html = html.replace( |
1965 "@LI-1@", |
1965 "@LI-1@", |
1966 self.trUtf8("Check the address for errors such as " |
1966 self.tr("Check the address for errors such as " |
1967 "<b>ww</b>.example.org instead of " |
1967 "<b>ww</b>.example.org instead of " |
1968 "<b>www</b>.example.org").encode("utf8")) |
1968 "<b>www</b>.example.org").encode("utf8")) |
1969 html = html.replace( |
1969 html = html.replace( |
1970 "@LI-2@", |
1970 "@LI-2@", |
1971 self.trUtf8("If the address is correct, try checking the network " |
1971 self.tr("If the address is correct, try checking the network " |
1972 "connection.").encode("utf8")) |
1972 "connection.").encode("utf8")) |
1973 html = html.replace( |
1973 html = html.replace( |
1974 "@LI-3@", |
1974 "@LI-3@", |
1975 self.trUtf8( |
1975 self.tr( |
1976 "If your computer or network is protected by a firewall " |
1976 "If your computer or network is protected by a firewall " |
1977 "or proxy, make sure that the browser is permitted to " |
1977 "or proxy, make sure that the browser is permitted to " |
1978 "access the network.").encode("utf8")) |
1978 "access the network.").encode("utf8")) |
1979 html = html.replace( |
1979 html = html.replace( |
1980 "@LI-4@", |
1980 "@LI-4@", |
1981 self.trUtf8("If your cache policy is set to offline browsing," |
1981 self.tr("If your cache policy is set to offline browsing," |
1982 "only pages in the local cache are available.") |
1982 "only pages in the local cache are available.") |
1983 .encode("utf8")) |
1983 .encode("utf8")) |
1984 html = html.replace( |
1984 html = html.replace( |
1985 "@BUTTON@", self.trUtf8("Try Again").encode("utf8")) |
1985 "@BUTTON@", self.tr("Try Again").encode("utf8")) |
1986 notFoundFrame.setHtml(bytes(html).decode("utf8"), replyUrl) |
1986 notFoundFrame.setHtml(bytes(html).decode("utf8"), replyUrl) |
1987 self.mw.historyManager().removeHistoryEntry(replyUrl, self.title()) |
1987 self.mw.historyManager().removeHistoryEntry(replyUrl, self.title()) |
1988 self.loadFinished.emit(False) |
1988 self.loadFinished.emit(False) |
1989 |
1989 |
1990 def __downloadRequested(self, request): |
1990 def __downloadRequested(self, request): |
2009 # accessed for the first time |
2009 # accessed for the first time |
2010 return |
2010 return |
2011 |
2011 |
2012 res = E5MessageBox.yesNo( |
2012 res = E5MessageBox.yesNo( |
2013 self, |
2013 self, |
2014 self.trUtf8("Web Database Quota"), |
2014 self.tr("Web Database Quota"), |
2015 self.trUtf8( |
2015 self.tr( |
2016 """<p>The database quota of <strong>{0}</strong> has""" |
2016 """<p>The database quota of <strong>{0}</strong> has""" |
2017 """ been exceeded while accessing database <strong>{1}""" |
2017 """ been exceeded while accessing database <strong>{1}""" |
2018 """</strong>.</p><p>Shall it be changed?</p>""") |
2018 """</strong>.</p><p>Shall it be changed?</p>""") |
2019 .format(self.__dataString(securityOrigin.databaseQuota()), |
2019 .format(self.__dataString(securityOrigin.databaseQuota()), |
2020 databaseName), |
2020 databaseName), |
2021 yesDefault=True) |
2021 yesDefault=True) |
2022 if res: |
2022 if res: |
2023 newQuota, ok = QInputDialog.getInt( |
2023 newQuota, ok = QInputDialog.getInt( |
2024 self, |
2024 self, |
2025 self.trUtf8("New Web Database Quota"), |
2025 self.tr("New Web Database Quota"), |
2026 self.trUtf8( |
2026 self.tr( |
2027 "Enter the new quota in MB (current = {0}, used = {1}; " |
2027 "Enter the new quota in MB (current = {0}, used = {1}; " |
2028 "step size = 5 MB):" |
2028 "step size = 5 MB):" |
2029 .format( |
2029 .format( |
2030 self.__dataString(securityOrigin.databaseQuota()), |
2030 self.__dataString(securityOrigin.databaseQuota()), |
2031 self.__dataString(securityOrigin.databaseUsage()))), |
2031 self.__dataString(securityOrigin.databaseUsage()))), |