mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow configuring the search URL
This commit is contained in:
parent
83d5865d4c
commit
cbdaad0003
@ -40,8 +40,15 @@ def create_selection_panel(container, apply_func, cancel_func):
|
||||
ans.checked = True
|
||||
return E.div(style='margin-top:1ex', E.label(ans, '\xa0' + text))
|
||||
|
||||
def url(name, text, title):
|
||||
ans = E.input(type='url', name=name, value=sd.get(name), size='50', title=title or '')
|
||||
return E.div(style='margin-top:1ex', E.label(text, E.br(), ans))
|
||||
|
||||
container.appendChild(cb(
|
||||
'show_selection_bar', _('Show a popup bar with common actions next to selected text')))
|
||||
container.appendChild(url(
|
||||
'net_search_url', _('URL to query when searching the internet'),
|
||||
_('The {q} in the URL is replaced by the selected text')))
|
||||
|
||||
container.appendChild(create_button_box(restore_defaults, apply_func, cancel_func))
|
||||
|
||||
|
@ -89,7 +89,7 @@ class SelectionBar:
|
||||
text = self.view.currently_showing.selection.text
|
||||
if text:
|
||||
q = encodeURIComponent(text)
|
||||
url = f'https://google.com/search?q={q}'
|
||||
url = get_session_data().get('net_search_url').format(q=q)
|
||||
ui_operations.open_url(url)
|
||||
|
||||
def clear_selection(self):
|
||||
|
@ -65,6 +65,7 @@ defaults = {
|
||||
'highlight_style': None,
|
||||
'custom_highlight_colors': v'[]',
|
||||
'show_selection_bar': True,
|
||||
'net_search_url': 'https://google.com/search?q={q}',
|
||||
}
|
||||
|
||||
is_local_setting = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user