mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Add an option to the right click menu to search for the currently selected word
This commit is contained in:
parent
cc7df726d5
commit
156e0970c9
@ -537,6 +537,12 @@ class DocumentView(QWebView): # {{{
|
|||||||
self.dictionary_action.setShortcut(Qt.CTRL+Qt.Key_L)
|
self.dictionary_action.setShortcut(Qt.CTRL+Qt.Key_L)
|
||||||
self.dictionary_action.triggered.connect(self.lookup)
|
self.dictionary_action.triggered.connect(self.lookup)
|
||||||
self.addAction(self.dictionary_action)
|
self.addAction(self.dictionary_action)
|
||||||
|
self.search_action = QAction(QIcon(I('dictionary.png')),
|
||||||
|
_('&Search for next occurrence'), self)
|
||||||
|
self.search_action.setShortcut(Qt.CTRL+Qt.Key_S)
|
||||||
|
self.search_action.triggered.connect(self.search_next)
|
||||||
|
self.addAction(self.search_action)
|
||||||
|
|
||||||
self.goto_location_action = QAction(_('Go to...'), self)
|
self.goto_location_action = QAction(_('Go to...'), self)
|
||||||
self.goto_location_menu = m = QMenu(self)
|
self.goto_location_menu = m = QMenu(self)
|
||||||
self.goto_location_actions = a = {
|
self.goto_location_actions = a = {
|
||||||
@ -620,6 +626,7 @@ class DocumentView(QWebView): # {{{
|
|||||||
text = unicode(self.selectedText())
|
text = unicode(self.selectedText())
|
||||||
if text:
|
if text:
|
||||||
menu.insertAction(list(menu.actions())[0], self.dictionary_action)
|
menu.insertAction(list(menu.actions())[0], self.dictionary_action)
|
||||||
|
menu.insertAction(list(menu.actions())[0], self.search_action)
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
menu.addAction(self.goto_location_action)
|
menu.addAction(self.goto_location_action)
|
||||||
menu.exec_(ev.globalPos())
|
menu.exec_(ev.globalPos())
|
||||||
@ -630,6 +637,12 @@ class DocumentView(QWebView): # {{{
|
|||||||
if t:
|
if t:
|
||||||
self.manager.lookup(t.split()[0])
|
self.manager.lookup(t.split()[0])
|
||||||
|
|
||||||
|
def search_next(self):
|
||||||
|
if self.manager is not None:
|
||||||
|
t = unicode(self.selectedText()).strip()
|
||||||
|
if t:
|
||||||
|
self.manager.search.set_search_string(t)
|
||||||
|
|
||||||
def set_manager(self, manager):
|
def set_manager(self, manager):
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
self.scrollbar = manager.horizontal_scrollbar
|
self.scrollbar = manager.horizontal_scrollbar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user