WebBrowser/WebBrowserView.py

branch
QtWebEngine
changeset 4772
db71b47b663e
parent 4767
0bace7c5ebc9
child 4780
1d203a177b16
equal deleted inserted replaced
4769:2b6f7e026cdc 4772:db71b47b663e
657 self.tr("Open Link in New Tab\tCtrl+LMB"), 657 self.tr("Open Link in New Tab\tCtrl+LMB"),
658 self.__openLinkInNewTab).setData(hitTest.linkUrl()) 658 self.__openLinkInNewTab).setData(hitTest.linkUrl())
659 # TODO: context menu: Open Link in New Window 659 # TODO: context menu: Open Link in New Window
660 # TODO: context menu: Open Link in Private Window 660 # TODO: context menu: Open Link in Private Window
661 menu.addSeparator() 661 menu.addSeparator()
662 # TODO: Download Link 662 # TODO: Qt 5.6
663 ## menu.addAction( 663 ## menu.addAction(
664 ## UI.PixmapCache.getIcon("download.png"), 664 ## UI.PixmapCache.getIcon("download.png"),
665 ## self.tr("Save Lin&k"), self.__downloadLink) 665 ## self.tr("Save Lin&k"), self.__downloadLink)
666 menu.addAction( 666 menu.addAction(
667 UI.PixmapCache.getIcon("bookmark22.png"), 667 UI.PixmapCache.getIcon("bookmark22.png"),
765 self.__copyLink).setData(hitTest.mediaUrl()) 765 self.__copyLink).setData(hitTest.mediaUrl())
766 menu.addAction( 766 menu.addAction(
767 UI.PixmapCache.getIcon("mailSend.png"), 767 UI.PixmapCache.getIcon("mailSend.png"),
768 self.tr("Send Media Address"), self.__sendLink)\ 768 self.tr("Send Media Address"), self.__sendLink)\
769 .setData(hitTest.mediaUrl()) 769 .setData(hitTest.mediaUrl())
770 # TODO: DownloadManager 770 # TODO: Qt 5.6
771 ## menu.addAction( 771 ## menu.addAction(
772 ## UI.PixmapCache.getIcon("download.png"), 772 ## UI.PixmapCache.getIcon("download.png"),
773 ## self.tr("Save Media"), self.__downloadMedia)\ 773 ## self.tr("Save Media"), self.__downloadMedia)
774 ## .setData(hitTest.mediaUrl())
775 774
776 def __createSelectedTextContextMenu(self, menu, hitTest): 775 def __createSelectedTextContextMenu(self, menu, hitTest):
777 """ 776 """
778 Private method to populate the context menu for selected text. 777 Private method to populate the context menu for selected text.
779 778
1009 1008
1010 if isinstance(data, QUrl): 1009 if isinstance(data, QUrl):
1011 data = data.toString() 1010 data = data.toString()
1012 QApplication.clipboard().setText(data) 1011 QApplication.clipboard().setText(data)
1013 1012
1013 # TODO: Qt 5.6
1014 ## def __downloadLink(self): 1014 ## def __downloadLink(self):
1015 ## """ 1015 ## """
1016 ## Private slot to download a link and save it to disk. 1016 ## Private slot to download a link and save it to disk.
1017 ## """ 1017 ## """
1018 ## self.pageAction(QWebPage.DownloadLinkToDisk).trigger() 1018 ## self.triggerPageAction(QWebEnginePage.DownloadLinkToDisk)
1019 ## 1019 ##
1020 ## def __downloadImage(self): 1020 ## def __downloadImage(self):
1021 ## """ 1021 ## """
1022 ## Private slot to download an image and save it to disk. 1022 ## Private slot to download an image and save it to disk.
1023 ## """ 1023 ## """
1024 ## self.pageAction(QWebPage.DownloadImageToDisk).trigger() 1024 ## self.triggerPageAction(QWebEnginePage.DownloadImageToDisk)
1025 ## 1025 ##
1026 ## def __copyImage(self): 1026 ## def __copyImage(self):
1027 ## """ 1027 ## """
1028 ## Private slot to copy an image to the clipboard. 1028 ## Private slot to copy an image to the clipboard.
1029 ## """ 1029 ## """
1030 ## self.pageAction(QWebPage.CopyImageToClipboard).trigger() 1030 ## self.triggerPageAction(QWebEnginePage.CopyImageToClipboard)
1031 1031
1032 # TODO: AdBlock 1032 # TODO: AdBlock
1033 ## def __blockImage(self): 1033 ## def __blockImage(self):
1034 ## """ 1034 ## """
1035 ## Private slot to add a block rule for an image URL. 1035 ## Private slot to add a block rule for an image URL.
1038 ## act = self.sender() 1038 ## act = self.sender()
1039 ## url = act.data() 1039 ## url = act.data()
1040 ## dlg = WebBrowser.WebBrowserWindow.WebBrowserWindow.adBlockManager().showDialog() 1040 ## dlg = WebBrowser.WebBrowserWindow.WebBrowserWindow.adBlockManager().showDialog()
1041 ## dlg.addCustomRule(url) 1041 ## dlg.addCustomRule(url)
1042 1042
1043 # TODO: DownloadManager 1043 # TODO: Qt 5.6
1044 ## def __downloadMedia(self): 1044 ## def __downloadMedia(self):
1045 ## """ 1045 ## """
1046 ## Private slot to download a media and save it to disk. 1046 ## Private slot to download a media and save it to disk.
1047 ## """ 1047 ## """
1048 ## act = self.sender() 1048 ## self.triggerPageAction(QWebEnginePage.DownloadMediaToDisk)
1049 ## url = act.data() 1049
1050 ## self.__mw.downloadManager().download(url, True, mainWindow=self.__mw) 1050 # TODO: Qt 5.6: do this with triggerPageAction()
1051
1052 def __pauseMedia(self): 1051 def __pauseMedia(self):
1053 """ 1052 """
1054 Private slot to pause or play the selected media. 1053 Private slot to pause or play the selected media.
1055 """ 1054 """
1056 from .Tools import Scripts 1055 from .Tools import Scripts
1057 script = Scripts.toggleMediaPause(self.__clickedPos) 1056 script = Scripts.toggleMediaPause(self.__clickedPos)
1058 self.page().runJavaScript(script) 1057 self.page().runJavaScript(script)
1059 1058
1059 # TODO: Qt 5.6: do this with triggerPageAction()
1060 def __muteMedia(self): 1060 def __muteMedia(self):
1061 """ 1061 """
1062 Private slot to (un)mute the selected media. 1062 Private slot to (un)mute the selected media.
1063 """ 1063 """
1064 from .Tools import Scripts 1064 from .Tools import Scripts

eric ide

mercurial