44 from eric7.EricGui import EricPixmapCache |
44 from eric7.EricGui import EricPixmapCache |
45 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
45 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
46 from eric7.EricWidgets.EricApplication import ericApp |
46 from eric7.EricWidgets.EricApplication import ericApp |
47 from eric7.Globals import qVersionTuple |
47 from eric7.Globals import qVersionTuple |
48 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
48 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
49 from eric7.WebBrowser.ZoomManager import ZoomManager |
49 |
50 |
50 from . import WebInspector |
51 from . import WebInspector |
51 from .Tools import Scripts |
52 from .Tools import Scripts |
52 from .Tools.WebBrowserTools import getHtmlPage, pixmapToDataUrl |
53 from .Tools.WebBrowserTools import getHtmlPage, pixmapToDataUrl |
53 from .Tools.WebIconLoader import WebIconLoader |
54 from .Tools.WebIconLoader import WebIconLoader |
464 """ |
465 """ |
465 if value != self.__currentZoom: |
466 if value != self.__currentZoom: |
466 self.setZoomFactor(value / 100.0) |
467 self.setZoomFactor(value / 100.0) |
467 self.__currentZoom = value |
468 self.__currentZoom = value |
468 if saveValue and not self.__mw.isPrivate(): |
469 if saveValue and not self.__mw.isPrivate(): |
469 from eric7.WebBrowser.ZoomManager import ZoomManager |
|
470 |
|
471 ZoomManager.instance().setZoomValue(self.url(), value) |
470 ZoomManager.instance().setZoomValue(self.url(), value) |
472 self.zoomValueChanged.emit(value) |
471 self.zoomValueChanged.emit(value) |
473 |
472 |
474 def zoomValue(self): |
473 def zoomValue(self): |
475 """ |
474 """ |
861 @param menu reference to the menu to be populated |
860 @param menu reference to the menu to be populated |
862 @type QMenu |
861 @type QMenu |
863 @param hitTest reference to the hit test object |
862 @param hitTest reference to the hit test object |
864 @type WebHitTestResult |
863 @type WebHitTestResult |
865 """ |
864 """ |
|
865 from .OpenSearch.OpenSearchEngineAction import OpenSearchEngineAction |
|
866 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog |
|
867 |
866 if not menu.isEmpty(): |
868 if not menu.isEmpty(): |
867 menu.addSeparator() |
869 menu.addSeparator() |
868 |
870 |
869 menu.addAction(self.__mw.copyAct) |
871 menu.addAction(self.__mw.copyAct) |
870 menu.addSeparator() |
872 menu.addSeparator() |
876 if engineName: |
878 if engineName: |
877 menu.addAction( |
879 menu.addAction( |
878 self.tr("Search with '{0}'").format(engineName), |
880 self.tr("Search with '{0}'").format(engineName), |
879 self.__searchDefaultRequested, |
881 self.__searchDefaultRequested, |
880 ) |
882 ) |
881 |
|
882 from .OpenSearch.OpenSearchEngineAction import OpenSearchEngineAction |
|
883 |
883 |
884 self.__searchMenu = menu.addMenu(self.tr("Search with...")) |
884 self.__searchMenu = menu.addMenu(self.tr("Search with...")) |
885 engineNames = self.__mw.openSearchManager().allEnginesNames() |
885 engineNames = self.__mw.openSearchManager().allEnginesNames() |
886 for engineName in engineNames: |
886 for engineName in engineNames: |
887 engine = self.__mw.openSearchManager().engine(engineName) |
887 engine = self.__mw.openSearchManager().engine(engineName) |
890 self.__searchMenu.addAction(act) |
890 self.__searchMenu.addAction(act) |
891 self.__searchMenu.triggered.connect(self.__searchRequested) |
891 self.__searchMenu.triggered.connect(self.__searchRequested) |
892 |
892 |
893 menu.addSeparator() |
893 menu.addSeparator() |
894 |
894 |
895 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog |
|
896 |
|
897 languages = Preferences.toList( |
895 languages = Preferences.toList( |
898 Preferences.getSettings().value( |
896 Preferences.getSettings().value( |
899 "WebBrowser/AcceptLanguages", |
897 "WebBrowser/AcceptLanguages", |
900 WebBrowserLanguagesDialog.defaultAcceptLanguages(), |
898 WebBrowserLanguagesDialog.defaultAcceptLanguages(), |
901 ) |
899 ) |
936 Private method to populate the basic context menu. |
934 Private method to populate the basic context menu. |
937 |
935 |
938 @param menu reference to the menu to be populated |
936 @param menu reference to the menu to be populated |
939 @type QMenu |
937 @type QMenu |
940 """ |
938 """ |
|
939 from .UserAgent.UserAgentMenu import UserAgentMenu |
|
940 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog |
|
941 |
941 menu.addAction(self.__mw.newTabAct) |
942 menu.addAction(self.__mw.newTabAct) |
942 menu.addAction(self.__mw.newAct) |
943 menu.addAction(self.__mw.newAct) |
943 menu.addSeparator() |
944 menu.addSeparator() |
944 if self.__mw.saveAsAct is not None: |
945 if self.__mw.saveAsAct is not None: |
945 menu.addAction(self.__mw.saveAsAct) |
946 menu.addAction(self.__mw.saveAsAct) |
985 EricPixmapCache.getIcon("mailSend"), self.tr("Send Page URL") |
986 EricPixmapCache.getIcon("mailSend"), self.tr("Send Page URL") |
986 ) |
987 ) |
987 act.setData(self.url()) |
988 act.setData(self.url()) |
988 act.triggered.connect(functools.partial(self.__sendLink, act)) |
989 act.triggered.connect(functools.partial(self.__sendLink, act)) |
989 menu.addSeparator() |
990 menu.addSeparator() |
990 |
|
991 from .UserAgent.UserAgentMenu import UserAgentMenu |
|
992 |
991 |
993 self.__userAgentMenu = UserAgentMenu(self.tr("User Agent"), url=self.url()) |
992 self.__userAgentMenu = UserAgentMenu(self.tr("User Agent"), url=self.url()) |
994 menu.addMenu(self.__userAgentMenu) |
993 menu.addMenu(self.__userAgentMenu) |
995 menu.addSeparator() |
994 menu.addSeparator() |
996 menu.addAction(self.__mw.backAct) |
995 menu.addAction(self.__mw.backAct) |
1021 EricPixmapCache.getIcon("w3"), self.tr("Validate Page") |
1020 EricPixmapCache.getIcon("w3"), self.tr("Validate Page") |
1022 ) |
1021 ) |
1023 act.setData(w3url) |
1022 act.setData(w3url) |
1024 act.triggered.connect(functools.partial(self.__openLinkInNewTab, act)) |
1023 act.triggered.connect(functools.partial(self.__openLinkInNewTab, act)) |
1025 |
1024 |
1026 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog |
|
1027 |
|
1028 languages = Preferences.toList( |
1025 languages = Preferences.toList( |
1029 Preferences.getSettings().value( |
1026 Preferences.getSettings().value( |
1030 "WebBrowser/AcceptLanguages", |
1027 "WebBrowser/AcceptLanguages", |
1031 WebBrowserLanguagesDialog.defaultAcceptLanguages(), |
1028 WebBrowserLanguagesDialog.defaultAcceptLanguages(), |
1032 ) |
1029 ) |
1053 @param act reference to the action to be populated upon success |
1050 @param act reference to the action to be populated upon success |
1054 @type QAction |
1051 @type QAction |
1055 @param pos position to be tested |
1052 @param pos position to be tested |
1056 @type QPoint |
1053 @type QPoint |
1057 """ |
1054 """ |
|
1055 from .Tools import Scripts |
|
1056 |
1058 self.__clickedPos = self.mapToViewport(pos) |
1057 self.__clickedPos = self.mapToViewport(pos) |
1059 |
|
1060 from .Tools import Scripts |
|
1061 |
1058 |
1062 script = Scripts.getFormData(self.__clickedPos) |
1059 script = Scripts.getFormData(self.__clickedPos) |
1063 self.page().runJavaScript( |
1060 self.page().runJavaScript( |
1064 script, |
1061 script, |
1065 WebBrowserPage.SafeJsWorld, |
1062 WebBrowserPage.SafeJsWorld, |
1157 Private slot to bookmark a link via the context menu. |
1154 Private slot to bookmark a link via the context menu. |
1158 |
1155 |
1159 @param act reference to the action that triggered |
1156 @param act reference to the action that triggered |
1160 @type QAction |
1157 @type QAction |
1161 """ |
1158 """ |
|
1159 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
|
1160 |
1162 url = act.data() |
1161 url = act.data() |
1163 if url.isEmpty(): |
1162 if url.isEmpty(): |
1164 return |
1163 return |
1165 |
|
1166 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
|
1167 |
1164 |
1168 dlg = AddBookmarkDialog() |
1165 dlg = AddBookmarkDialog() |
1169 dlg.setUrl(bytes(url.toEncoded()).decode()) |
1166 dlg.setUrl(bytes(url.toEncoded()).decode()) |
1170 dlg.exec() |
1167 dlg.exec() |
1171 |
1168 |
1358 |
1355 |
1359 @param res reference to the result list containing all |
1356 @param res reference to the result list containing all |
1360 meta attributes |
1357 meta attributes |
1361 @type list |
1358 @type list |
1362 """ |
1359 """ |
|
1360 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
|
1361 |
1363 description = "" |
1362 description = "" |
1364 for meta in res: |
1363 for meta in res: |
1365 if meta["name"] == "description": |
1364 if meta["name"] == "description": |
1366 description = meta["content"] |
1365 description = meta["content"] |
1367 |
|
1368 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
|
1369 |
1366 |
1370 dlg = AddBookmarkDialog() |
1367 dlg = AddBookmarkDialog() |
1371 dlg.setUrl(bytes(self.url().toEncoded()).decode()) |
1368 dlg.setUrl(bytes(self.url().toEncoded()).decode()) |
1372 dlg.setTitle(self.title()) |
1369 dlg.setTitle(self.title()) |
1373 dlg.setDescription(description) |
1370 dlg.setDescription(description) |
1709 Private slot handling the loaded web site icon. |
1706 Private slot handling the loaded web site icon. |
1710 |
1707 |
1711 @param icon web site icon |
1708 @param icon web site icon |
1712 @type QIcon |
1709 @type QIcon |
1713 """ |
1710 """ |
|
1711 from eric7.WebBrowser.Tools import WebIconProvider |
|
1712 |
1714 self.__siteIcon = icon |
1713 self.__siteIcon = icon |
1715 |
|
1716 from eric7.WebBrowser.Tools import WebIconProvider |
|
1717 |
1714 |
1718 WebIconProvider.instance().saveIcon(self) |
1715 WebIconProvider.instance().saveIcon(self) |
1719 |
1716 |
1720 self.faviconChanged.emit() |
1717 self.faviconChanged.emit() |
1721 |
1718 |
1724 Public method to get the web site icon. |
1721 Public method to get the web site icon. |
1725 |
1722 |
1726 @return web site icon |
1723 @return web site icon |
1727 @rtype QIcon |
1724 @rtype QIcon |
1728 """ |
1725 """ |
|
1726 from eric7.WebBrowser.Tools import WebIconProvider |
|
1727 |
1729 if not self.__siteIcon.isNull(): |
1728 if not self.__siteIcon.isNull(): |
1730 return QIcon(self.__siteIcon) |
1729 return QIcon(self.__siteIcon) |
1731 |
|
1732 from eric7.WebBrowser.Tools import WebIconProvider |
|
1733 |
1730 |
1734 return WebIconProvider.instance().iconForUrl(self.url()) |
1731 return WebIconProvider.instance().iconForUrl(self.url()) |
1735 |
1732 |
1736 def title(self): |
1733 def title(self): |
1737 """ |
1734 """ |
1865 self.__progress = 0 |
1862 self.__progress = 0 |
1866 |
1863 |
1867 QApplication.processEvents() |
1864 QApplication.processEvents() |
1868 QTimer.singleShot(200, self.__renderPreview) |
1865 QTimer.singleShot(200, self.__renderPreview) |
1869 |
1866 |
1870 from eric7.WebBrowser.ZoomManager import ZoomManager |
|
1871 |
|
1872 zoomValue = ZoomManager.instance().zoomValue(self.url()) |
1867 zoomValue = ZoomManager.instance().zoomValue(self.url()) |
1873 self.setZoomValue(zoomValue) |
1868 self.setZoomValue(zoomValue) |
1874 |
1869 |
1875 if ok: |
1870 if ok: |
1876 self.__mw.historyManager().addHistoryEntry(self) |
1871 self.__mw.historyManager().addHistoryEntry(self) |
1888 Private slot to adjust the 'lastModified' value of bookmarks. |
1883 Private slot to adjust the 'lastModified' value of bookmarks. |
1889 |
1884 |
1890 @param lastModified last modified value |
1885 @param lastModified last modified value |
1891 @type str |
1886 @type str |
1892 """ |
1887 """ |
|
1888 from .Bookmarks.BookmarkNode import BookmarkNode |
|
1889 |
1893 modified = QDateTime.fromString(lastModified, "MM/dd/yyyy hh:mm:ss") |
1890 modified = QDateTime.fromString(lastModified, "MM/dd/yyyy hh:mm:ss") |
1894 if modified.isValid(): |
1891 if modified.isValid(): |
1895 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
1896 |
|
1897 from .Bookmarks.BookmarkNode import BookmarkNode |
|
1898 |
|
1899 manager = WebBrowserWindow.bookmarksManager() |
1892 manager = WebBrowserWindow.bookmarksManager() |
1900 for bookmark in manager.bookmarksForUrl(self.url()): |
1893 for bookmark in manager.bookmarksForUrl(self.url()): |
1901 manager.setTimestamp(bookmark, BookmarkNode.TsModified, modified) |
1894 manager.setTimestamp(bookmark, BookmarkNode.TsModified, modified) |
1902 |
1895 |
1903 def isLoading(self): |
1896 def isLoading(self): |
2261 generated by getSessionData() |
2254 generated by getSessionData() |
2262 @type dict |
2255 @type dict |
2263 @return tuple containing the title, URL and web icon |
2256 @return tuple containing the title, URL and web icon |
2264 @rtype tuple of (str, str, QIcon) |
2257 @rtype tuple of (str, str, QIcon) |
2265 """ |
2258 """ |
|
2259 from eric7.WebBrowser.Tools import WebIconProvider |
|
2260 |
2266 title = sessionData.get("Title", "") |
2261 title = sessionData.get("Title", "") |
2267 urlStr = sessionData.get("Url", "") |
2262 urlStr = sessionData.get("Url", "") |
2268 |
2263 |
2269 if "Icon" in sessionData: |
2264 if "Icon" in sessionData: |
2270 iconArray = QByteArray.fromBase64(sessionData["Icon"].encode("ascii")) |
2265 iconArray = QByteArray.fromBase64(sessionData["Icon"].encode("ascii")) |
2271 stream = QDataStream(iconArray, QIODevice.OpenModeFlag.ReadOnly) |
2266 stream = QDataStream(iconArray, QIODevice.OpenModeFlag.ReadOnly) |
2272 icon = QIcon() |
2267 icon = QIcon() |
2273 stream >> icon |
2268 stream >> icon |
2274 else: |
2269 else: |
2275 from eric7.WebBrowser.Tools import WebIconProvider |
|
2276 |
|
2277 icon = WebIconProvider.instance().iconForUrl(QUrl.fromUserInput(urlStr)) |
2270 icon = WebIconProvider.instance().iconForUrl(QUrl.fromUserInput(urlStr)) |
2278 |
2271 |
2279 return title, urlStr, icon |
2272 return title, urlStr, icon |
2280 |
2273 |
2281 ########################################################################### |
2274 ########################################################################### |
2315 Private slot to handle quota requests of the web page. |
2308 Private slot to handle quota requests of the web page. |
2316 |
2309 |
2317 @param quotaRequest reference to the quota request object |
2310 @param quotaRequest reference to the quota request object |
2318 @type QWebEngineQuotaRequest |
2311 @type QWebEngineQuotaRequest |
2319 """ |
2312 """ |
|
2313 from .Download.DownloadUtilities import dataString |
|
2314 |
2320 acceptRequest = Preferences.getWebBrowser("AcceptQuotaRequest") |
2315 acceptRequest = Preferences.getWebBrowser("AcceptQuotaRequest") |
2321 # map yes/no/ask from (0, 1, 2) |
2316 # map yes/no/ask from (0, 1, 2) |
2322 if acceptRequest == 0: |
2317 if acceptRequest == 0: |
2323 # always yes |
2318 # always yes |
2324 ok = True |
2319 ok = True |
2325 elif acceptRequest == 1: |
2320 elif acceptRequest == 1: |
2326 # always no |
2321 # always no |
2327 ok = False |
2322 ok = False |
2328 else: |
2323 else: |
2329 # ask user |
2324 # ask user |
2330 from .Download.DownloadUtilities import dataString |
|
2331 |
|
2332 sizeStr = dataString(quotaRequest.requestedSize()) |
2325 sizeStr = dataString(quotaRequest.requestedSize()) |
2333 |
2326 |
2334 ok = EricMessageBox.yesNo( |
2327 ok = EricMessageBox.yesNo( |
2335 self, |
2328 self, |
2336 self.tr("Quota Request"), |
2329 self.tr("Quota Request"), |
2356 |
2349 |
2357 @param clientCertificateSelection list of client SSL certificates |
2350 @param clientCertificateSelection list of client SSL certificates |
2358 found in system's client certificate store |
2351 found in system's client certificate store |
2359 @type QWebEngineClientCertificateSelection |
2352 @type QWebEngineClientCertificateSelection |
2360 """ |
2353 """ |
|
2354 from eric7.EricNetwork.EricSslCertificateSelectionDialog import ( |
|
2355 EricSslCertificateSelectionDialog, |
|
2356 ) |
|
2357 |
2361 certificates = clientCertificateSelection.certificates() |
2358 certificates = clientCertificateSelection.certificates() |
2362 if len(certificates) == 0: |
2359 if len(certificates) == 0: |
2363 clientCertificateSelection.selectNone() |
2360 clientCertificateSelection.selectNone() |
2364 elif len(certificates) == 1: |
2361 elif len(certificates) == 1: |
2365 clientCertificateSelection.select(certificates[0]) |
2362 clientCertificateSelection.select(certificates[0]) |
2366 else: |
2363 else: |
2367 certificate = None |
2364 certificate = None |
2368 from eric7.EricNetwork.EricSslCertificateSelectionDialog import ( |
|
2369 EricSslCertificateSelectionDialog, |
|
2370 ) |
|
2371 |
|
2372 dlg = EricSslCertificateSelectionDialog(certificates, self) |
2365 dlg = EricSslCertificateSelectionDialog(certificates, self) |
2373 if dlg.exec() == QDialog.DialogCode.Accepted: |
2366 if dlg.exec() == QDialog.DialogCode.Accepted: |
2374 certificate = dlg.getSelectedCertificate() |
2367 certificate = dlg.getSelectedCertificate() |
2375 |
2368 |
2376 if certificate is None: |
2369 if certificate is None: |
2390 Private slot to handle file system access requests of the web page. |
2383 Private slot to handle file system access requests of the web page. |
2391 |
2384 |
2392 @param accessRequest reference to the file system access request object |
2385 @param accessRequest reference to the file system access request object |
2393 @type QWebEngineFileSystemAccessRequest |
2386 @type QWebEngineFileSystemAccessRequest |
2394 """ |
2387 """ |
2395 from PyQt6.QtWebEngineCore import QWebEngineFileSystemAccessRequest |
2388 from PyQt6.QtWebEngineCore import ( # __IGNORE_WARNING_I102__ |
|
2389 QWebEngineFileSystemAccessRequest, |
|
2390 ) |
2396 |
2391 |
2397 acceptRequest = Preferences.getWebBrowser("AcceptFileSystemAccessRequest") |
2392 acceptRequest = Preferences.getWebBrowser("AcceptFileSystemAccessRequest") |
2398 # map yes/no/ask from (0, 1, 2) |
2393 # map yes/no/ask from (0, 1, 2) |
2399 if acceptRequest == 0: |
2394 if acceptRequest == 0: |
2400 # always yes |
2395 # always yes |