Continued porting the web browser. QtWebEngine

Sun, 06 Mar 2016 17:24:27 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 06 Mar 2016 17:24:27 +0100
branch
QtWebEngine
changeset 4818
9afce2f09ac0
parent 4817
0a4e2fb0e93c
child 4819
cb0672f0fc15

Continued porting the web browser.

- added an entry to search the selected text with the current search engine to the selected text context menu

WebBrowser/WebBrowserView.py file | annotate | diff | comparison | revisions
diff -r 0a4e2fb0e93c -r 9afce2f09ac0 WebBrowser/WebBrowserView.py
--- a/WebBrowser/WebBrowserView.py	Sun Mar 06 16:59:26 2016 +0100
+++ b/WebBrowser/WebBrowserView.py	Sun Mar 06 17:24:27 2016 +0100
@@ -808,11 +808,16 @@
             UI.PixmapCache.getIcon("mailSend.png"),
             self.tr("Send Text"),
             self.__sendLink).setData(self.selectedText())
-        # TODO: OpenSearch: add a search entry using the current engine
-        self.__searchMenu = menu.addMenu(self.tr("Search with..."))
+        
+        engineName = self.__mw.openSearchManager().currentEngineName()
+        if engineName:
+            menu.addAction(self.tr("Search with '{0}'").format(engineName), 
+                           self.__searchDefaultRequested)
         
         from .OpenSearch.OpenSearchEngineAction import \
             OpenSearchEngineAction
+        
+        self.__searchMenu = menu.addMenu(self.tr("Search with..."))
         engineNames = self.__mw.openSearchManager().allEnginesNames()
         for engineName in engineNames:
             engine = self.__mw.openSearchManager().engine(engineName)
@@ -1122,6 +1127,19 @@
         url = act.data()
         self.__mw.requestVirusTotalScan(url)
     
+    def __searchDefaultRequested(self):
+        """
+        Private slot to search for some text with the current search engine.
+        """
+        searchText = self.selectedText()
+        
+        if not searchText:
+            return
+        
+        engine = self.__mw.openSearchManager().currentEngine()
+        if engine:
+            self.search.emit(engine.searchUrl(searchText))
+    
     def __searchRequested(self, act):
         """
         Private slot to search for some text with a selected search engine.
@@ -1136,6 +1154,9 @@
         engineName = act.data()
         if engineName:
             engine = self.__mw.openSearchManager().engine(engineName)
+        else:
+            engine = self.__mw.openSearchManager().currentEngine()
+        if engine:
             self.search.emit(engine.searchUrl(searchText))
     
     def __addSearchEngine(self):

eric ide

mercurial