576 @param menu reference to the menu to be populated |
576 @param menu reference to the menu to be populated |
577 @type QMenu |
577 @type QMenu |
578 @param hitTest reference to the hit test object |
578 @param hitTest reference to the hit test object |
579 @type WebHitTestResult |
579 @type WebHitTestResult |
580 """ |
580 """ |
|
581 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
582 |
581 if not menu.isEmpty(): |
583 if not menu.isEmpty(): |
582 menu.addSeparator() |
584 menu.addSeparator() |
583 |
585 |
584 menu.addAction( |
586 menu.addAction( |
585 UI.PixmapCache.getIcon("openNewTab.png"), |
587 UI.PixmapCache.getIcon("openNewTab.png"), |
597 self.__copyLink).setData(hitTest.imageUrl()) |
599 self.__copyLink).setData(hitTest.imageUrl()) |
598 menu.addAction( |
600 menu.addAction( |
599 UI.PixmapCache.getIcon("mailSend.png"), |
601 UI.PixmapCache.getIcon("mailSend.png"), |
600 self.tr("Send Image Link"), |
602 self.tr("Send Image Link"), |
601 self.__sendLink).setData(hitTest.imageUrl()) |
603 self.__sendLink).setData(hitTest.imageUrl()) |
|
604 |
|
605 if hitTest.imageUrl().scheme() in ["http", "https"]: |
|
606 menu.addSeparator() |
|
607 engine = WebBrowserWindow.imageSearchEngine() |
|
608 searchEngineName = engine.searchEngine() |
|
609 menu.addAction( |
|
610 UI.PixmapCache.getIcon("{0}.png".format( |
|
611 searchEngineName.lower())), |
|
612 self.tr("Search image in {0}").format(searchEngineName), |
|
613 self.__searchImage).setData( |
|
614 engine.getSearchQuery(hitTest.imageUrl())) |
|
615 self.__imageSearchMenu = menu.addMenu( |
|
616 self.tr("Search image with...")) |
|
617 for searchEngineName in engine.searchEngineNames(): |
|
618 self.__imageSearchMenu.addAction( |
|
619 UI.PixmapCache.getIcon("{0}.png".format( |
|
620 searchEngineName.lower())), |
|
621 self.tr("Search image in {0}").format(searchEngineName), |
|
622 self.__searchImage).setData( |
|
623 engine.getSearchQuery( |
|
624 hitTest.imageUrl(), searchEngineName)) |
|
625 |
602 menu.addSeparator() |
626 menu.addSeparator() |
603 menu.addAction( |
627 menu.addAction( |
604 UI.PixmapCache.getIcon("adBlockPlus.png"), |
628 UI.PixmapCache.getIcon("adBlockPlus.png"), |
605 self.tr("Block Image"), self.__blockImage)\ |
629 self.tr("Block Image"), self.__blockImage)\ |
606 .setData(hitTest.imageUrl().toString()) |
630 .setData(hitTest.imageUrl().toString()) |
967 act = self.sender() |
991 act = self.sender() |
968 url = act.data() |
992 url = act.data() |
969 dlg = WebBrowserWindow.adBlockManager().showDialog() |
993 dlg = WebBrowserWindow.adBlockManager().showDialog() |
970 dlg.addCustomRule(url) |
994 dlg.addCustomRule(url) |
971 |
995 |
|
996 def __searchImage(self): |
|
997 """ |
|
998 Private slot to search for an image URL. |
|
999 """ |
|
1000 act = self.sender() |
|
1001 url = act.data() |
|
1002 self.setSource(url, newTab=True) |
|
1003 |
972 def __downloadMedia(self): |
1004 def __downloadMedia(self): |
973 """ |
1005 """ |
974 Private slot to download a media and save it to disk. |
1006 Private slot to download a media and save it to disk. |
975 """ |
1007 """ |
976 self.triggerPageAction(QWebEnginePage.DownloadMediaToDisk) |
1008 self.triggerPageAction(QWebEnginePage.DownloadMediaToDisk) |