Edit Book: Allow the color of the links in the Live CSS panel to be themed. Fixes #1326897 [Custom Colors schemes, hard coded to the "hyperlink color"](https://bugs.launchpad.net/calibre/+bug/1326897)

This commit is contained in:
Kovid Goyal 2014-06-06 21:38:30 +05:30
parent c5a1065a76
commit d5e2c1f4cc
2 changed files with 7 additions and 1 deletions

View File

@ -70,6 +70,7 @@ SOLARIZED = \
Error us=wave uc={red}
SpellError us=wave uc={orange}
Tooltip fg=black bg=ffffed
Link fg={blue}
DiffDelete bg={base02} fg={red}
DiffInsert bg={base02} fg={green}
@ -111,6 +112,7 @@ THEMES = {
Error us=wave uc=red
SpellError us=wave uc=orange
SpecialCharacter bg={cursor_loc}
Link fg=cyan
DiffDelete bg=341414 fg=642424
DiffInsert bg=143414 fg=246424
@ -157,6 +159,7 @@ THEMES = {
SpecialCharacter bg={cursor_loc}
Error us=wave uc=red
SpellError us=wave uc=magenta
Link fg=blue
DiffDelete bg=rgb(255,180,200) fg=rgb(200,80,110)
DiffInsert bg=rgb(180,255,180) fg=rgb(80,210,80)
@ -224,7 +227,6 @@ def read_theme(raw):
ans[name] = Highlight(fg, bg, bold, italic, underline, underline_color)
return ans
THEMES = {k:read_theme(raw) for k, raw in THEMES.iteritems()}
def u(x):
@ -584,6 +586,9 @@ class ThemeEditor(Dialog):
data.pop(k)
for k in missing:
data[k] = dict(THEMES[default_theme()][k]._asdict())
for nk, nv in data[k].iteritems():
if isinstance(nv, QBrush):
data[k][nk] = unicode(nv.color().name())
if extra or missing:
tprefs['custom_themes'][name] = data
return data

View File

@ -364,6 +364,7 @@ class LiveCSS(QWidget):
pal.setColor(pal.Window, theme_color(theme, 'Normal', 'bg'))
pal.setColor(pal.WindowText, theme_color(theme, 'Normal', 'fg'))
pal.setColor(pal.AlternateBase, theme_color(theme, 'HighlightRegion', 'bg'))
pal.setColor(pal.Link, theme_color(theme, 'Link', 'fg'))
pal.setColor(pal.LinkVisited, theme_color(theme, 'Keyword', 'fg'))
self.setPalette(pal)
if hasattr(self, 'box'):