src/eric7/WebBrowser/WebBrowserWindow.py

branch
eric7
changeset 9482
a2bc06a54d9d
parent 9473
3f23dbf37dbe
child 9573
9960d19d66b5
equal deleted inserted replaced
9481:0b936ff1bbb9 9482:a2bc06a54d9d
58 from eric7 import Globals, Preferences, Utilities 58 from eric7 import Globals, Preferences, Utilities
59 from eric7.EricGui import EricPixmapCache 59 from eric7.EricGui import EricPixmapCache
60 from eric7.EricGui.EricAction import EricAction 60 from eric7.EricGui.EricAction import EricAction
61 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor 61 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor
62 from eric7.EricNetwork.EricNetworkIcon import EricNetworkIcon 62 from eric7.EricNetwork.EricNetworkIcon import EricNetworkIcon
63 from eric7.EricNetwork.EricSslUtilities import initSSL
63 from eric7.EricWidgets import EricErrorMessage, EricFileDialog, EricMessageBox 64 from eric7.EricWidgets import EricErrorMessage, EricFileDialog, EricMessageBox
64 from eric7.EricWidgets.EricApplication import ericApp 65 from eric7.EricWidgets.EricApplication import ericApp
65 from eric7.EricWidgets.EricMainWindow import EricMainWindow 66 from eric7.EricWidgets.EricMainWindow import EricMainWindow
66 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget 67 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget
67 from eric7.Globals import getConfig 68 from eric7.Globals import getConfig
68 from eric7.Preferences import Shortcuts 69 from eric7.Preferences import Shortcuts
70 from eric7.Preferences.ShortcutsDialog import ShortcutsDialog
69 from eric7.UI import Config 71 from eric7.UI import Config
70 from eric7.UI.Info import Version 72 from eric7.UI.Info import Version
71 from eric7.UI.NotificationWidget import NotificationTypes 73 from eric7.UI.NotificationWidget import NotificationTypes
72 from eric7.WebBrowser.Tools import WebIconProvider 74 from eric7.WebBrowser.Tools import WebIconProvider
73 from eric7.WebBrowser.ZoomManager import ZoomManager 75 from eric7.WebBrowser.ZoomManager import ZoomManager
166 @param single flag indicating to start in single application mode 168 @param single flag indicating to start in single application mode
167 @type bool 169 @type bool
168 @param saname name to be used for the single application server 170 @param saname name to be used for the single application server
169 @type str 171 @type str
170 """ 172 """
171 self.__hideNavigationTimer = None
172
173 super().__init__(parent)
174 self.setObjectName(name)
175 if private:
176 self.setWindowTitle(self.tr("eric Web Browser (Private Mode)"))
177 else:
178 self.setWindowTitle(self.tr("eric Web Browser"))
179
180 self.__settingsDir = settingsDir
181 self.setWindowIcon(EricPixmapCache.getIcon("ericWeb"))
182
183 self.__mHistory = []
184 self.__lastConfigurationPageName = ""
185
186 WebBrowserWindow._isPrivate = private
187
188 self.__shortcutsDialog = None
189
190 WebBrowserWindow.setUseQtHelp(qthelp or bool(searchWord))
191
192 self.webProfile(private)
193 self.networkManager()
194
195 self.__htmlFullScreen = False
196 self.__windowStates = Qt.WindowState.WindowNoState
197 self.__isClosing = False
198
199 from .AdBlock.AdBlockIcon import AdBlockIcon 173 from .AdBlock.AdBlockIcon import AdBlockIcon
200 from .Bookmarks.BookmarksToolBar import BookmarksToolBar 174 from .Bookmarks.BookmarksToolBar import BookmarksToolBar
201 from .Navigation.NavigationBar import NavigationBar 175 from .Navigation.NavigationBar import NavigationBar
202 from .Navigation.NavigationContainer import NavigationContainer 176 from .Navigation.NavigationContainer import NavigationContainer
203 from .QtHelp.HelpIndexWidget import HelpIndexWidget 177 from .QtHelp.HelpIndexWidget import HelpIndexWidget
205 from .QtHelp.HelpTocWidget import HelpTocWidget 179 from .QtHelp.HelpTocWidget import HelpTocWidget
206 from .SearchWidget import SearchWidget 180 from .SearchWidget import SearchWidget
207 from .StatusBar.ImagesIcon import ImagesIcon 181 from .StatusBar.ImagesIcon import ImagesIcon
208 from .StatusBar.JavaScriptIcon import JavaScriptIcon 182 from .StatusBar.JavaScriptIcon import JavaScriptIcon
209 from .VirusTotal.VirusTotalApi import VirusTotalAPI 183 from .VirusTotal.VirusTotalApi import VirusTotalAPI
184 from .WebBrowserJavaScriptConsole import WebBrowserJavaScriptConsole
210 from .WebBrowserTabWidget import WebBrowserTabWidget 185 from .WebBrowserTabWidget import WebBrowserTabWidget
211 from .WebBrowserView import WebBrowserView 186 from .WebBrowserView import WebBrowserView
212 187
188 self.__hideNavigationTimer = None
189
190 super().__init__(parent)
191 self.setObjectName(name)
192 if private:
193 self.setWindowTitle(self.tr("eric Web Browser (Private Mode)"))
194 else:
195 self.setWindowTitle(self.tr("eric Web Browser"))
196
197 self.__settingsDir = settingsDir
198 self.setWindowIcon(EricPixmapCache.getIcon("ericWeb"))
199
200 self.__mHistory = []
201 self.__lastConfigurationPageName = ""
202
203 WebBrowserWindow._isPrivate = private
204
205 self.__shortcutsDialog = None
206
207 WebBrowserWindow.setUseQtHelp(qthelp or bool(searchWord))
208
209 self.webProfile(private)
210 self.networkManager()
211
212 self.__htmlFullScreen = False
213 self.__windowStates = Qt.WindowState.WindowNoState
214 self.__isClosing = False
215
213 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) 216 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
214 217
215 # initialize some SSL stuff 218 # initialize some SSL stuff
216 from eric7.EricNetwork.EricSslUtilities import initSSL
217
218 initSSL() 219 initSSL()
219 220
220 if WebBrowserWindow._useQtHelp: 221 if WebBrowserWindow._useQtHelp:
221 self.__helpEngine = QHelpEngine( 222 self.__helpEngine = QHelpEngine(
222 WebBrowserWindow.getQtHelpCollectionFileName(), self 223 WebBrowserWindow.getQtHelpCollectionFileName(), self
307 self.__searchDock.setObjectName("SearchWindow") 308 self.__searchDock.setObjectName("SearchWindow")
308 self.__searchDock.setWidget(self.__searchWindow) 309 self.__searchDock.setWidget(self.__searchWindow)
309 self.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.__searchDock) 310 self.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.__searchDock)
310 311
311 # JavaScript Console window 312 # JavaScript Console window
312 from .WebBrowserJavaScriptConsole import WebBrowserJavaScriptConsole
313
314 self.__javascriptConsole = WebBrowserJavaScriptConsole(self) 313 self.__javascriptConsole = WebBrowserJavaScriptConsole(self)
315 self.__javascriptConsoleDock = QDockWidget(self.tr("JavaScript Console")) 314 self.__javascriptConsoleDock = QDockWidget(self.tr("JavaScript Console"))
316 self.__javascriptConsoleDock.setObjectName("JavascriptConsole") 315 self.__javascriptConsoleDock.setObjectName("JavascriptConsole")
317 self.__javascriptConsoleDock.setAllowedAreas( 316 self.__javascriptConsoleDock.setAllowedAreas(
318 Qt.DockWidgetArea.BottomDockWidgetArea | Qt.DockWidgetArea.TopDockWidgetArea 317 Qt.DockWidgetArea.BottomDockWidgetArea | Qt.DockWidgetArea.TopDockWidgetArea
1844 ) 1843 )
1845 self.clearIconsAct.triggered.connect(self.__clearIconsDatabase) 1844 self.clearIconsAct.triggered.connect(self.__clearIconsDatabase)
1846 self.__actions.append(self.clearIconsAct) 1845 self.__actions.append(self.clearIconsAct)
1847 1846
1848 self.manageIconsAct = EricAction( 1847 self.manageIconsAct = EricAction(
1849 self.tr("Manage saved Favicons"), 1848 self.tr("Manage Saved Favicons"),
1850 EricPixmapCache.getIcon("icons"), 1849 EricPixmapCache.getIcon("icons"),
1851 self.tr("Manage saved Favicons"), 1850 self.tr("Manage Saved Favicons"),
1852 0, 1851 0,
1853 0, 1852 0,
1854 self, 1853 self,
1855 "webbrowser_manage_icons_db", 1854 "webbrowser_manage_icons_db",
1856 ) 1855 )
1857 self.manageIconsAct.setStatusTip( 1856 self.manageIconsAct.setStatusTip(
1858 self.tr("Show a dialog to manage the saved favicons") 1857 self.tr("Show a dialog to manage the saved favicons")
1859 ) 1858 )
1860 self.manageIconsAct.setWhatsThis( 1859 self.manageIconsAct.setWhatsThis(
1861 self.tr( 1860 self.tr(
1862 """<b>Manage saved Favicons</b>""" 1861 """<b>Manage Saved Favicons</b>"""
1863 """<p>This shows a dialog to manage the saved favicons of""" 1862 """<p>This shows a dialog to manage the saved favicons of"""
1864 """ previously visited URLs.</p>""" 1863 """ previously visited URLs.</p>"""
1865 ) 1864 )
1866 ) 1865 )
1867 self.manageIconsAct.triggered.connect(self.__showWebIconsDialog) 1866 self.manageIconsAct.triggered.connect(self.__showWebIconsDialog)
2302 2301
2303 def __initMenus(self): 2302 def __initMenus(self):
2304 """ 2303 """
2305 Private method to create the menus. 2304 Private method to create the menus.
2306 """ 2305 """
2306 from .Bookmarks.BookmarksMenu import BookmarksMenuBarMenu
2307 from .History.HistoryMenu import HistoryMenu
2308 from .UserAgent.UserAgentMenu import UserAgentMenu
2309
2307 mb = self.menuBar() 2310 mb = self.menuBar()
2308 2311
2309 menu = mb.addMenu(self.tr("&File")) 2312 menu = mb.addMenu(self.tr("&File"))
2310 menu.addAction(self.newTabAct) 2313 menu.addAction(self.newTabAct)
2311 menu.addAction(self.newAct) 2314 menu.addAction(self.newAct)
2371 menu.addSeparator() 2374 menu.addSeparator()
2372 menu.addAction(self.pageSourceAct) 2375 menu.addAction(self.pageSourceAct)
2373 menu.addAction(self.fullScreenAct) 2376 menu.addAction(self.fullScreenAct)
2374 self.addActions(menu.actions()) 2377 self.addActions(menu.actions())
2375 2378
2376 from .History.HistoryMenu import HistoryMenu
2377
2378 self.historyMenu = HistoryMenu(self, self.__tabWidget) 2379 self.historyMenu = HistoryMenu(self, self.__tabWidget)
2379 self.historyMenu.setTitle(self.tr("H&istory")) 2380 self.historyMenu.setTitle(self.tr("H&istory"))
2380 self.historyMenu.openUrl.connect(self.openUrl) 2381 self.historyMenu.openUrl.connect(self.openUrl)
2381 self.historyMenu.newTab.connect(self.openUrlNewTab) 2382 self.historyMenu.newTab.connect(self.openUrlNewTab)
2382 self.historyMenu.newBackgroundTab.connect(self.openUrlNewBackgroundTab) 2383 self.historyMenu.newBackgroundTab.connect(self.openUrlNewBackgroundTab)
2388 historyActions.append(self.backAct) 2389 historyActions.append(self.backAct)
2389 historyActions.append(self.forwardAct) 2390 historyActions.append(self.forwardAct)
2390 historyActions.append(self.homeAct) 2391 historyActions.append(self.homeAct)
2391 self.historyMenu.setInitialActions(historyActions) 2392 self.historyMenu.setInitialActions(historyActions)
2392 self.addActions(historyActions) 2393 self.addActions(historyActions)
2393
2394 from .Bookmarks.BookmarksMenu import BookmarksMenuBarMenu
2395 2394
2396 self.bookmarksMenu = BookmarksMenuBarMenu(self) 2395 self.bookmarksMenu = BookmarksMenuBarMenu(self)
2397 self.bookmarksMenu.setTitle(self.tr("&Bookmarks")) 2396 self.bookmarksMenu.setTitle(self.tr("&Bookmarks"))
2398 self.bookmarksMenu.openUrl.connect(self.openUrl) 2397 self.bookmarksMenu.openUrl.connect(self.openUrl)
2399 self.bookmarksMenu.newTab.connect(self.openUrlNewTab) 2398 self.bookmarksMenu.newTab.connect(self.openUrlNewTab)
2437 menu.addSeparator() 2436 menu.addSeparator()
2438 menu.addAction(self.safeBrowsingAct) 2437 menu.addAction(self.safeBrowsingAct)
2439 menu.addSeparator() 2438 menu.addSeparator()
2440 self.__settingsMenu = menu 2439 self.__settingsMenu = menu
2441 self.__settingsMenu.aboutToShow.connect(self.__aboutToShowSettingsMenu) 2440 self.__settingsMenu.aboutToShow.connect(self.__aboutToShowSettingsMenu)
2442
2443 from .UserAgent.UserAgentMenu import UserAgentMenu
2444 2441
2445 self.__userAgentMenu = UserAgentMenu(self.tr("Global User Agent")) 2442 self.__userAgentMenu = UserAgentMenu(self.tr("Global User Agent"))
2446 menu.addMenu(self.__userAgentMenu) 2443 menu.addMenu(self.__userAgentMenu)
2447 menu.addAction(self.userAgentManagerAct) 2444 menu.addAction(self.userAgentManagerAct)
2448 menu.addSeparator() 2445 menu.addSeparator()
3061 @param title title for the bookmark 3058 @param title title for the bookmark
3062 @type str 3059 @type str
3063 @param res result of the JavaScript 3060 @param res result of the JavaScript
3064 @type list 3061 @type list
3065 """ 3062 """
3063 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
3064
3066 description = "" 3065 description = ""
3067 for meta in res: 3066 for meta in res:
3068 if meta["name"] == "description": 3067 if meta["name"] == "description":
3069 description = meta["content"] 3068 description = meta["content"]
3070
3071 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
3072 3069
3073 dlg = AddBookmarkDialog() 3070 dlg = AddBookmarkDialog()
3074 dlg.setUrl(url) 3071 dlg.setUrl(url)
3075 dlg.setTitle(title) 3072 dlg.setTitle(title)
3076 dlg.setDescription(description) 3073 dlg.setDescription(description)
3145 @param title title for the bookmark 3142 @param title title for the bookmark
3146 @type str 3143 @type str
3147 @param res result of the JavaScript 3144 @param res result of the JavaScript
3148 @type list 3145 @type list
3149 """ 3146 """
3147 from .Bookmarks.BookmarkNode import BookmarkNode
3148
3150 description = "" 3149 description = ""
3151 for meta in res: 3150 for meta in res:
3152 if meta["name"] == "description": 3151 if meta["name"] == "description":
3153 description = meta["content"] 3152 description = meta["content"]
3154
3155 from .Bookmarks.BookmarkNode import BookmarkNode
3156 3153
3157 bookmark = BookmarkNode(BookmarkNode.Bookmark) 3154 bookmark = BookmarkNode(BookmarkNode.Bookmark)
3158 bookmark.url = url 3155 bookmark.url = url
3159 bookmark.title = title 3156 bookmark.title = title
3160 bookmark.desc = description 3157 bookmark.desc = description
3807 """ 3804 """
3808 Class method to get a reference to the network manager object. 3805 Class method to get a reference to the network manager object.
3809 3806
3810 @return reference to the network access manager (NetworkManager) 3807 @return reference to the network access manager (NetworkManager)
3811 """ 3808 """
3809 from .Network.NetworkManager import NetworkManager
3810
3812 if cls._networkManager is None: 3811 if cls._networkManager is None:
3813 from .Network.NetworkManager import NetworkManager
3814
3815 cls._networkManager = NetworkManager(cls.helpEngine()) 3812 cls._networkManager = NetworkManager(cls.helpEngine())
3816 3813
3817 return cls._networkManager 3814 return cls._networkManager
3818 3815
3819 @classmethod 3816 @classmethod
3821 """ 3818 """
3822 Class method to get a reference to the cookie jar. 3819 Class method to get a reference to the cookie jar.
3823 3820
3824 @return reference to the cookie jar (CookieJar) 3821 @return reference to the cookie jar (CookieJar)
3825 """ 3822 """
3823 from .CookieJar.CookieJar import CookieJar
3824
3826 if cls._cookieJar is None: 3825 if cls._cookieJar is None:
3827 from .CookieJar.CookieJar import CookieJar
3828
3829 cls._cookieJar = CookieJar() 3826 cls._cookieJar = CookieJar()
3830 3827
3831 return cls._cookieJar 3828 return cls._cookieJar
3832 3829
3833 @pyqtSlot() 3830 @pyqtSlot()
3840 @pyqtSlot() 3837 @pyqtSlot()
3841 def __showWebIconsDialog(self): 3838 def __showWebIconsDialog(self):
3842 """ 3839 """
3843 Private slot to show a dialog to manage the favicons database. 3840 Private slot to show a dialog to manage the favicons database.
3844 """ 3841 """
3845 WebIconProvider.instance().showWebIconDialog() 3842 WebIconProvider.instance().showWebIconDialog(self)
3846 3843
3847 @pyqtSlot(QUrl) 3844 @pyqtSlot(QUrl)
3848 def urlHandler(self, url): 3845 def urlHandler(self, url):
3849 """ 3846 """
3850 Public slot used as desktop URL handler. 3847 Public slot used as desktop URL handler.
3957 def __manageQtHelpDocumentation(self): 3954 def __manageQtHelpDocumentation(self):
3958 """ 3955 """
3959 Private slot to manage the QtHelp documentation database. 3956 Private slot to manage the QtHelp documentation database.
3960 """ 3957 """
3961 if WebBrowserWindow._useQtHelp: 3958 if WebBrowserWindow._useQtHelp:
3962 from .QtHelp.QtHelpDocumentationConfigurationDialog import ( 3959 from .QtHelp.QtHelpDocumentationConfigurationDialog import ( # __IGNORE_WARNING__
3963 QtHelpDocumentationConfigurationDialog, 3960 QtHelpDocumentationConfigurationDialog,
3964 ) 3961 )
3965 3962
3966 dlg = QtHelpDocumentationConfigurationDialog(self.__helpEngine, self) 3963 dlg = QtHelpDocumentationConfigurationDialog(self.__helpEngine, self)
3967 dlg.exec() 3964 dlg.exec()
4055 """ 4052 """
4056 Private slot to look for new documentation to be loaded into the 4053 Private slot to look for new documentation to be loaded into the
4057 help database. 4054 help database.
4058 """ 4055 """
4059 if WebBrowserWindow._useQtHelp: 4056 if WebBrowserWindow._useQtHelp:
4060 from .QtHelp.HelpDocsInstaller import HelpDocsInstaller 4057 from .QtHelp.HelpDocsInstaller import ( # __IGNORE_WARNING_I101__
4058 HelpDocsInstaller,
4059 )
4061 4060
4062 self.__helpInstaller = HelpDocsInstaller(self.__helpEngine.collectionFile()) 4061 self.__helpInstaller = HelpDocsInstaller(self.__helpEngine.collectionFile())
4063 self.__helpInstaller.errorMessage.connect(self.__showInstallationError) 4062 self.__helpInstaller.errorMessage.connect(self.__showInstallationError)
4064 self.__helpInstaller.docsInstalled.connect(self.__docsInstalled) 4063 self.__helpInstaller.docsInstalled.connect(self.__docsInstalled)
4065 4064
4190 @pyqtSlot() 4189 @pyqtSlot()
4191 def __showCertificateErrorsDialog(self): 4190 def __showCertificateErrorsDialog(self):
4192 """ 4191 """
4193 Private slot to show the certificate errors management dialog. 4192 Private slot to show the certificate errors management dialog.
4194 """ 4193 """
4195 self.networkManager().showSslErrorExceptionsDialog() 4194 self.networkManager().showSslErrorExceptionsDialog(self)
4196 4195
4197 @pyqtSlot() 4196 @pyqtSlot()
4198 def __showAdBlockDialog(self): 4197 def __showAdBlockDialog(self):
4199 """ 4198 """
4200 Private slot to show the AdBlock configuration dialog. 4199 Private slot to show the AdBlock configuration dialog.
4201 """ 4200 """
4202 self.adBlockManager().showDialog() 4201 self.adBlockManager().showDialog(self)
4203 4202
4204 @pyqtSlot() 4203 @pyqtSlot()
4205 def __showPersonalInformationDialog(self): 4204 def __showPersonalInformationDialog(self):
4206 """ 4205 """
4207 Private slot to show the Personal Information configuration dialog. 4206 Private slot to show the Personal Information configuration dialog.
4208 """ 4207 """
4209 self.personalInformationManager().showConfigurationDialog() 4208 self.personalInformationManager().showConfigurationDialog(parent=self)
4210 4209
4211 @pyqtSlot() 4210 @pyqtSlot()
4212 def __showGreaseMonkeyConfigDialog(self): 4211 def __showGreaseMonkeyConfigDialog(self):
4213 """ 4212 """
4214 Private slot to show the GreaseMonkey scripts configuration dialog. 4213 Private slot to show the GreaseMonkey scripts configuration dialog.
4215 """ 4214 """
4216 self.greaseMonkeyManager().showConfigurationDialog() 4215 self.greaseMonkeyManager().showConfigurationDialog(parent=self)
4217 4216
4218 @pyqtSlot() 4217 @pyqtSlot()
4219 def __showFeaturePermissionDialog(self): 4218 def __showFeaturePermissionDialog(self):
4220 """ 4219 """
4221 Private slot to show the feature permission dialog. 4220 Private slot to show the feature permission dialog.
4222 """ 4221 """
4223 self.featurePermissionManager().showFeaturePermissionsDialog() 4222 self.featurePermissionManager().showFeaturePermissionsDialog(self)
4224 4223
4225 @pyqtSlot() 4224 @pyqtSlot()
4226 def __showZoomValuesDialog(self): 4225 def __showZoomValuesDialog(self):
4227 """ 4226 """
4228 Private slot to show the zoom values management dialog. 4227 Private slot to show the zoom values management dialog.
4294 """ 4293 """
4295 Class method to get a reference to the bookmarks manager. 4294 Class method to get a reference to the bookmarks manager.
4296 4295
4297 @return reference to the bookmarks manager (BookmarksManager) 4296 @return reference to the bookmarks manager (BookmarksManager)
4298 """ 4297 """
4298 from .Bookmarks.BookmarksManager import BookmarksManager
4299
4299 if cls._bookmarksManager is None: 4300 if cls._bookmarksManager is None:
4300 from .Bookmarks.BookmarksManager import BookmarksManager
4301
4302 cls._bookmarksManager = BookmarksManager() 4301 cls._bookmarksManager = BookmarksManager()
4303 4302
4304 return cls._bookmarksManager 4303 return cls._bookmarksManager
4305 4304
4306 @pyqtSlot(QUrl) 4305 @pyqtSlot(QUrl)
4383 """ 4382 """
4384 Class method to get a reference to the history manager. 4383 Class method to get a reference to the history manager.
4385 4384
4386 @return reference to the history manager (HistoryManager) 4385 @return reference to the history manager (HistoryManager)
4387 """ 4386 """
4387 from .History.HistoryManager import HistoryManager
4388
4388 if cls._historyManager is None: 4389 if cls._historyManager is None:
4389 from .History.HistoryManager import HistoryManager
4390
4391 cls._historyManager = HistoryManager() 4390 cls._historyManager = HistoryManager()
4392 4391
4393 return cls._historyManager 4392 return cls._historyManager
4394 4393
4395 @classmethod 4394 @classmethod
4397 """ 4396 """
4398 Class method to get a reference to the password manager. 4397 Class method to get a reference to the password manager.
4399 4398
4400 @return reference to the password manager (PasswordManager) 4399 @return reference to the password manager (PasswordManager)
4401 """ 4400 """
4401 from .Passwords.PasswordManager import PasswordManager
4402
4402 if cls._passwordManager is None: 4403 if cls._passwordManager is None:
4403 from .Passwords.PasswordManager import PasswordManager
4404
4405 cls._passwordManager = PasswordManager() 4404 cls._passwordManager = PasswordManager()
4406 4405
4407 return cls._passwordManager 4406 return cls._passwordManager
4408 4407
4409 @classmethod 4408 @classmethod
4411 """ 4410 """
4412 Class method to get a reference to the AdBlock manager. 4411 Class method to get a reference to the AdBlock manager.
4413 4412
4414 @return reference to the AdBlock manager (AdBlockManager) 4413 @return reference to the AdBlock manager (AdBlockManager)
4415 """ 4414 """
4415 from .AdBlock.AdBlockManager import AdBlockManager
4416
4416 if cls._adblockManager is None: 4417 if cls._adblockManager is None:
4417 from .AdBlock.AdBlockManager import AdBlockManager
4418
4419 cls._adblockManager = AdBlockManager() 4418 cls._adblockManager = AdBlockManager()
4420 4419
4421 return cls._adblockManager 4420 return cls._adblockManager
4422 4421
4423 def adBlockIcon(self): 4422 def adBlockIcon(self):
4433 """ 4432 """
4434 Class method to get a reference to the download manager. 4433 Class method to get a reference to the download manager.
4435 4434
4436 @return reference to the download manager (DownloadManager) 4435 @return reference to the download manager (DownloadManager)
4437 """ 4436 """
4437 from .Download.DownloadManager import DownloadManager
4438
4438 if cls._downloadManager is None: 4439 if cls._downloadManager is None:
4439 from .Download.DownloadManager import DownloadManager
4440
4441 cls._downloadManager = DownloadManager() 4440 cls._downloadManager = DownloadManager()
4442 4441
4443 return cls._downloadManager 4442 return cls._downloadManager
4444 4443
4445 @classmethod 4444 @classmethod
4448 Class method to get a reference to the personal information manager. 4447 Class method to get a reference to the personal information manager.
4449 4448
4450 @return reference to the personal information manager 4449 @return reference to the personal information manager
4451 (PersonalInformationManager) 4450 (PersonalInformationManager)
4452 """ 4451 """
4452 from .PersonalInformationManager import PersonalInformationManager
4453
4453 if cls._personalInformationManager is None: 4454 if cls._personalInformationManager is None:
4454 from .PersonalInformationManager import PersonalInformationManager
4455
4456 cls._personalInformationManager = ( 4455 cls._personalInformationManager = (
4457 PersonalInformationManager.PersonalInformationManager() 4456 PersonalInformationManager.PersonalInformationManager()
4458 ) 4457 )
4459 4458
4460 return cls._personalInformationManager 4459 return cls._personalInformationManager
4464 """ 4463 """
4465 Class method to get a reference to the GreaseMonkey manager. 4464 Class method to get a reference to the GreaseMonkey manager.
4466 4465
4467 @return reference to the GreaseMonkey manager (GreaseMonkeyManager) 4466 @return reference to the GreaseMonkey manager (GreaseMonkeyManager)
4468 """ 4467 """
4468 from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager
4469
4469 if cls._greaseMonkeyManager is None: 4470 if cls._greaseMonkeyManager is None:
4470 from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager
4471
4472 cls._greaseMonkeyManager = GreaseMonkeyManager() 4471 cls._greaseMonkeyManager = GreaseMonkeyManager()
4473 4472
4474 return cls._greaseMonkeyManager 4473 return cls._greaseMonkeyManager
4475 4474
4476 @classmethod 4475 @classmethod
4479 Class method to get a reference to the feature permission manager. 4478 Class method to get a reference to the feature permission manager.
4480 4479
4481 @return reference to the feature permission manager 4480 @return reference to the feature permission manager
4482 @rtype FeaturePermissionManager 4481 @rtype FeaturePermissionManager
4483 """ 4482 """
4483 from .FeaturePermissions.FeaturePermissionManager import (
4484 FeaturePermissionManager,
4485 )
4486
4484 if cls._featurePermissionManager is None: 4487 if cls._featurePermissionManager is None:
4485 from .FeaturePermissions.FeaturePermissionManager import (
4486 FeaturePermissionManager,
4487 )
4488
4489 cls._featurePermissionManager = FeaturePermissionManager() 4488 cls._featurePermissionManager = FeaturePermissionManager()
4490 4489
4491 return cls._featurePermissionManager 4490 return cls._featurePermissionManager
4492 4491
4493 @classmethod 4492 @classmethod
4496 Class method to get a reference to the image search engine. 4495 Class method to get a reference to the image search engine.
4497 4496
4498 @return reference to the image finder object 4497 @return reference to the image finder object
4499 @rtype ImageSearchEngine 4498 @rtype ImageSearchEngine
4500 """ 4499 """
4500 from .ImageSearch.ImageSearchEngine import ImageSearchEngine
4501
4501 if cls._imageSearchEngine is None: 4502 if cls._imageSearchEngine is None:
4502 from .ImageSearch.ImageSearchEngine import ImageSearchEngine
4503
4504 cls._imageSearchEngine = ImageSearchEngine() 4503 cls._imageSearchEngine = ImageSearchEngine()
4505 4504
4506 return cls._imageSearchEngine 4505 return cls._imageSearchEngine
4507 4506
4508 @classmethod 4507 @classmethod
4511 Class method to get a reference to the auto scroller. 4510 Class method to get a reference to the auto scroller.
4512 4511
4513 @return reference to the auto scroller object 4512 @return reference to the auto scroller object
4514 @rtype AutoScroller 4513 @rtype AutoScroller
4515 """ 4514 """
4515 from .AutoScroll.AutoScroller import AutoScroller
4516
4516 if cls._autoScroller is None: 4517 if cls._autoScroller is None:
4517 from .AutoScroll.AutoScroller import AutoScroller
4518
4519 cls._autoScroller = AutoScroller() 4518 cls._autoScroller = AutoScroller()
4520 4519
4521 return cls._autoScroller 4520 return cls._autoScroller
4522 4521
4523 @classmethod 4522 @classmethod
4526 Class method to get a reference to the tab manager widget. 4525 Class method to get a reference to the tab manager widget.
4527 4526
4528 @return reference to the tab manager widget 4527 @return reference to the tab manager widget
4529 @rtype TabManagerWidget 4528 @rtype TabManagerWidget
4530 """ 4529 """
4530 from .TabManager.TabManagerWidget import TabManagerWidget
4531
4531 if cls._tabManager is None: 4532 if cls._tabManager is None:
4532 from .TabManager.TabManagerWidget import TabManagerWidget
4533
4534 cls._tabManager = TabManagerWidget(cls.mainWindow()) 4533 cls._tabManager = TabManagerWidget(cls.mainWindow())
4535 4534
4536 # do the connections 4535 # do the connections
4537 for window in cls.mainWindows(): 4536 for window in cls.mainWindows():
4538 cls._tabManager.mainWindowCreated(window, False) 4537 cls._tabManager.mainWindowCreated(window, False)
4860 """ 4859 """
4861 Class method to get a reference to the RSS feeds manager. 4860 Class method to get a reference to the RSS feeds manager.
4862 4861
4863 @return reference to the RSS feeds manager (FeedsManager) 4862 @return reference to the RSS feeds manager (FeedsManager)
4864 """ 4863 """
4864 from .Feeds.FeedsManager import FeedsManager
4865
4865 if cls._feedsManager is None: 4866 if cls._feedsManager is None:
4866 from .Feeds.FeedsManager import FeedsManager
4867
4868 cls._feedsManager = FeedsManager() 4867 cls._feedsManager = FeedsManager()
4869 4868
4870 return cls._feedsManager 4869 return cls._feedsManager
4871 4870
4872 @pyqtSlot() 4871 @pyqtSlot()
4912 """ 4911 """
4913 Class method to get a reference to the user agents manager. 4912 Class method to get a reference to the user agents manager.
4914 4913
4915 @return reference to the user agents manager (UserAgentManager) 4914 @return reference to the user agents manager (UserAgentManager)
4916 """ 4915 """
4916 from .UserAgent.UserAgentManager import UserAgentManager
4917
4917 if cls._userAgentsManager is None: 4918 if cls._userAgentsManager is None:
4918 from .UserAgent.UserAgentManager import UserAgentManager
4919
4920 cls._userAgentsManager = UserAgentManager() 4919 cls._userAgentsManager = UserAgentManager()
4921 4920
4922 return cls._userAgentsManager 4921 return cls._userAgentsManager
4923 4922
4924 @pyqtSlot() 4923 @pyqtSlot()
4936 """ 4935 """
4937 Class method to get a reference to the data synchronization manager. 4936 Class method to get a reference to the data synchronization manager.
4938 4937
4939 @return reference to the data synchronization manager (SyncManager) 4938 @return reference to the data synchronization manager (SyncManager)
4940 """ 4939 """
4940 from .Sync.SyncManager import SyncManager
4941
4941 if cls._syncManager is None: 4942 if cls._syncManager is None:
4942 from .Sync.SyncManager import SyncManager
4943
4944 cls._syncManager = SyncManager() 4943 cls._syncManager = SyncManager()
4945 4944
4946 return cls._syncManager 4945 return cls._syncManager
4947 4946
4948 @pyqtSlot() 4947 @pyqtSlot()
4957 """ 4956 """
4958 Class method to get a reference to the speed dial. 4957 Class method to get a reference to the speed dial.
4959 4958
4960 @return reference to the speed dial (SpeedDial) 4959 @return reference to the speed dial (SpeedDial)
4961 """ 4960 """
4961 from .SpeedDial.SpeedDial import SpeedDial
4962
4962 if cls._speedDial is None: 4963 if cls._speedDial is None:
4963 from .SpeedDial.SpeedDial import SpeedDial
4964
4965 cls._speedDial = SpeedDial() 4964 cls._speedDial = SpeedDial()
4966 4965
4967 return cls._speedDial 4966 return cls._speedDial
4968 4967
4969 def keyPressEvent(self, evt): 4968 def keyPressEvent(self, evt):
5172 """ 5171 """
5173 Private method to set a user style sheet. 5172 Private method to set a user style sheet.
5174 5173
5175 @param styleSheetFile name of the user style sheet file (string) 5174 @param styleSheetFile name of the user style sheet file (string)
5176 """ 5175 """
5176 from .WebBrowserPage import WebBrowserPage
5177
5177 name = "_eric_userstylesheet" 5178 name = "_eric_userstylesheet"
5178 userStyle = "" 5179 userStyle = ""
5179 5180
5180 userStyle += WebBrowserTools.readAllFileContents(styleSheetFile).replace( 5181 userStyle += WebBrowserTools.readAllFileContents(styleSheetFile).replace(
5181 "\n", "" 5182 "\n", ""
5184 scripts = self.webProfile().scripts().find(name) 5185 scripts = self.webProfile().scripts().find(name)
5185 if scripts: 5186 if scripts:
5186 self.webProfile().scripts().remove(scripts[0]) 5187 self.webProfile().scripts().remove(scripts[0])
5187 5188
5188 if userStyle: 5189 if userStyle:
5189 from .WebBrowserPage import WebBrowserPage
5190
5191 script = QWebEngineScript() 5190 script = QWebEngineScript()
5192 script.setName(name) 5191 script.setName(name)
5193 script.setInjectionPoint(QWebEngineScript.InjectionPoint.DocumentCreation) 5192 script.setInjectionPoint(QWebEngineScript.InjectionPoint.DocumentCreation)
5194 script.setWorldId(WebBrowserPage.SafeJsWorld) 5193 script.setWorldId(WebBrowserPage.SafeJsWorld)
5195 script.setRunsOnSubFrames(True) 5194 script.setRunsOnSubFrames(True)
5217 @type NotificationTypes 5216 @type NotificationTypes
5218 @param timeout time in seconds the notification should be shown 5217 @param timeout time in seconds the notification should be shown
5219 (None = use configured timeout, 0 = indefinitely) 5218 (None = use configured timeout, 0 = indefinitely)
5220 @type int 5219 @type int
5221 """ 5220 """
5221 from eric7.UI.NotificationWidget import NotificationWidget
5222
5222 if cls._notification is None: 5223 if cls._notification is None:
5223 from eric7.UI.NotificationWidget import NotificationWidget
5224
5225 cls._notification = NotificationWidget() 5224 cls._notification = NotificationWidget()
5226 5225
5227 if timeout is None: 5226 if timeout is None:
5228 timeout = Preferences.getUI("NotificationTimeout") 5227 timeout = Preferences.getUI("NotificationTimeout")
5229 cls._notification.showNotification( 5228 cls._notification.showNotification(
5277 @param private flag indicating the privacy mode 5276 @param private flag indicating the privacy mode
5278 @type bool 5277 @type bool
5279 @return reference to the web profile object 5278 @return reference to the web profile object
5280 @rtype QWebEngineProfile 5279 @rtype QWebEngineProfile
5281 """ 5280 """
5281 from .WebBrowserPage import WebBrowserPage
5282
5282 if cls._webProfile is None: 5283 if cls._webProfile is None:
5283 if private: 5284 if private:
5284 cls._webProfile = QWebEngineProfile() 5285 cls._webProfile = QWebEngineProfile()
5285 else: 5286 else:
5286 cls._webProfile = QWebEngineProfile.defaultProfile() 5287 cls._webProfile = QWebEngineProfile.defaultProfile()
5322 cls._webProfile.setSpellCheckLanguages( 5323 cls._webProfile.setSpellCheckLanguages(
5323 Preferences.getWebBrowser("SpellCheckLanguages") 5324 Preferences.getWebBrowser("SpellCheckLanguages")
5324 ) 5325 )
5325 5326
5326 # Setup QWebChannel user scripts 5327 # Setup QWebChannel user scripts
5327 from .WebBrowserPage import WebBrowserPage
5328
5329 # WebChannel for SafeJsWorld 5328 # WebChannel for SafeJsWorld
5330 script = QWebEngineScript() 5329 script = QWebEngineScript()
5331 script.setName("_eric_webchannel") 5330 script.setName("_eric_webchannel")
5332 script.setInjectionPoint(QWebEngineScript.InjectionPoint.DocumentCreation) 5331 script.setInjectionPoint(QWebEngineScript.InjectionPoint.DocumentCreation)
5333 script.setWorldId(WebBrowserPage.SafeJsWorld) 5332 script.setWorldId(WebBrowserPage.SafeJsWorld)
5375 Class method to get a reference to the session manager. 5374 Class method to get a reference to the session manager.
5376 5375
5377 @return reference to the session manager 5376 @return reference to the session manager
5378 @rtype SessionManager 5377 @rtype SessionManager
5379 """ 5378 """
5379 from .Session.SessionManager import SessionManager
5380
5380 if cls._sessionManager is None and not cls._isPrivate: 5381 if cls._sessionManager is None and not cls._isPrivate:
5381 from .Session.SessionManager import SessionManager
5382
5383 cls._sessionManager = SessionManager() 5382 cls._sessionManager = SessionManager()
5384 5383
5385 return cls._sessionManager 5384 return cls._sessionManager
5386 5385
5387 @pyqtSlot() 5386 @pyqtSlot()
5401 Class method to get a reference to the safe browsing interface. 5400 Class method to get a reference to the safe browsing interface.
5402 5401
5403 @return reference to the safe browsing manager 5402 @return reference to the safe browsing manager
5404 @rtype SafeBrowsingManager 5403 @rtype SafeBrowsingManager
5405 """ 5404 """
5405 from .SafeBrowsing.SafeBrowsingManager import SafeBrowsingManager
5406
5406 if cls._safeBrowsingManager is None: 5407 if cls._safeBrowsingManager is None:
5407 from .SafeBrowsing.SafeBrowsingManager import SafeBrowsingManager
5408
5409 cls._safeBrowsingManager = SafeBrowsingManager() 5408 cls._safeBrowsingManager = SafeBrowsingManager()
5410 5409
5411 return cls._safeBrowsingManager 5410 return cls._safeBrowsingManager
5412 5411
5413 @pyqtSlot() 5412 @pyqtSlot()
5427 Class method to get a reference to the protocol handler manager. 5426 Class method to get a reference to the protocol handler manager.
5428 5427
5429 @return reference to the protocol handler manager 5428 @return reference to the protocol handler manager
5430 @rtype ProtocolHandlerManager 5429 @rtype ProtocolHandlerManager
5431 """ 5430 """
5431 from .Network.ProtocolHandlerManager import ProtocolHandlerManager
5432
5432 if cls._protocolHandlerManager is None: 5433 if cls._protocolHandlerManager is None:
5433 from .Network.ProtocolHandlerManager import ProtocolHandlerManager
5434
5435 cls._protocolHandlerManager = ProtocolHandlerManager() 5434 cls._protocolHandlerManager = ProtocolHandlerManager()
5436 5435
5437 return cls._protocolHandlerManager 5436 return cls._protocolHandlerManager
5438 5437
5439 @pyqtSlot() 5438 @pyqtSlot()
5499 def __configShortcuts(self): 5498 def __configShortcuts(self):
5500 """ 5499 """
5501 Private slot to configure the keyboard shortcuts. 5500 Private slot to configure the keyboard shortcuts.
5502 """ 5501 """
5503 if self.__shortcutsDialog is None: 5502 if self.__shortcutsDialog is None:
5504 from eric7.Preferences.ShortcutsDialog import ShortcutsDialog
5505
5506 self.__shortcutsDialog = ShortcutsDialog(self) 5503 self.__shortcutsDialog = ShortcutsDialog(self)
5507 self.__shortcutsDialog.populate(helpViewer=self) 5504 self.__shortcutsDialog.populate(helpViewer=self)
5508 self.__shortcutsDialog.show() 5505 self.__shortcutsDialog.show()
5509 5506
5510 @pyqtSlot() 5507 @pyqtSlot()
5542 if fpath.exists() 5539 if fpath.exists()
5543 else True 5540 else True
5544 ) 5541 )
5545 5542
5546 if ok: 5543 if ok:
5547 from eric7.Preferences import Shortcuts
5548
5549 Shortcuts.exportShortcuts(fn, helpViewer=self) 5544 Shortcuts.exportShortcuts(fn, helpViewer=self)
5550 5545
5551 @pyqtSlot() 5546 @pyqtSlot()
5552 def __importShortcuts(self): 5547 def __importShortcuts(self):
5553 """ 5548 """
5561 "Keyboard Shortcuts File (*.ekj);;" "XML Keyboard shortcut file (*.e4k)" 5556 "Keyboard Shortcuts File (*.ekj);;" "XML Keyboard shortcut file (*.e4k)"
5562 ), 5557 ),
5563 ) 5558 )
5564 5559
5565 if fn: 5560 if fn:
5566 from eric7.Preferences import Shortcuts
5567
5568 Shortcuts.importShortcuts(fn, helpViewer=self) 5561 Shortcuts.importShortcuts(fn, helpViewer=self)

eric ide

mercurial