diff --git a/src/calibre/gui2/viewer/config.py b/src/calibre/gui2/viewer/config.py
index 99cceee265..f45587d248 100644
--- a/src/calibre/gui2/viewer/config.py
+++ b/src/calibre/gui2/viewer/config.py
@@ -47,6 +47,8 @@ def config(defaults=None):
c.add_opt('hyphenate', default=False, help=_('Hyphenate text'))
c.add_opt('hyphenate_default_lang', default='en',
help=_('Default language for hyphenation rules'))
+ c.add_opt('search_online_url', default='https://www.google.com/search?q={text}',
+ help=_('The URL to use when searching for selected text online'))
c.add_opt('remember_current_page', default=True,
help=_('Save the current position in the document, when quitting'))
c.add_opt('copy_bookmarks_to_file', default=True,
@@ -313,6 +315,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
self.hyphenate_default_lang.setCurrentIndex(idx)
self.hyphenate.setChecked(opts.hyphenate)
self.hyphenate_default_lang.setEnabled(opts.hyphenate)
+ self.search_online_url.setText(opts.search_online_url or '')
self.opt_fit_images.setChecked(opts.fit_images)
self.opt_fullscreen_clock.setChecked(opts.fullscreen_clock)
self.opt_fullscreen_scrollbar.setChecked(opts.fullscreen_scrollbar)
@@ -397,6 +400,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
self.hyphenate_default_lang.itemData(idx))
c.set('line_scrolling_stops_on_pagebreaks',
self.opt_line_scrolling_stops_on_pagebreaks.isChecked())
+ c.set('search_online_url', self.search_online_url.text().strip())
c.set('fullscreen_clock', self.opt_fullscreen_clock.isChecked())
c.set('fullscreen_pos', self.opt_fullscreen_pos.isChecked())
c.set('fullscreen_scrollbar', self.opt_fullscreen_scrollbar.isChecked())
diff --git a/src/calibre/gui2/viewer/config.ui b/src/calibre/gui2/viewer/config.ui
index 7783072187..124c8b3b80 100644
--- a/src/calibre/gui2/viewer/config.ui
+++ b/src/calibre/gui2/viewer/config.ui
@@ -240,8 +240,8 @@ QToolBox::tab:hover {
0
0
- 374
- 211
+ 799
+ 378
@@ -370,8 +370,8 @@ QToolBox::tab:hover {
0
0
- 381
- 193
+ 799
+ 378
@@ -472,8 +472,8 @@ QToolBox::tab:hover {
0
0
- 340
- 70
+ 799
+ 378
@@ -551,8 +551,8 @@ QToolBox::tab:hover {
0
0
- 384
- 140
+ 799
+ 378
@@ -636,7 +636,38 @@ QToolBox::tab:hover {
&Miscellaneous options
-
+
+ -
+
+
+ Remember last used &window size and layout
+
+
+
+ -
+
+
+ Remember the ¤t page when quitting
+
+
+
+ -
+
+
+ Keep a copy of all bookmarks/current page information inside the ebook file, so that you can share them by simply sending the ebook file itself. Currently only works with ebooks in the EPUB format.
+
+
+ Keep a copy of bookmarks/current page inside the ebook file, for easy sharing
+
+
+
+ -
+
+
+ Show &controls in the viewer window
+
+
+
-
@@ -644,6 +675,13 @@ QToolBox::tab:hover {
+ -
+
+
+ Clear search history
+
+
+
-
@@ -661,44 +699,38 @@ QToolBox::tab:hover {
- -
-
-
- Clear search history
-
-
-
- -
-
-
- Show &controls in the viewer window
-
-
-
-
-
+
- Remember last used &window size and layout
+ &Search online URL:
+
+
+ search_online_url
- -
-
-
- Remember the ¤t page when quitting
-
-
-
- -
-
+
-
+
- Keep a copy of all bookmarks/current page information inside the ebook file, so that you can share them by simply sending the ebook file itself. Currently only works with ebooks in the EPUB format.
-
-
- Keep a copy of bookmarks/current page inside the ebook file, for easy sharing
+ Change the search engine used to perform online searches for selected text.
+You must enter the search URL for the search engine, with the placeholder
+{text}, which will be replaced by the selected text.
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py
index b4cf1aedd2..d57d7d27e9 100644
--- a/src/calibre/gui2/viewer/documentview.py
+++ b/src/calibre/gui2/viewer/documentview.py
@@ -189,6 +189,7 @@ class Document(QWebPage): # {{{
self.show_controls = opts.show_controls
self.remember_current_page = opts.remember_current_page
self.copy_bookmarks_to_file = opts.copy_bookmarks_to_file
+ self.search_online_url = opts.search_online_url or 'https://www.google.com/search?q={text}'
def fit_images(self):
if self.do_fit_images and not self.in_paged_mode:
@@ -701,7 +702,7 @@ class DocumentView(QWebView): # {{{
if len(t) > 40:
t = t[:40] + u'...'
t = t.replace(u'&', u'&&')
- return _("S&earch Google for '%s'")%t
+ return _("S&earch online for '%s'")%t
def popup_table(self):
html = self.document.extract_node()
@@ -820,7 +821,7 @@ class DocumentView(QWebView): # {{{
self.do_search_online(t)
def do_search_online(self, text):
- url = 'https://www.google.com/search?q=' + QUrl().toPercentEncoding(text)
+ url = self.document.search_online_url.replace('{text}', QUrl().toPercentEncoding(text))
open_url(QUrl.fromEncoded(url))
def set_manager(self, manager):