Windows: Book details panel: Fix selection not visible when using the system default theme

This commit is contained in:
Kovid Goyal 2024-08-02 12:19:49 +05:30
parent b0ddcfdc5a
commit 5203dc48d3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 0 deletions

View File

@ -1287,6 +1287,10 @@ class Application(QApplication):
if cft >= 0: if cft >= 0:
self.setCursorFlashTime(int(cft)) self.setCursorFlashTime(int(cft))
@property
def using_calibre_style(self) -> bool:
return self.palette_manager.using_calibre_style
@property @property
def is_dark_theme(self): def is_dark_theme(self):
return self.palette_manager.is_dark_theme return self.palette_manager.is_dark_theme

View File

@ -1061,6 +1061,12 @@ class BookInfo(HTMLDisplay):
ac.current_url = ac.current_fmt = None ac.current_url = ac.current_fmt = None
self.setFocusPolicy(Qt.FocusPolicy.NoFocus) self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.setDefaultStyleSheet(css()) 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): def change_layout(self, vertical):
if vertical != self.vertical: if vertical != self.vertical: