WebBrowser/WebBrowserWindow.py

branch
QtWebEngine
changeset 4913
e16573640cb8
parent 4910
e97af1181efd
child 4917
682750cc7bd5
equal deleted inserted replaced
4910:e97af1181efd 4913:e16573640cb8
16 import os 16 import os
17 import shutil 17 import shutil
18 import sys 18 import sys
19 19
20 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \ 20 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \
21 QUrl, QThread, QTextCodec, QProcess, QEvent 21 QUrl, QTextCodec, QProcess, QEvent
22 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics, \ 22 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics
23 QIcon
24 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \ 23 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \
25 QComboBox, QLabel, QSplitter, QMenu, QToolButton, QLineEdit, \ 24 QComboBox, QLabel, QSplitter, QMenu, QToolButton, QLineEdit, \
26 QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QAction, \ 25 QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QAction, \
27 QInputDialog 26 QInputDialog
28 ##from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest
29 from PyQt5.QtWebEngineWidgets import QWebEngineSettings, QWebEnginePage, \ 27 from PyQt5.QtWebEngineWidgets import QWebEngineSettings, QWebEnginePage, \
30 QWebEngineProfile, QWebEngineScript 28 QWebEngineProfile, QWebEngineScript
31 try: 29 try:
32 from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery 30 from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery
33 QTHELP_AVAILABLE = True 31 QTHELP_AVAILABLE = True
75 """ 73 """
76 webBrowserClosed = pyqtSignal() 74 webBrowserClosed = pyqtSignal()
77 75
78 BrowserWindows = [] 76 BrowserWindows = []
79 77
80 ## maxMenuFilePathLen = 75
81 ##
82 _fromEric = False 78 _fromEric = False
83 UseQtHelp = QTHELP_AVAILABLE 79 UseQtHelp = QTHELP_AVAILABLE
84 _isPrivate = False 80 _isPrivate = False
85 81
86 _webProfile = None 82 _webProfile = None
1682 menu.addAction(self.newAct) 1678 menu.addAction(self.newAct)
1683 menu.addAction(self.newPrivateAct) 1679 menu.addAction(self.newPrivateAct)
1684 menu.addAction(self.openAct) 1680 menu.addAction(self.openAct)
1685 menu.addAction(self.openTabAct) 1681 menu.addAction(self.openTabAct)
1686 menu.addSeparator() 1682 menu.addSeparator()
1683 # TODO: Qt 5.7: Save
1687 ## menu.addAction(self.saveAsAct) 1684 ## menu.addAction(self.saveAsAct)
1688 menu.addAction(self.savePageScreenAct) 1685 menu.addAction(self.savePageScreenAct)
1689 menu.addAction(self.saveVisiblePageScreenAct) 1686 menu.addAction(self.saveVisiblePageScreenAct)
1690 menu.addSeparator() 1687 menu.addSeparator()
1691 menu.addAction(self.printPreviewAct) 1688 menu.addAction(self.printPreviewAct)
1842 filetb.addAction(self.newAct) 1839 filetb.addAction(self.newAct)
1843 filetb.addAction(self.newPrivateAct) 1840 filetb.addAction(self.newPrivateAct)
1844 filetb.addAction(self.openAct) 1841 filetb.addAction(self.openAct)
1845 filetb.addAction(self.openTabAct) 1842 filetb.addAction(self.openTabAct)
1846 filetb.addSeparator() 1843 filetb.addSeparator()
1844 # TODO: Qt 5.7: Save
1847 ## filetb.addAction(self.saveAsAct) 1845 ## filetb.addAction(self.saveAsAct)
1848 filetb.addAction(self.savePageScreenAct) 1846 filetb.addAction(self.savePageScreenAct)
1849 filetb.addSeparator() 1847 filetb.addSeparator()
1850 filetb.addAction(self.printPreviewAct) 1848 filetb.addAction(self.printPreviewAct)
1851 filetb.addAction(self.printAct) 1849 filetb.addAction(self.printAct)
2157 url = "file:///" + Utilities.fromNativeSeparators(fn) 2155 url = "file:///" + Utilities.fromNativeSeparators(fn)
2158 else: 2156 else:
2159 url = "file://" + fn 2157 url = "file://" + fn
2160 self.newTab(url) 2158 self.newTab(url)
2161 2159
2160 # TODO: Qt 5.7: Save
2162 ## def __savePageAs(self): 2161 ## def __savePageAs(self):
2163 ## """ 2162 ## """
2164 ## Private slot to save the current page. 2163 ## Private slot to save the current page.
2165 ## """ 2164 ## """
2166 ## browser = self.currentBrowser() 2165 ## browser = self.currentBrowser()
2483 2482
2484 def __reload(self): 2483 def __reload(self):
2485 """ 2484 """
2486 Private slot called to handle the reload action. 2485 Private slot called to handle the reload action.
2487 """ 2486 """
2488 ## self.currentBrowser().reloadBypassingCache() 2487 self.currentBrowser().reloadBypassingCache()
2489 self.currentBrowser().reload()
2490 2488
2491 def __stopLoading(self): 2489 def __stopLoading(self):
2492 """ 2490 """
2493 Private slot called to handle loading of the current page. 2491 Private slot called to handle loading of the current page.
2494 """ 2492 """
2861 Private method to show the table of contents window. 2859 Private method to show the table of contents window.
2862 """ 2860 """
2863 if WebBrowserWindow.useQtHelp: 2861 if WebBrowserWindow.useQtHelp:
2864 self.__activateDock(self.__tocWindow) 2862 self.__activateDock(self.__tocWindow)
2865 2863
2866 ## def __hideTocWindow(self):
2867 ## """
2868 ## Private method to hide the table of contents window.
2869 ## """
2870 ## if WebBrowserWindow.UseQtHelp:
2871 ## self.__tocDock.hide()
2872 ##
2873 def __showIndexWindow(self): 2864 def __showIndexWindow(self):
2874 """ 2865 """
2875 Private method to show the index window. 2866 Private method to show the index window.
2876 """ 2867 """
2877 if WebBrowserWindow.useQtHelp: 2868 if WebBrowserWindow.useQtHelp:
2878 self.__activateDock(self.__indexWindow) 2869 self.__activateDock(self.__indexWindow)
2879 2870
2880 ## def __hideIndexWindow(self):
2881 ## """
2882 ## Private method to hide the index window.
2883 ## """
2884 ## if WebBrowserWindow.UseQtHelp:
2885 ## self.__indexDock.hide()
2886 ##
2887 def __showSearchWindow(self): 2871 def __showSearchWindow(self):
2888 """ 2872 """
2889 Private method to show the search window. 2873 Private method to show the search window.
2890 """ 2874 """
2891 if WebBrowserWindow.useQtHelp: 2875 if WebBrowserWindow.useQtHelp:
2892 self.__activateDock(self.__searchWindow) 2876 self.__activateDock(self.__searchWindow)
2893 2877
2894 ## def __hideSearchWindow(self):
2895 ## """
2896 ## Private method to hide the search window.
2897 ## """
2898 ## if WebBrowserWindow.UseQtHelp:
2899 ## self.__searchDock.hide()
2900 ##
2901 def __activateDock(self, widget): 2878 def __activateDock(self, widget):
2902 """ 2879 """
2903 Private method to activate the dock widget of the given widget. 2880 Private method to activate the dock widget of the given widget.
2904 2881
2905 @param widget reference to the widget to be activated (QWidget) 2882 @param widget reference to the widget to be activated (QWidget)

eric ide

mercurial