From 286efc792eb87c343e96dae9cee6c30fbf0fa593 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Nov 2019 20:44:16 +0530 Subject: [PATCH] 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) --- src/calibre/gui2/viewer/web_view.py | 13 ++++++++++--- src/pyj/read_book/globals.pyj | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/viewer/web_view.py b/src/calibre/gui2/viewer/web_view.py index 22b36d438c..17fb801177 100644 --- a/src/calibre/gui2/viewer/web_view.py +++ b/src/calibre/gui2/viewer/web_view.py @@ -387,12 +387,19 @@ class Inspector(QWidget): def system_colors(): - pal = QApplication.instance().palette() - return { + app = QApplication.instance() + is_dark_theme = app.is_dark_theme + pal = app.palette() + ans = { 'background': pal.color(pal.Base).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): diff --git a/src/pyj/read_book/globals.pyj b/src/pyj/read_book/globals.pyj index b906c67f31..8244679b77 100644 --- a/src/pyj/read_book/globals.pyj +++ b/src/pyj/read_book/globals.pyj @@ -60,7 +60,9 @@ def set_system_colors(spec): c = default_color_schemes.system c.foreground = spec.foreground c.background = spec.background - c.link = spec.link + v'delete c.link' + if spec.link: + c.link = spec.link register_callback(def(): # Ensure the color scheme names are translated