src/eric7/WebBrowser/WebBrowserWindow.py

branch
eric7
changeset 10436
f6881d10e995
parent 10428
a071d4065202
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
527 @classmethod 527 @classmethod
528 def setIconDatabasePath(cls, enable=True): 528 def setIconDatabasePath(cls, enable=True):
529 """ 529 """
530 Class method to set the favicons path. 530 Class method to set the favicons path.
531 531
532 @param enable flag indicating to enabled icon storage (boolean) 532 @param enable flag indicating to enabled icon storage
533 @type bool
533 """ 534 """
534 if enable: 535 if enable:
535 iconDatabasePath = os.path.join( 536 iconDatabasePath = os.path.join(
536 Globals.getConfigDir(), "web_browser", "favicons" 537 Globals.getConfigDir(), "web_browser", "favicons"
537 ) 538 )
2300 2301
2301 def getActions(self): 2302 def getActions(self):
2302 """ 2303 """
2303 Public method to get a list of all actions. 2304 Public method to get a list of all actions.
2304 2305
2305 @return list of all actions (list of EricAction) 2306 @return list of all actions
2307 @rtype list of EricAction
2306 """ 2308 """
2307 return self.__actions[:] 2309 return self.__actions[:]
2308 2310
2309 def getActionsCategory(self): 2311 def getActionsCategory(self):
2310 """ 2312 """
2804 @pyqtSlot() 2806 @pyqtSlot()
2805 def newTab(self, link=None, addNextTo=None, background=False): 2807 def newTab(self, link=None, addNextTo=None, background=False):
2806 """ 2808 """
2807 Public slot called to open a new web browser tab. 2809 Public slot called to open a new web browser tab.
2808 2810
2809 @param link file to be displayed in the new window (string or QUrl) 2811 @param link file to be displayed in the new window
2812 @type str or QUrl
2810 @param addNextTo reference to the browser to open the tab after 2813 @param addNextTo reference to the browser to open the tab after
2811 (WebBrowserView) 2814 @type WebBrowserView
2812 @param background flag indicating to open the tab in the 2815 @param background flag indicating to open the tab in the background
2813 background (bool) 2816 @type bool
2814 @return reference to the new browser 2817 @return reference to the new browser
2815 @rtype WebBrowserView 2818 @rtype WebBrowserView
2816 """ 2819 """
2817 if addNextTo: 2820 if addNextTo:
2818 return self.__tabWidget.newBrowserAfter( 2821 return self.__tabWidget.newBrowserAfter(
3185 3188
3186 def closeEvent(self, e): 3189 def closeEvent(self, e):
3187 """ 3190 """
3188 Protected event handler for the close event. 3191 Protected event handler for the close event.
3189 3192
3190 @param e the close event (QCloseEvent) 3193 @param e the close event
3191 <br />This event is simply accepted after the history has been 3194 <br />This event is simply accepted after the history has been
3192 saved and all window references have been deleted. 3195 saved and all window references have been deleted.
3196 @type QCloseEvent
3193 """ 3197 """
3194 res = self.__shutdownWindow() 3198 res = self.__shutdownWindow()
3195 3199
3196 if res: 3200 if res:
3197 e.accept() 3201 e.accept()
3210 3214
3211 def __shutdownWindow(self): 3215 def __shutdownWindow(self):
3212 """ 3216 """
3213 Private method to shut down a web browser window. 3217 Private method to shut down a web browser window.
3214 3218
3215 @return flag indicating successful shutdown (boolean) 3219 @return flag indicating successful shutdown
3220 @rtype bool
3216 """ 3221 """
3217 if ( 3222 if (
3218 not WebBrowserWindow._performingShutdown 3223 not WebBrowserWindow._performingShutdown
3219 and not self.__forcedClose 3224 and not self.__forcedClose
3220 and not self.__tabWidget.shallShutDown() 3225 and not self.__tabWidget.shallShutDown()
3594 3599
3595 def currentBrowser(self): 3600 def currentBrowser(self):
3596 """ 3601 """
3597 Public method to get a reference to the current web browser. 3602 Public method to get a reference to the current web browser.
3598 3603
3599 @return reference to the current help browser (WebBrowserView) 3604 @return reference to the current help browser
3605 @rtype WebBrowserView
3600 """ 3606 """
3601 return self.__tabWidget.currentBrowser() 3607 return self.__tabWidget.currentBrowser()
3602 3608
3603 def browserAt(self, index): 3609 def browserAt(self, index):
3604 """ 3610 """
3605 Public method to get a reference to the web browser with the given 3611 Public method to get a reference to the web browser with the given
3606 index. 3612 index.
3607 3613
3608 @param index index of the browser to get (integer) 3614 @param index index of the browser to get
3609 @return reference to the indexed web browser (WebBrowserView) 3615 @type int
3616 @return reference to the indexed web browser
3617 @rtype WebBrowserView
3610 """ 3618 """
3611 return self.__tabWidget.browserAt(index) 3619 return self.__tabWidget.browserAt(index)
3612 3620
3613 def browsers(self): 3621 def browsers(self):
3614 """ 3622 """
3615 Public method to get a list of references to all web browsers. 3623 Public method to get a list of references to all web browsers.
3616 3624
3617 @return list of references to web browsers (list of WebBrowserView) 3625 @return list of references to web browsers
3626 @rtype list of WebBrowserView
3618 """ 3627 """
3619 return self.__tabWidget.browsers() 3628 return self.__tabWidget.browsers()
3620 3629
3621 @pyqtSlot(int) 3630 @pyqtSlot(int)
3622 def __currentChanged(self, index): 3631 def __currentChanged(self, index):
3768 @classmethod 3777 @classmethod
3769 def setUseQtHelp(cls, use): 3778 def setUseQtHelp(cls, use):
3770 """ 3779 """
3771 Class method to set the QtHelp usage. 3780 Class method to set the QtHelp usage.
3772 3781
3773 @param use flag indicating usage (boolean) 3782 @param use flag indicating usage
3783 @type bool
3774 """ 3784 """
3775 if use: 3785 if use:
3776 cls._useQtHelp = use and QTHELP_AVAILABLE 3786 cls._useQtHelp = use and QTHELP_AVAILABLE
3777 else: 3787 else:
3778 cls._useQtHelp = False 3788 cls._useQtHelp = False
3780 @classmethod 3790 @classmethod
3781 def helpEngine(cls): 3791 def helpEngine(cls):
3782 """ 3792 """
3783 Class method to get a reference to the help engine. 3793 Class method to get a reference to the help engine.
3784 3794
3785 @return reference to the help engine (QHelpEngine) 3795 @return reference to the help engine
3796 @rtype QHelpEngine
3786 """ 3797 """
3787 if cls._useQtHelp: 3798 if cls._useQtHelp:
3788 if cls._helpEngine is None: 3799 if cls._helpEngine is None:
3789 cls._helpEngine = QHelpEngine( 3800 cls._helpEngine = QHelpEngine(
3790 WebBrowserWindow.getQtHelpCollectionFileName() 3801 WebBrowserWindow.getQtHelpCollectionFileName()
3810 @classmethod 3821 @classmethod
3811 def networkManager(cls): 3822 def networkManager(cls):
3812 """ 3823 """
3813 Class method to get a reference to the network manager object. 3824 Class method to get a reference to the network manager object.
3814 3825
3815 @return reference to the network access manager (NetworkManager) 3826 @return reference to the network access manager
3827 @rtype NetworkManager
3816 """ 3828 """
3817 from .Network.NetworkManager import NetworkManager 3829 from .Network.NetworkManager import NetworkManager
3818 3830
3819 if cls._networkManager is None: 3831 if cls._networkManager is None:
3820 cls._networkManager = NetworkManager(cls.helpEngine()) 3832 cls._networkManager = NetworkManager(cls.helpEngine())
3824 @classmethod 3836 @classmethod
3825 def cookieJar(cls): 3837 def cookieJar(cls):
3826 """ 3838 """
3827 Class method to get a reference to the cookie jar. 3839 Class method to get a reference to the cookie jar.
3828 3840
3829 @return reference to the cookie jar (CookieJar) 3841 @return reference to the cookie jar
3842 @rtype CookieJar
3830 """ 3843 """
3831 from .CookieJar.CookieJar import CookieJar 3844 from .CookieJar.CookieJar import CookieJar
3832 3845
3833 if cls._cookieJar is None: 3846 if cls._cookieJar is None:
3834 cls._cookieJar = CookieJar() 3847 cls._cookieJar = CookieJar()
3920 3933
3921 def __activateDock(self, widget): 3934 def __activateDock(self, widget):
3922 """ 3935 """
3923 Private method to activate the dock widget of the given widget. 3936 Private method to activate the dock widget of the given widget.
3924 3937
3925 @param widget reference to the widget to be activated (QWidget) 3938 @param widget reference to the widget to be activated
3939 @type QWidget
3926 """ 3940 """
3927 widget.parent().show() 3941 widget.parent().show()
3928 widget.parent().raise_() 3942 widget.parent().raise_()
3929 widget.setFocus() 3943 widget.setFocus()
3930 3944
3974 def getSourceFileList(self): 3988 def getSourceFileList(self):
3975 """ 3989 """
3976 Public method to get a list of all opened source files. 3990 Public method to get a list of all opened source files.
3977 3991
3978 @return dictionary with tab id as key and host/namespace as value 3992 @return dictionary with tab id as key and host/namespace as value
3993 @rtype dict
3979 """ 3994 """
3980 return self.__tabWidget.getSourceFileList() 3995 return self.__tabWidget.getSourceFileList()
3981 3996
3982 @pyqtSlot() 3997 @pyqtSlot()
3983 def __indexingStarted(self): 3998 def __indexingStarted(self):
4178 def searchEnginesAction(self): 4193 def searchEnginesAction(self):
4179 """ 4194 """
4180 Public method to get a reference to the search engines configuration 4195 Public method to get a reference to the search engines configuration
4181 action. 4196 action.
4182 4197
4183 @return reference to the search engines configuration action (QAction) 4198 @return reference to the search engines configuration action
4199 @rtype QAction
4184 """ 4200 """
4185 return self.searchEnginesAct 4201 return self.searchEnginesAct
4186 4202
4187 @pyqtSlot() 4203 @pyqtSlot()
4188 def __showPasswordsDialog(self): 4204 def __showPasswordsDialog(self):
4289 @classmethod 4305 @classmethod
4290 def icon(cls, url): 4306 def icon(cls, url):
4291 """ 4307 """
4292 Class method to get the icon for an URL. 4308 Class method to get the icon for an URL.
4293 4309
4294 @param url URL to get icon for (QUrl) 4310 @param url URL to get icon for
4295 @return icon for the URL (QIcon) 4311 @type QUrl
4312 @return icon for the URL
4313 @rtype QIcon
4296 """ 4314 """
4297 return WebIconProvider.instance().iconForUrl(url) 4315 return WebIconProvider.instance().iconForUrl(url)
4298 4316
4299 @classmethod 4317 @classmethod
4300 def bookmarksManager(cls): 4318 def bookmarksManager(cls):
4301 """ 4319 """
4302 Class method to get a reference to the bookmarks manager. 4320 Class method to get a reference to the bookmarks manager.
4303 4321
4304 @return reference to the bookmarks manager (BookmarksManager) 4322 @return reference to the bookmarks manager
4323 @rtype BookmarksManager
4305 """ 4324 """
4306 from .Bookmarks.BookmarksManager import BookmarksManager 4325 from .Bookmarks.BookmarksManager import BookmarksManager
4307 4326
4308 if cls._bookmarksManager is None: 4327 if cls._bookmarksManager is None:
4309 cls._bookmarksManager = BookmarksManager() 4328 cls._bookmarksManager = BookmarksManager()
4388 @classmethod 4407 @classmethod
4389 def historyManager(cls): 4408 def historyManager(cls):
4390 """ 4409 """
4391 Class method to get a reference to the history manager. 4410 Class method to get a reference to the history manager.
4392 4411
4393 @return reference to the history manager (HistoryManager) 4412 @return reference to the history manager
4413 @rtype HistoryManager
4394 """ 4414 """
4395 from .History.HistoryManager import HistoryManager 4415 from .History.HistoryManager import HistoryManager
4396 4416
4397 if cls._historyManager is None: 4417 if cls._historyManager is None:
4398 cls._historyManager = HistoryManager() 4418 cls._historyManager = HistoryManager()
4402 @classmethod 4422 @classmethod
4403 def passwordManager(cls): 4423 def passwordManager(cls):
4404 """ 4424 """
4405 Class method to get a reference to the password manager. 4425 Class method to get a reference to the password manager.
4406 4426
4407 @return reference to the password manager (PasswordManager) 4427 @return reference to the password manager
4428 @rtype PasswordManager
4408 """ 4429 """
4409 from .Passwords.PasswordManager import PasswordManager 4430 from .Passwords.PasswordManager import PasswordManager
4410 4431
4411 if cls._passwordManager is None: 4432 if cls._passwordManager is None:
4412 cls._passwordManager = PasswordManager() 4433 cls._passwordManager = PasswordManager()
4416 @classmethod 4437 @classmethod
4417 def adBlockManager(cls): 4438 def adBlockManager(cls):
4418 """ 4439 """
4419 Class method to get a reference to the AdBlock manager. 4440 Class method to get a reference to the AdBlock manager.
4420 4441
4421 @return reference to the AdBlock manager (AdBlockManager) 4442 @return reference to the AdBlock manager
4443 @rtype AdBlockManager
4422 """ 4444 """
4423 from .AdBlock.AdBlockManager import AdBlockManager 4445 from .AdBlock.AdBlockManager import AdBlockManager
4424 4446
4425 if cls._adblockManager is None: 4447 if cls._adblockManager is None:
4426 cls._adblockManager = AdBlockManager() 4448 cls._adblockManager = AdBlockManager()
4429 4451
4430 def adBlockIcon(self): 4452 def adBlockIcon(self):
4431 """ 4453 """
4432 Public method to get a reference to the AdBlock icon. 4454 Public method to get a reference to the AdBlock icon.
4433 4455
4434 @return reference to the AdBlock icon (AdBlockIcon) 4456 @return reference to the AdBlock icon
4457 @rtype AdBlockIcon
4435 """ 4458 """
4436 return self.__adBlockIcon 4459 return self.__adBlockIcon
4437 4460
4438 @classmethod 4461 @classmethod
4439 def downloadManager(cls): 4462 def downloadManager(cls):
4440 """ 4463 """
4441 Class method to get a reference to the download manager. 4464 Class method to get a reference to the download manager.
4442 4465
4443 @return reference to the download manager (DownloadManager) 4466 @return reference to the download manager
4467 @rtype DownloadManager
4444 """ 4468 """
4445 from .Download.DownloadManager import DownloadManager 4469 from .Download.DownloadManager import DownloadManager
4446 4470
4447 if cls._downloadManager is None: 4471 if cls._downloadManager is None:
4448 cls._downloadManager = DownloadManager() 4472 cls._downloadManager = DownloadManager()
4453 def personalInformationManager(cls): 4477 def personalInformationManager(cls):
4454 """ 4478 """
4455 Class method to get a reference to the personal information manager. 4479 Class method to get a reference to the personal information manager.
4456 4480
4457 @return reference to the personal information manager 4481 @return reference to the personal information manager
4458 (PersonalInformationManager) 4482 @rtype PersonalInformationManager
4459 """ 4483 """
4460 from .PersonalInformationManager import PersonalInformationManager 4484 from .PersonalInformationManager import PersonalInformationManager
4461 4485
4462 if cls._personalInformationManager is None: 4486 if cls._personalInformationManager is None:
4463 cls._personalInformationManager = ( 4487 cls._personalInformationManager = (
4469 @classmethod 4493 @classmethod
4470 def greaseMonkeyManager(cls): 4494 def greaseMonkeyManager(cls):
4471 """ 4495 """
4472 Class method to get a reference to the GreaseMonkey manager. 4496 Class method to get a reference to the GreaseMonkey manager.
4473 4497
4474 @return reference to the GreaseMonkey manager (GreaseMonkeyManager) 4498 @return reference to the GreaseMonkey manager
4499 @rtype GreaseMonkeyManager
4475 """ 4500 """
4476 from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager 4501 from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager
4477 4502
4478 if cls._greaseMonkeyManager is None: 4503 if cls._greaseMonkeyManager is None:
4479 cls._greaseMonkeyManager = GreaseMonkeyManager() 4504 cls._greaseMonkeyManager = GreaseMonkeyManager()
4560 @classmethod 4585 @classmethod
4561 def mainWindow(cls): 4586 def mainWindow(cls):
4562 """ 4587 """
4563 Class method to get a reference to the main window. 4588 Class method to get a reference to the main window.
4564 4589
4565 @return reference to the main window (WebBrowserWindow) 4590 @return reference to the main window
4591 @rtype WebBrowserWindow
4566 """ 4592 """
4567 if cls.BrowserWindows: 4593 if cls.BrowserWindows:
4568 return cls.BrowserWindows[0] 4594 return cls.BrowserWindows[0]
4569 else: 4595 else:
4570 return None 4596 return None
4572 @classmethod 4598 @classmethod
4573 def mainWindows(cls): 4599 def mainWindows(cls):
4574 """ 4600 """
4575 Class method to get references to all main windows. 4601 Class method to get references to all main windows.
4576 4602
4577 @return references to all main window (list of WebBrowserWindow) 4603 @return references to all main window
4604 @rtype list of WebBrowserWindow
4578 """ 4605 """
4579 return cls.BrowserWindows 4606 return cls.BrowserWindows
4580 4607
4581 @pyqtSlot() 4608 @pyqtSlot()
4582 def __appFocusChanged(self): 4609 def __appFocusChanged(self):
4603 4630
4604 def openSearchManager(self): 4631 def openSearchManager(self):
4605 """ 4632 """
4606 Public method to get a reference to the opensearch manager object. 4633 Public method to get a reference to the opensearch manager object.
4607 4634
4608 @return reference to the opensearch manager object (OpenSearchManager) 4635 @return reference to the opensearch manager object
4636 @rtype OpenSearchManager
4609 """ 4637 """
4610 return self.__navigationBar.searchEdit().openSearchManager() 4638 return self.__navigationBar.searchEdit().openSearchManager()
4611 4639
4612 def __createTextEncodingAction(self, codec, defaultCodec, parentMenu, name=None): 4640 def __createTextEncodingAction(self, codec, defaultCodec, parentMenu, name=None):
4613 """ 4641 """
4865 @classmethod 4893 @classmethod
4866 def feedsManager(cls): 4894 def feedsManager(cls):
4867 """ 4895 """
4868 Class method to get a reference to the RSS feeds manager. 4896 Class method to get a reference to the RSS feeds manager.
4869 4897
4870 @return reference to the RSS feeds manager (FeedsManager) 4898 @return reference to the RSS feeds manager
4899 @rtype FeedsManager
4871 """ 4900 """
4872 from .Feeds.FeedsManager import FeedsManager 4901 from .Feeds.FeedsManager import FeedsManager
4873 4902
4874 if cls._feedsManager is None: 4903 if cls._feedsManager is None:
4875 cls._feedsManager = FeedsManager() 4904 cls._feedsManager = FeedsManager()
4917 @classmethod 4946 @classmethod
4918 def userAgentsManager(cls): 4947 def userAgentsManager(cls):
4919 """ 4948 """
4920 Class method to get a reference to the user agents manager. 4949 Class method to get a reference to the user agents manager.
4921 4950
4922 @return reference to the user agents manager (UserAgentManager) 4951 @return reference to the user agents manager
4952 @rtype UserAgentManager
4923 """ 4953 """
4924 from .UserAgent.UserAgentManager import UserAgentManager 4954 from .UserAgent.UserAgentManager import UserAgentManager
4925 4955
4926 if cls._userAgentsManager is None: 4956 if cls._userAgentsManager is None:
4927 cls._userAgentsManager = UserAgentManager() 4957 cls._userAgentsManager = UserAgentManager()
4941 @classmethod 4971 @classmethod
4942 def syncManager(cls): 4972 def syncManager(cls):
4943 """ 4973 """
4944 Class method to get a reference to the data synchronization manager. 4974 Class method to get a reference to the data synchronization manager.
4945 4975
4946 @return reference to the data synchronization manager (SyncManager) 4976 @return reference to the data synchronization manager
4977 @rtype SyncManager
4947 """ 4978 """
4948 from .Sync.SyncManager import SyncManager 4979 from .Sync.SyncManager import SyncManager
4949 4980
4950 if cls._syncManager is None: 4981 if cls._syncManager is None:
4951 cls._syncManager = SyncManager() 4982 cls._syncManager = SyncManager()
4962 @classmethod 4993 @classmethod
4963 def speedDial(cls): 4994 def speedDial(cls):
4964 """ 4995 """
4965 Class method to get a reference to the speed dial. 4996 Class method to get a reference to the speed dial.
4966 4997
4967 @return reference to the speed dial (SpeedDial) 4998 @return reference to the speed dial
4999 @rtype SpeedDial
4968 """ 5000 """
4969 from .SpeedDial.SpeedDial import SpeedDial 5001 from .SpeedDial.SpeedDial import SpeedDial
4970 5002
4971 if cls._speedDial is None: 5003 if cls._speedDial is None:
4972 cls._speedDial = SpeedDial() 5004 cls._speedDial = SpeedDial()
4975 5007
4976 def keyPressEvent(self, evt): 5008 def keyPressEvent(self, evt):
4977 """ 5009 """
4978 Protected method to handle key presses. 5010 Protected method to handle key presses.
4979 5011
4980 @param evt reference to the key press event (QKeyEvent) 5012 @param evt reference to the key press event
5013 @type QKeyEvent
4981 """ 5014 """
4982 number = -1 5015 number = -1
4983 key = evt.key() 5016 key = evt.key()
4984 5017
4985 if key == Qt.Key.Key_1: 5018 if key == Qt.Key.Key_1:
5083 5116
5084 def requestVirusTotalScan(self, url): 5117 def requestVirusTotalScan(self, url):
5085 """ 5118 """
5086 Public method to submit a request to scan an URL by VirusTotal. 5119 Public method to submit a request to scan an URL by VirusTotal.
5087 5120
5088 @param url URL to be scanned (QUrl) 5121 @param url URL to be scanned
5122 @type QUrl
5089 """ 5123 """
5090 self.__virusTotal.submitUrl(url) 5124 self.__virusTotal.submitUrl(url)
5091 5125
5092 @pyqtSlot(str) 5126 @pyqtSlot(str)
5093 def __virusTotalSubmitUrlError(self, msg): 5127 def __virusTotalSubmitUrlError(self, msg):
5177 5211
5178 def __setUserStyleSheet(self, styleSheetFile): 5212 def __setUserStyleSheet(self, styleSheetFile):
5179 """ 5213 """
5180 Private method to set a user style sheet. 5214 Private method to set a user style sheet.
5181 5215
5182 @param styleSheetFile name of the user style sheet file (string) 5216 @param styleSheetFile name of the user style sheet file
5217 @type str
5183 """ 5218 """
5184 from .WebBrowserPage import WebBrowserPage 5219 from .WebBrowserPage import WebBrowserPage
5185 5220
5186 name = "_eric_userstylesheet" 5221 name = "_eric_userstylesheet"
5187 userStyle = "" 5222 userStyle = ""

eric ide

mercurial