From 5203dc48d3e632832cbd1e92ce45fb907f2a1eed Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 2 Aug 2024 12:19:49 +0530 Subject: [PATCH] Windows: Book details panel: Fix selection not visible when using the system default theme --- src/calibre/gui2/__init__.py | 4 ++++ src/calibre/gui2/book_details.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index a8ee72ed7f..10adcd1b6a 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1287,6 +1287,10 @@ class Application(QApplication): if cft >= 0: self.setCursorFlashTime(int(cft)) + @property + def using_calibre_style(self) -> bool: + return self.palette_manager.using_calibre_style + @property def is_dark_theme(self): return self.palette_manager.is_dark_theme diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index 939e5480b1..0d0f5fb7f9 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -1061,6 +1061,12 @@ class BookInfo(HTMLDisplay): ac.current_url = ac.current_fmt = None self.setFocusPolicy(Qt.FocusPolicy.NoFocus) self.setDefaultStyleSheet(css()) + if iswindows and not QApplication.instance().using_calibre_style: + # workaround Qt bug that causes selected text to be invisible on + # windows when using system theme + bg = self.palette().color(QPalette.ColorRole.Highlight).name() + fg = self.palette().color(QPalette.ColorRole.HighlightedText).name() + self.setStyleSheet(f'QTextBrowser {{ selection-color: {fg}; selection-background-color: {bg}; }}') def change_layout(self, vertical): if vertical != self.vertical: