WebBrowser/WebBrowserWindow.py

branch
QtWebEngine
changeset 4741
f9e1adc69076
parent 4735
84e78ee0f361
child 4742
f9d1090f6ab9
equal deleted inserted replaced
4735:84e78ee0f361 4741:f9e1adc69076
1490 ## if not self.__initShortcutsOnly: 1490 ## if not self.__initShortcutsOnly:
1491 ## self.reindexDocumentationAct.triggered.connect( 1491 ## self.reindexDocumentationAct.triggered.connect(
1492 ## self.__searchEngine.reindexDocumentation) 1492 ## self.__searchEngine.reindexDocumentation)
1493 ## self.__actions.append(self.reindexDocumentationAct) 1493 ## self.__actions.append(self.reindexDocumentationAct)
1494 1494
1495 # TODO: Clear Private Data 1495 self.clearPrivateDataAct = E5Action(
1496 ## self.clearPrivateDataAct = E5Action( 1496 self.tr('Clear private data'),
1497 ## self.tr('Clear private data'), 1497 self.tr('&Clear private data'),
1498 ## self.tr('&Clear private data'), 1498 0, 0,
1499 ## 0, 0, 1499 self, 'webbrowser_clear_private_data')
1500 ## self, 'webbrowser_clear_private_data') 1500 self.clearPrivateDataAct.setStatusTip(self.tr(
1501 ## self.clearPrivateDataAct.setStatusTip(self.tr( 1501 'Clear private data'))
1502 ## 'Clear private data')) 1502 self.clearPrivateDataAct.setWhatsThis(self.tr(
1503 ## self.clearPrivateDataAct.setWhatsThis(self.tr( 1503 """<b>Clear private data</b>"""
1504 ## """<b>Clear private data</b>""" 1504 """<p>Clears the private data like browsing history, search"""
1505 ## """<p>Clears the private data like browsing history, search""" 1505 """ history or the favicons database.</p>"""
1506 ## """ history or the favicons database.</p>""" 1506 ))
1507 ## )) 1507 if not self.__initShortcutsOnly:
1508 ## if not self.__initShortcutsOnly: 1508 self.clearPrivateDataAct.triggered.connect(
1509 ## self.clearPrivateDataAct.triggered.connect( 1509 self.__clearPrivateData)
1510 ## self.__clearPrivateData) 1510 self.__actions.append(self.clearPrivateDataAct)
1511 ## self.__actions.append(self.clearPrivateDataAct) 1511
1512 ## 1512 self.clearIconsAct = E5Action(
1513 ## self.clearIconsAct = E5Action( 1513 self.tr('Clear icons database'),
1514 ## self.tr('Clear icons database'), 1514 self.tr('Clear &icons database'),
1515 ## self.tr('Clear &icons database'), 1515 0, 0,
1516 ## 0, 0, 1516 self, 'webbrowser_clear_icons_db')
1517 ## self, 'webbrowser_clear_icons_db') 1517 self.clearIconsAct.setStatusTip(self.tr(
1518 ## self.clearIconsAct.setStatusTip(self.tr( 1518 'Clear the database of favicons'))
1519 ## 'Clear the database of favicons')) 1519 self.clearIconsAct.setWhatsThis(self.tr(
1520 ## self.clearIconsAct.setWhatsThis(self.tr( 1520 """<b>Clear icons database</b>"""
1521 ## """<b>Clear icons database</b>""" 1521 """<p>Clears the database of favicons of previously visited"""
1522 ## """<p>Clears the database of favicons of previously visited""" 1522 """ URLs.</p>"""
1523 ## """ URLs.</p>""" 1523 ))
1524 ## )) 1524 if not self.__initShortcutsOnly:
1525 ## if not self.__initShortcutsOnly: 1525 self.clearIconsAct.triggered.connect(self.__clearIconsDatabase)
1526 ## self.clearIconsAct.triggered.connect(self.__clearIconsDatabase) 1526 self.__actions.append(self.clearIconsAct)
1527 ## self.__actions.append(self.clearIconsAct) 1527
1528 1528 self.searchEnginesAct = E5Action(
1529 # TODO: Open Search 1529 self.tr('Configure Search Engines'),
1530 ## self.searchEnginesAct = E5Action( 1530 self.tr('Configure Search &Engines...'),
1531 ## self.tr('Configure Search Engines'), 1531 0, 0,
1532 ## self.tr('Configure Search &Engines...'), 1532 self, 'webbrowser_search_engines')
1533 ## 0, 0, 1533 self.searchEnginesAct.setStatusTip(self.tr(
1534 ## self, 'webbrowser_search_engines') 1534 'Configure the available search engines'))
1535 ## self.searchEnginesAct.setStatusTip(self.tr( 1535 self.searchEnginesAct.setWhatsThis(self.tr(
1536 ## 'Configure the available search engines')) 1536 """<b>Configure Search Engines...</b>"""
1537 ## self.searchEnginesAct.setWhatsThis(self.tr( 1537 """<p>Opens a dialog to configure the available search"""
1538 ## """<b>Configure Search Engines...</b>""" 1538 """ engines.</p>"""
1539 ## """<p>Opens a dialog to configure the available search""" 1539 ))
1540 ## """ engines.</p>""" 1540 if not self.__initShortcutsOnly:
1541 ## )) 1541 self.searchEnginesAct.triggered.connect(
1542 ## if not self.__initShortcutsOnly: 1542 self.__showEnginesConfigurationDialog)
1543 ## self.searchEnginesAct.triggered.connect( 1543 self.__actions.append(self.searchEnginesAct)
1544 ## self.__showEnginesConfigurationDialog)
1545 ## self.__actions.append(self.searchEnginesAct)
1546 1544
1547 # TODO: Passwords 1545 # TODO: Passwords
1548 ## self.passwordsAct = E5Action( 1546 ## self.passwordsAct = E5Action(
1549 ## self.tr('Manage Saved Passwords'), 1547 ## self.tr('Manage Saved Passwords'),
1550 ## UI.PixmapCache.getIcon("passwords.png"), 1548 ## UI.PixmapCache.getIcon("passwords.png"),
1861 ## menu.addAction(self.personalDataAct) 1859 ## menu.addAction(self.personalDataAct)
1862 ## menu.addAction(self.greaseMonkeyAct) 1860 ## menu.addAction(self.greaseMonkeyAct)
1863 ## menu.addAction(self.featurePermissionAct) 1861 ## menu.addAction(self.featurePermissionAct)
1864 ## menu.addSeparator() 1862 ## menu.addSeparator()
1865 menu.addAction(self.editMessageFilterAct) 1863 menu.addAction(self.editMessageFilterAct)
1866 ## menu.addSeparator() 1864 menu.addSeparator()
1867 ## menu.addAction(self.searchEnginesAct) 1865 menu.addAction(self.searchEnginesAct)
1868 ## menu.addSeparator() 1866 ## menu.addSeparator()
1869 ## menu.addAction(self.passwordsAct) 1867 ## menu.addAction(self.passwordsAct)
1870 ## if SSL_AVAILABLE: 1868 ## if SSL_AVAILABLE:
1871 ## menu.addAction(self.certificatesAct) 1869 ## menu.addAction(self.certificatesAct)
1872 ## menu.addSeparator() 1870 ## menu.addSeparator()
1888 ## if WebBrowserWindow.UseQtHelp: 1886 ## if WebBrowserWindow.UseQtHelp:
1889 ## menu.addAction(self.manageQtHelpDocsAct) 1887 ## menu.addAction(self.manageQtHelpDocsAct)
1890 ## menu.addAction(self.manageQtHelpFiltersAct) 1888 ## menu.addAction(self.manageQtHelpFiltersAct)
1891 ## menu.addAction(self.reindexDocumentationAct) 1889 ## menu.addAction(self.reindexDocumentationAct)
1892 ## menu.addSeparator() 1890 ## menu.addSeparator()
1893 ## menu.addAction(self.clearPrivateDataAct) 1891 menu.addAction(self.clearPrivateDataAct)
1894 ## menu.addAction(self.clearIconsAct) 1892 menu.addAction(self.clearIconsAct)
1895 1893
1896 ## menu = mb.addMenu(self.tr("&Tools")) 1894 ## menu = mb.addMenu(self.tr("&Tools"))
1897 ## menu.setTearOffEnabled(True) 1895 ## menu.setTearOffEnabled(True)
1898 ## menu.addAction(self.feedsManagerAct) 1896 ## menu.addAction(self.feedsManagerAct)
1899 ## menu.addAction(self.siteInfoAct) 1897 ## menu.addAction(self.siteInfoAct)
2028 gotb.addSeparator() 2026 gotb.addSeparator()
2029 2027
2030 self.__navigationSplitter = QSplitter(gotb) 2028 self.__navigationSplitter = QSplitter(gotb)
2031 self.__navigationSplitter.addWidget(self.__tabWidget.stackedUrlBar()) 2029 self.__navigationSplitter.addWidget(self.__tabWidget.stackedUrlBar())
2032 2030
2033 ## from .HelpWebSearchWidget import HelpWebSearchWidget 2031 from .WebBrowserWebSearchWidget import WebBrowserWebSearchWidget
2034 ## self.searchEdit = HelpWebSearchWidget(self) 2032 self.searchEdit = WebBrowserWebSearchWidget(self)
2035 ## sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) 2033 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
2036 ## sizePolicy.setHorizontalStretch(2) 2034 sizePolicy.setHorizontalStretch(2)
2037 ## sizePolicy.setVerticalStretch(0) 2035 sizePolicy.setVerticalStretch(0)
2038 ## self.searchEdit.setSizePolicy(sizePolicy) 2036 self.searchEdit.setSizePolicy(sizePolicy)
2039 ## self.searchEdit.search.connect(self.__linkActivated) 2037 self.searchEdit.search.connect(self.__linkActivated)
2040 ## self.__navigationSplitter.addWidget(self.searchEdit) 2038 self.__navigationSplitter.addWidget(self.searchEdit)
2041 gotb.addWidget(self.__navigationSplitter) 2039 gotb.addWidget(self.__navigationSplitter)
2042 2040
2043 self.__navigationSplitter.setSizePolicy( 2041 self.__navigationSplitter.setSizePolicy(
2044 QSizePolicy.Expanding, QSizePolicy.Maximum) 2042 QSizePolicy.Expanding, QSizePolicy.Maximum)
2045 self.__navigationSplitter.setCollapsible(0, False) 2043 self.__navigationSplitter.setCollapsible(0, False)
2134 Private slot called to handle a change of a browser's title. 2132 Private slot called to handle a change of a browser's title.
2135 2133
2136 @param browser reference to the browser (WebBrowserView) 2134 @param browser reference to the browser (WebBrowserView)
2137 @param title new title (string) 2135 @param title new title (string)
2138 """ 2136 """
2139 pass 2137 self.historyManager().updateHistoryEntry(
2140 ## self.historyManager().updateHistoryEntry( 2138 browser.url().toString(), title)
2141 ## browser.url().toString(), title)
2142 2139
2143 @pyqtSlot() 2140 @pyqtSlot()
2144 def newTab(self, link=None, requestData=None, addNextTo=None): 2141 def newTab(self, link=None, requestData=None, addNextTo=None):
2145 """ 2142 """
2146 Public slot called to open a new web browser tab. 2143 Public slot called to open a new web browser tab.
2147 2144
2148 @param link file to be displayed in the new window (string or QUrl) 2145 @param link file to be displayed in the new window (string or QUrl)
2149 @param requestData tuple containing the request data (QNetworkRequest, 2146 @param requestData page load request data (LoadRequest)
2150 QNetworkAccessManager.Operation, QByteArray)
2151 @param addNextTo reference to the browser to open the tab after 2147 @param addNextTo reference to the browser to open the tab after
2152 (HelpBrowser) 2148 (HelpBrowser)
2153 """ 2149 """
2154 if addNextTo: 2150 if addNextTo:
2155 self.__tabWidget.newBrowserAfter(addNextTo, link, requestData) 2151 self.__tabWidget.newBrowserAfter(addNextTo, link, requestData)
2156 else: 2152 else:
2157 self.__tabWidget.newBrowser(link, requestData) 2153 self.__tabWidget.newBrowser(link, requestData)
2158 # TODO: check the above
2159 2154
2160 @pyqtSlot() 2155 @pyqtSlot()
2161 def newWindow(self, link=None): 2156 def newWindow(self, link=None):
2162 """ 2157 """
2163 Public slot called to open a new web browser window. 2158 Public slot called to open a new web browser window.
2174 self.__fromEric) 2169 self.__fromEric)
2175 h.show() 2170 h.show()
2176 2171
2177 # TODO: Private Window 2172 # TODO: Private Window
2178 2173
2179 # TODO: check if this is still needed 2174 # TODO: check if this is still needed/possible
2180 def previewer(self): 2175 def previewer(self):
2181 """ 2176 """
2182 Public method to get a reference to the previewer tab. 2177 Public method to get a reference to the previewer tab.
2183 2178
2184 @return reference to the previewer tab (WebBrowserView) 2179 @return reference to the previewer tab (WebBrowserView)
2503 ## 2498 ##
2504 ## self.__virusTotal.close() 2499 ## self.__virusTotal.close()
2505 ## 2500 ##
2506 ## self.flashCookieManager().shutdown() 2501 ## self.flashCookieManager().shutdown()
2507 ## 2502 ##
2508 ## self.searchEdit.openSearchManager().close() 2503 self.searchEdit.openSearchManager().close()
2509 ## 2504
2510 ## if WebBrowserWindow.UseQtHelp: 2505 ## if WebBrowserWindow.UseQtHelp:
2511 ## self.__searchEngine.cancelIndexing() 2506 ## self.__searchEngine.cancelIndexing()
2512 ## self.__searchEngine.cancelSearching() 2507 ## self.__searchEngine.cancelSearching()
2513 ## 2508 ##
2514 ## if self.__helpInstaller: 2509 ## if self.__helpInstaller:
2515 ## self.__helpInstaller.stop() 2510 ## self.__helpInstaller.stop()
2516 ## 2511 ##
2517 ## self.searchEdit.saveSearches() 2512 self.searchEdit.saveSearches()
2518 ## 2513
2519 self.__tabWidget.closeAllBrowsers() 2514 self.__tabWidget.closeAllBrowsers()
2520 2515
2521 state = self.saveState() 2516 state = self.saveState()
2522 Preferences.setWebBrowser("WebBrowserState", state) 2517 Preferences.setWebBrowser("WebBrowserState", state)
2523 2518
2804 ## 2799 ##
2805 self.historyManager().preferencesChanged() 2800 self.historyManager().preferencesChanged()
2806 2801
2807 self.__tabWidget.preferencesChanged() 2802 self.__tabWidget.preferencesChanged()
2808 2803
2809 # TODO: OpenSearch 2804 self.searchEdit.preferencesChanged()
2810 ## self.searchEdit.preferencesChanged() 2805
2811 ##
2812 # TODO: VirusTotal 2806 # TODO: VirusTotal
2813 ## self.__virusTotal.preferencesChanged() 2807 ## self.__virusTotal.preferencesChanged()
2814 ## if not Preferences.getWebBrowser("VirusTotalEnabled") or \ 2808 ## if not Preferences.getWebBrowser("VirusTotalEnabled") or \
2815 ## Preferences.getWebBrowser("VirusTotalServiceKey") == "": 2809 ## Preferences.getWebBrowser("VirusTotalServiceKey") == "":
2816 ## self.virustotalScanCurrentAct.setEnabled(False) 2810 ## self.virustotalScanCurrentAct.setEnabled(False)
2921 ## """ 2915 ## """
2922 ## from .CookieJar.CookieJar import CookieJar 2916 ## from .CookieJar.CookieJar import CookieJar
2923 ## cls._cookieJar = CookieJar() 2917 ## cls._cookieJar = CookieJar()
2924 ## return cls.networkAccessManager().cookieJar() 2918 ## return cls.networkAccessManager().cookieJar()
2925 ## 2919 ##
2926 ## def __clearIconsDatabase(self): 2920 def __clearIconsDatabase(self):
2927 ## """ 2921 """
2928 ## Private slot to clear the icons databse. 2922 Private slot to clear the icons databse.
2929 ## """ 2923 """
2930 ## QWebSettings.clearIconDatabase() 2924 WebIconProvider.instance().clear()
2931 ## 2925
2932 @pyqtSlot(QUrl) 2926 @pyqtSlot(QUrl)
2933 def __linkActivated(self, url): 2927 def __linkActivated(self, url):
2934 """ 2928 """
2935 Private slot to handle the selection of a link. 2929 Private slot to handle the selection of a link.
2936 2930
3283 history.goToItem(history.backItems(historyCount)[-1 * offset - 1]) 3277 history.goToItem(history.backItems(historyCount)[-1 * offset - 1])
3284 else: 3278 else:
3285 # go forward 3279 # go forward
3286 history.goToItem(history.forwardItems(historyCount)[offset - 1]) 3280 history.goToItem(history.forwardItems(historyCount)[offset - 1])
3287 3281
3288 ## def __clearPrivateData(self): 3282 def __clearPrivateData(self):
3289 ## """ 3283 """
3290 ## Private slot to clear the private data. 3284 Private slot to clear the private data.
3291 ## """ 3285 """
3292 ## from .HelpClearPrivateDataDialog import HelpClearPrivateDataDialog 3286 from .WebBrowserClearPrivateDataDialog import \
3293 ## dlg = HelpClearPrivateDataDialog(self) 3287 WebBrowserClearPrivateDataDialog
3294 ## if dlg.exec_() == QDialog.Accepted: 3288 dlg = WebBrowserClearPrivateDataDialog(self)
3295 ## # browsing history, search history, favicons, disk cache, cookies, 3289 if dlg.exec_() == QDialog.Accepted:
3296 ## # passwords, web databases, downloads, Flash cookies 3290 # browsing history, search history, favicons, disk cache, cookies,
3297 ## (history, searches, favicons, cache, cookies, 3291 # passwords, web databases, downloads, Flash cookies
3298 ## passwords, databases, downloads, flashCookies, zoomValues, 3292 (history, searches, favicons, cache, cookies,
3299 ## historyPeriod) = dlg.getData() 3293 passwords, databases, downloads, flashCookies, zoomValues,
3300 ## if history: 3294 historyPeriod) = dlg.getData()
3301 ## self.historyManager().clear(historyPeriod) 3295 if history:
3302 ## self.__tabWidget.clearClosedTabsList() 3296 self.historyManager().clear(historyPeriod)
3303 ## if searches: 3297 self.__tabWidget.clearClosedTabsList()
3304 ## self.searchEdit.clear() 3298 if searches:
3299 self.searchEdit.clear()
3300 # TODO: Downloads
3305 ## if downloads: 3301 ## if downloads:
3306 ## self.downloadManager().cleanup() 3302 ## self.downloadManager().cleanup()
3307 ## self.downloadManager().hide() 3303 ## self.downloadManager().hide()
3308 ## if favicons: 3304 if favicons:
3309 ## self.__clearIconsDatabase() 3305 self.__clearIconsDatabase()
3306 # TODO: Cache Cleaning
3310 ## if cache: 3307 ## if cache:
3311 ## try: 3308 ## try:
3312 ## self.networkAccessManager().cache().clear() 3309 ## self.networkAccessManager().cache().clear()
3313 ## except AttributeError: 3310 ## except AttributeError:
3314 ## pass 3311 ## pass
3312 # TODO: Cookies
3315 ## if cookies: 3313 ## if cookies:
3316 ## self.cookieJar().clear() 3314 ## self.cookieJar().clear()
3315 # TODO: Passwords
3317 ## if passwords: 3316 ## if passwords:
3318 ## self.passwordManager().clear() 3317 ## self.passwordManager().clear()
3318 # TODO: Web Databases
3319 ## if databases: 3319 ## if databases:
3320 ## if hasattr(QWebDatabase, "removeAllDatabases"): 3320 ## if hasattr(QWebDatabase, "removeAllDatabases"):
3321 ## QWebDatabase.removeAllDatabases() 3321 ## QWebDatabase.removeAllDatabases()
3322 ## else: 3322 ## else:
3323 ## for securityOrigin in QWebSecurityOrigin.allOrigins(): 3323 ## for securityOrigin in QWebSecurityOrigin.allOrigins():
3324 ## for database in securityOrigin.databases(): 3324 ## for database in securityOrigin.databases():
3325 ## QWebDatabase.removeDatabase(database) 3325 ## QWebDatabase.removeDatabase(database)
3326 # TODO: Flash Cookie Manager
3326 ## if flashCookies: 3327 ## if flashCookies:
3327 ## from .HelpLanguagesDialog import HelpLanguagesDialog 3328 ## from .HelpLanguagesDialog import HelpLanguagesDialog
3328 ## languages = Preferences.toList( 3329 ## languages = Preferences.toList(
3329 ## Preferences.Prefs.settings.value( 3330 ## Preferences.Prefs.settings.value(
3330 ## "Help/AcceptLanguages", 3331 ## "Help/AcceptLanguages",
3334 ## langCode = language.split("[")[1][:2] 3335 ## langCode = language.split("[")[1][:2]
3335 ## self.newTab( 3336 ## self.newTab(
3336 ## "http://www.macromedia.com/support/documentation/" 3337 ## "http://www.macromedia.com/support/documentation/"
3337 ## "{0}/flashplayer/help/settings_manager07.html".format( 3338 ## "{0}/flashplayer/help/settings_manager07.html".format(
3338 ## langCode)) 3339 ## langCode))
3339 ## if zoomValues: 3340 if zoomValues:
3340 ## ZoomManager.instance().clear() 3341 ZoomManager.instance().clear()
3341 ## 3342
3342 ## def __showEnginesConfigurationDialog(self): 3343 def __showEnginesConfigurationDialog(self):
3343 ## """ 3344 """
3344 ## Private slot to show the search engines configuration dialog. 3345 Private slot to show the search engines configuration dialog.
3345 ## """ 3346 """
3346 ## from .OpenSearch.OpenSearchDialog import OpenSearchDialog 3347 from .OpenSearch.OpenSearchDialog import OpenSearchDialog
3347 ## 3348
3348 ## dlg = OpenSearchDialog(self) 3349 dlg = OpenSearchDialog(self)
3349 ## dlg.exec_() 3350 dlg.exec_()
3350 ## 3351
3351 ## def searchEnginesAction(self): 3352 def searchEnginesAction(self):
3352 ## """ 3353 """
3353 ## Public method to get a reference to the search engines configuration 3354 Public method to get a reference to the search engines configuration
3354 ## action. 3355 action.
3355 ## 3356
3356 ## @return reference to the search engines configuration action (QAction) 3357 @return reference to the search engines configuration action (QAction)
3357 ## """ 3358 """
3358 ## return self.searchEnginesAct 3359 return self.searchEnginesAct
3359 ## 3360
3360 ## def __showPasswordsDialog(self): 3361 ## def __showPasswordsDialog(self):
3361 ## """ 3362 ## """
3362 ## Private slot to show the passwords management dialog. 3363 ## Private slot to show the passwords management dialog.
3363 ## """ 3364 ## """
3364 ## from .Passwords.PasswordsDialog import PasswordsDialog 3365 ## from .Passwords.PasswordsDialog import PasswordsDialog
3659 if self.__lastActiveWindow: 3660 if self.__lastActiveWindow:
3660 return self.__lastActiveWindow 3661 return self.__lastActiveWindow
3661 3662
3662 return self.mainWindow() 3663 return self.mainWindow()
3663 3664
3664 ## def openSearchManager(self): 3665 def openSearchManager(self):
3665 ## """ 3666 """
3666 ## Public method to get a reference to the opensearch manager object. 3667 Public method to get a reference to the opensearch manager object.
3667 ## 3668
3668 ## @return reference to the opensearch manager object (OpenSearchManager) 3669 @return reference to the opensearch manager object (OpenSearchManager)
3669 ## """ 3670 """
3670 ## return self.searchEdit.openSearchManager() 3671 return self.searchEdit.openSearchManager()
3671 ## 3672
3672 def __aboutToShowTextEncodingMenu(self): 3673 def __aboutToShowTextEncodingMenu(self):
3673 """ 3674 """
3674 Private slot to populate the text encoding menu. 3675 Private slot to populate the text encoding menu.
3675 """ 3676 """
3676 self.__textEncodingMenu.clear() 3677 self.__textEncodingMenu.clear()

eric ide

mercurial