18 ) |
18 ) |
19 from PyQt6.QtGui import ( |
19 from PyQt6.QtGui import ( |
20 QDesktopServices, QClipboard, QIcon, QContextMenuEvent, QPixmap, QCursor |
20 QDesktopServices, QClipboard, QIcon, QContextMenuEvent, QPixmap, QCursor |
21 ) |
21 ) |
22 from PyQt6.QtWidgets import QStyle, QMenu, QApplication, QDialog |
22 from PyQt6.QtWidgets import QStyle, QMenu, QApplication, QDialog |
23 from PyQt6.QtWebEngineCore import QWebEnginePage, QWebEngineDownloadItem |
23 from PyQt6.QtWebEngineCore import QWebEnginePage, QWebEngineDownloadRequest |
24 from PyQt6.QtWebEngineWidgets import QWebEngineView |
24 from PyQt6.QtWebEngineWidgets import QWebEngineView |
25 |
25 |
26 from EricWidgets import EricMessageBox, EricFileDialog |
26 from EricWidgets import EricMessageBox, EricFileDialog |
27 from EricWidgets.EricApplication import ericApp |
27 from EricWidgets.EricApplication import ericApp |
28 |
28 |
141 |
141 |
142 def __createNewPage(self): |
142 def __createNewPage(self): |
143 """ |
143 """ |
144 Private method to create a new page object. |
144 Private method to create a new page object. |
145 """ |
145 """ |
146 self.__page = WebBrowserPage(self) |
146 self.__page = WebBrowserPage(self, self) |
147 self.setPage(self.__page) |
147 self.setPage(self.__page) |
148 |
148 |
149 self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort) |
149 self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort) |
150 self.__page.safeBrowsingBad.connect(self.safeBrowsingBad) |
150 self.__page.safeBrowsingBad.connect(self.safeBrowsingBad) |
151 self.__page.printPageRequested.connect(self.__printPage) |
151 self.__page.printPageRequested.connect(self.__printPage) |
1914 """ |
1914 """ |
1915 Private method to get the file name to save the page to. |
1915 Private method to get the file name to save the page to. |
1916 |
1916 |
1917 @return tuple containing the file name to save to and the |
1917 @return tuple containing the file name to save to and the |
1918 save page format |
1918 save page format |
1919 @rtype tuple of (str, QWebEngineDownloadItem.SavePageFormat) |
1919 @rtype tuple of (str, QWebEngineDownloadRequest.SavePageFormat) |
1920 """ |
1920 """ |
1921 documentLocation = QStandardPaths.writableLocation( |
1921 documentLocation = QStandardPaths.writableLocation( |
1922 QStandardPaths.StandardLocation.DocumentsLocation) |
1922 QStandardPaths.StandardLocation.DocumentsLocation) |
1923 filterList = [ |
1923 filterList = [ |
1924 self.tr("Web Archive (*.mhtml *.mht)"), |
1924 self.tr("Web Archive (*.mhtml *.mht)"), |
1942 defaultFileName += ".mht" |
1942 defaultFileName += ".mht" |
1943 else: |
1943 else: |
1944 defaultFileName += ".mhtml" |
1944 defaultFileName += ".mhtml" |
1945 |
1945 |
1946 fileName = "" |
1946 fileName = "" |
1947 saveFormat = QWebEngineDownloadItem.SavePageFormat.MimeHtmlSaveFormat |
1947 saveFormat = QWebEngineDownloadRequest.SavePageFormat.MimeHtmlSaveFormat |
1948 |
1948 |
1949 fileName, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
1949 fileName, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
1950 None, |
1950 None, |
1951 self.tr("Save Web Page"), |
1951 self.tr("Save Web Page"), |
1952 defaultFileName, |
1952 defaultFileName, |
1954 None) |
1954 None) |
1955 if fileName: |
1955 if fileName: |
1956 index = filterList.index(selectedFilter) |
1956 index = filterList.index(selectedFilter) |
1957 if index == 0: |
1957 if index == 0: |
1958 saveFormat = ( |
1958 saveFormat = ( |
1959 QWebEngineDownloadItem.SavePageFormat.MimeHtmlSaveFormat |
1959 QWebEngineDownloadRequest.SavePageFormat.MimeHtmlSaveFormat |
1960 ) |
1960 ) |
1961 elif index == 1: |
1961 elif index == 1: |
1962 saveFormat = ( |
1962 saveFormat = ( |
1963 QWebEngineDownloadItem.SavePageFormat.SingleHtmlSaveFormat |
1963 QWebEngineDownloadRequest.SavePageFormat.SingleHtmlSaveFormat |
1964 ) |
1964 ) |
1965 else: |
1965 else: |
1966 saveFormat = ( |
1966 saveFormat = ( |
1967 QWebEngineDownloadItem.SavePageFormat |
1967 QWebEngineDownloadRequest.SavePageFormat |
1968 .CompleteHtmlSaveFormat |
1968 .CompleteHtmlSaveFormat |
1969 ) |
1969 ) |
1970 |
1970 |
1971 extension = os.path.splitext(fileName)[1] |
1971 extension = os.path.splitext(fileName)[1] |
1972 if not extension: |
1972 if not extension: |