Skip to content
Permalink
Browse files
Book details panel: Pick the color used for links from the current sy…
…stem color theme
  • Loading branch information
kovidgoyal committed Jul 8, 2016
1 parent 7a54770 commit db8742a39316648c5f94b1dc26f0f50268a7f2c3
Showing with 16 additions and 14 deletions.
  1. +2 −1 resources/templates/book_details.css
  2. +11 −2 src/calibre/gui2/book_details.py
  3. +1 −8 src/calibre/gui2/dialogs/book_info.py
  4. +2 −3 src/calibre/gui2/viewer/ui.py
@@ -1,6 +1,7 @@
a {
text-decoration: none;
color: blue
/* LINK_COLOR below will be replaced with the link color defined by the current color theme */
color: LINK_COLOR
}

a:hover {
@@ -25,6 +25,16 @@
from calibre.utils.config import tweaks
from calibre.utils.localization import is_rtl

_css = None
def css():
global _css
if _css is None:
_css = P('templates/book_details.css', data=True).decode('utf-8')
col = QApplication.instance().palette().color(QPalette.Link).name()
_css = _css.replace('LINK_COLOR', col)
return _css


def render_html(mi, css, vertical, widget, all_fields=False, render_data_func=None): # {{{
table, comment_fields = (render_data_func or render_data)(mi, all_fields=all_fields,
use_roman_numbers=config['use_roman_numerals_for_series_number'])
@@ -422,7 +432,6 @@ def __init__(self, vertical, parent=None):
self.setAcceptDrops(False)
palette.setBrush(QPalette.Base, Qt.transparent)
self.page().setPalette(palette)
self.css = P('templates/book_details.css', data=True).decode('utf-8')
for x, icon in [
('remove_format', 'trash.png'), ('save_format', 'save.png'),
('restore_format', 'edit-undo.png'), ('copy_link','edit-copy.png'),
@@ -485,7 +494,7 @@ def turnoff_scrollbar(self, *args):
self.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)

def show_data(self, mi):
html = render_html(mi, self.css, self.vertical, self.parent())
html = render_html(mi, css(), self.vertical, self.parent())
self.setHtml(html)

def mouseDoubleClickEvent(self, ev):
@@ -14,16 +14,9 @@

from calibre.gui2 import gprefs, NO_URL_FORMATTING
from calibre import fit_image
from calibre.gui2.book_details import render_html, details_context_menu_event
from calibre.gui2.book_details import render_html, details_context_menu_event, css
from calibre.gui2.widgets import CoverView

_css = None
def css():
global _css
if _css is None:
_css = P('templates/book_details.css', data=True).decode('utf-8')
return _css

class Details(QWebView):

def __init__(self, book_info, parent=None):
@@ -75,21 +75,20 @@ def __init__(self, parent):
palette = self.palette()
palette.setBrush(QPalette.Base, Qt.transparent)
self.page().setPalette(palette)
self.css = P('templates/book_details.css', data=True).decode('utf-8')
self.setVisible(False)

def update_layout(self):
self.setGeometry(0, 0, self.parent().width(), self.parent().height())

def show_opf(self, opf, ext=''):
from calibre.gui2.book_details import render_html
from calibre.gui2.book_details import render_html, css
from calibre.ebooks.metadata.book.render import mi_to_html

def render_data(mi, use_roman_numbers=True, all_fields=False):
return mi_to_html(mi, use_roman_numbers=use_roman_numbers, rating_font=rating_font(), rtl=is_rtl())

mi = opf.to_book_metadata()
html = render_html(mi, self.css, True, self, render_data_func=render_data)
html = render_html(mi, css(), True, self, render_data_func=render_data)
self.setHtml(html)

def setVisible(self, x):

0 comments on commit db8742a

Please sign in to comment.