WebBrowser/WebBrowserView.py

branch
QtWebEngine
changeset 4818
9afce2f09ac0
parent 4801
71bdc520f640
child 4826
aa752e6e9eba
equal deleted inserted replaced
4817:0a4e2fb0e93c 4818:9afce2f09ac0
806 menu.addSeparator() 806 menu.addSeparator()
807 menu.addAction( 807 menu.addAction(
808 UI.PixmapCache.getIcon("mailSend.png"), 808 UI.PixmapCache.getIcon("mailSend.png"),
809 self.tr("Send Text"), 809 self.tr("Send Text"),
810 self.__sendLink).setData(self.selectedText()) 810 self.__sendLink).setData(self.selectedText())
811 # TODO: OpenSearch: add a search entry using the current engine 811
812 self.__searchMenu = menu.addMenu(self.tr("Search with...")) 812 engineName = self.__mw.openSearchManager().currentEngineName()
813 if engineName:
814 menu.addAction(self.tr("Search with '{0}'").format(engineName),
815 self.__searchDefaultRequested)
813 816
814 from .OpenSearch.OpenSearchEngineAction import \ 817 from .OpenSearch.OpenSearchEngineAction import \
815 OpenSearchEngineAction 818 OpenSearchEngineAction
819
820 self.__searchMenu = menu.addMenu(self.tr("Search with..."))
816 engineNames = self.__mw.openSearchManager().allEnginesNames() 821 engineNames = self.__mw.openSearchManager().allEnginesNames()
817 for engineName in engineNames: 822 for engineName in engineNames:
818 engine = self.__mw.openSearchManager().engine(engineName) 823 engine = self.__mw.openSearchManager().engine(engineName)
819 act = OpenSearchEngineAction(engine, self.__searchMenu) 824 act = OpenSearchEngineAction(engine, self.__searchMenu)
820 act.setData(engineName) 825 act.setData(engineName)
1120 """ 1125 """
1121 act = self.sender() 1126 act = self.sender()
1122 url = act.data() 1127 url = act.data()
1123 self.__mw.requestVirusTotalScan(url) 1128 self.__mw.requestVirusTotalScan(url)
1124 1129
1130 def __searchDefaultRequested(self):
1131 """
1132 Private slot to search for some text with the current search engine.
1133 """
1134 searchText = self.selectedText()
1135
1136 if not searchText:
1137 return
1138
1139 engine = self.__mw.openSearchManager().currentEngine()
1140 if engine:
1141 self.search.emit(engine.searchUrl(searchText))
1142
1125 def __searchRequested(self, act): 1143 def __searchRequested(self, act):
1126 """ 1144 """
1127 Private slot to search for some text with a selected search engine. 1145 Private slot to search for some text with a selected search engine.
1128 1146
1129 @param act reference to the action that triggered this slot (QAction) 1147 @param act reference to the action that triggered this slot (QAction)
1134 return 1152 return
1135 1153
1136 engineName = act.data() 1154 engineName = act.data()
1137 if engineName: 1155 if engineName:
1138 engine = self.__mw.openSearchManager().engine(engineName) 1156 engine = self.__mw.openSearchManager().engine(engineName)
1157 else:
1158 engine = self.__mw.openSearchManager().currentEngine()
1159 if engine:
1139 self.search.emit(engine.searchUrl(searchText)) 1160 self.search.emit(engine.searchUrl(searchText))
1140 1161
1141 def __addSearchEngine(self): 1162 def __addSearchEngine(self):
1142 """ 1163 """
1143 Private slot to add a new search engine. 1164 Private slot to add a new search engine.

eric ide

mercurial