Viewer: When using the system color theme only override link colors in the book if the theme is dark. Fixes #1852990 [Viewer ignores color-property for links](https://bugs.launchpad.net/calibre/+bug/1852990)

This commit is contained in:
Kovid Goyal 2019-11-21 20:44:16 +05:30
parent ee5dd52ec1
commit 286efc792e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 4 deletions

View File

@ -387,12 +387,19 @@ class Inspector(QWidget):
def system_colors(): def system_colors():
pal = QApplication.instance().palette() app = QApplication.instance()
return { is_dark_theme = app.is_dark_theme
pal = app.palette()
ans = {
'background': pal.color(pal.Base).name(), 'background': pal.color(pal.Base).name(),
'foreground': pal.color(pal.Text).name(), 'foreground': pal.color(pal.Text).name(),
'link': pal.color(pal.Link).name(),
} }
if is_dark_theme:
# only override link colors for dark themes
# since if the book specifies its own link colors
# they will likely work well with light themes
ans['link'] = pal.color(pal.Link).name()
return ans
class WebView(RestartingWebEngineView): class WebView(RestartingWebEngineView):

View File

@ -60,7 +60,9 @@ def set_system_colors(spec):
c = default_color_schemes.system c = default_color_schemes.system
c.foreground = spec.foreground c.foreground = spec.foreground
c.background = spec.background c.background = spec.background
c.link = spec.link v'delete c.link'
if spec.link:
c.link = spec.link
register_callback(def(): register_callback(def():
# Ensure the color scheme names are translated # Ensure the color scheme names are translated