mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Button to refresh random book
This commit is contained in:
parent
c1b41b14fc
commit
d800f68b62
@ -48,6 +48,10 @@ class BookDetailsPanel:
|
||||
self.render_book(book_id)
|
||||
else:
|
||||
self.fetch_metadata(book_id)
|
||||
get_boss().ui.set_button_visibility('random', not book_id or book_id == '0')
|
||||
|
||||
def show_random(self):
|
||||
self.fetch_metadata('0')
|
||||
|
||||
def no_book(self, book_id):
|
||||
self.container.appendChild(E.div(
|
||||
|
@ -107,6 +107,13 @@ class TopBar:
|
||||
if action is not None:
|
||||
right.lastChild.addEventListener('click', def(event): event.preventDefault(), action();)
|
||||
|
||||
def set_button_visibility(self, icon_name, visible):
|
||||
for bar in self.bar, self.dummy_bar:
|
||||
right = bar.firstChild.nextSibling
|
||||
elem = right.querySelector('i.fa.fa-fw.fa-' + icon_name)
|
||||
if elem:
|
||||
elem.parentNode.style.display = 'inline' if visible else 'none'
|
||||
|
||||
def apply_state(self, left, buttons):
|
||||
self.set_left(**left)
|
||||
for bar in self.bar, self.dummy_bar:
|
||||
|
@ -104,7 +104,8 @@ class UI:
|
||||
bss.add_button(icon_name='cogs', tooltip=_('Configure Tag Browser'), action=show_panel_action('booklist-config-tb'))
|
||||
self.panel_map['booklist-search'] = UIState(bss, main_panel=self.search_panel)
|
||||
|
||||
self.panel_map['book-details'] = UIState(ClosePanelBar(_('Book Details')), main_panel=self.book_details_panel)
|
||||
self.panel_map['book-details'] = bd = UIState(ClosePanelBar(_('Book Details')), main_panel=self.book_details_panel)
|
||||
bd.add_button(icon_name='random', tooltip=_('Pick another random book'), action=self.book_details_panel.show_random.bind(self.book_details_panel))
|
||||
|
||||
def create_prefences_panel(self, title, close_callback=None, panel_data=None):
|
||||
ans = UIState(ClosePanelBar(title), close_callback=close_callback, main_panel=self.prefs_panel, panel_data=panel_data)
|
||||
@ -114,6 +115,9 @@ class UI:
|
||||
def set_title(self, text):
|
||||
self.top_bar.set_title(text)
|
||||
|
||||
def set_button_visibility(self, icon_name, visible):
|
||||
self.top_bar.set_button_visibility(icon_name, visible)
|
||||
|
||||
def on_resize(self):
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user