mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When using a dark color scheme fix the link color everywhere not just in the book details
This commit is contained in:
parent
420b2f65b4
commit
30731ad4e3
@ -16,7 +16,7 @@ from threading import Lock, RLock
|
||||
from PyQt5.Qt import (
|
||||
QT_VERSION, QApplication, QBuffer, QByteArray, QCoreApplication, QDateTime,
|
||||
QDesktopServices, QDialog, QEvent, QFileDialog, QFileIconProvider, QFileInfo,
|
||||
QFont, QFontDatabase, QFontInfo, QFontMetrics, QIcon, QLocale,
|
||||
QFont, QFontDatabase, QFontInfo, QFontMetrics, QIcon, QLocale, QColor,
|
||||
QNetworkProxyFactory, QObject, QSettings, QSocketNotifier, QStringListModel, Qt,
|
||||
QThread, QTimer, QTranslator, QUrl, pyqtSignal
|
||||
)
|
||||
@ -1011,6 +1011,11 @@ class Application(QApplication):
|
||||
prints('Using calibre Qt style:', self.using_calibre_style)
|
||||
if self.using_calibre_style:
|
||||
self.load_calibre_style()
|
||||
self.is_dark_theme = is_dark_theme()
|
||||
if self.is_dark_theme:
|
||||
pal = self.palette()
|
||||
pal.setColor(pal.Link, QColor('#6CB4EE'))
|
||||
self.setPalette(pal)
|
||||
|
||||
def load_calibre_style(self):
|
||||
icon_map = self.__icon_map_memory_ = {}
|
||||
|
@ -23,7 +23,7 @@ from calibre.ebooks.metadata.search_internet import (
|
||||
)
|
||||
from calibre.gui2 import (
|
||||
NO_URL_FORMATTING, choose_save_file, config, default_author_link, gprefs,
|
||||
is_dark_theme, pixmap_to_data, rating_font, safe_open_url
|
||||
pixmap_to_data, rating_font, safe_open_url
|
||||
)
|
||||
from calibre.gui2.dnd import (
|
||||
dnd_get_files, dnd_get_image, dnd_has_extension, dnd_has_image, image_extensions
|
||||
@ -61,13 +61,6 @@ def css(reset=False):
|
||||
return css.ans
|
||||
|
||||
|
||||
def themed_css(reset=False):
|
||||
ans = css(reset)
|
||||
if is_dark_theme():
|
||||
ans = 'a { color: #6CB4EE }\n\n' + ans
|
||||
return ans
|
||||
|
||||
|
||||
def copy_all(text_browser):
|
||||
mf = getattr(text_browser, 'details', text_browser)
|
||||
c = QApplication.clipboard()
|
||||
@ -562,10 +555,10 @@ class BookInfo(HTMLDisplay):
|
||||
ac.data = (None, None, None)
|
||||
ac.triggered.connect(self.remove_item_triggered)
|
||||
self.setFocusPolicy(Qt.NoFocus)
|
||||
self.document().setDefaultStyleSheet(themed_css())
|
||||
self.document().setDefaultStyleSheet(self.default_css + css())
|
||||
|
||||
def refresh_css(self):
|
||||
self.document().setDefaultStyleSheet(themed_css(True))
|
||||
self.document().setDefaultStyleSheet(self.default_css + css(True))
|
||||
|
||||
def remove_item_triggered(self):
|
||||
field, value, book_id = self.remove_item_action.data
|
||||
|
@ -12,7 +12,7 @@ from PyQt5.Qt import (
|
||||
from calibre import fit_image
|
||||
from calibre.gui2 import NO_URL_FORMATTING, gprefs
|
||||
from calibre.gui2.book_details import (
|
||||
themed_css, details_context_menu_event, render_html, set_html
|
||||
css, details_context_menu_event, render_html, set_html
|
||||
)
|
||||
from calibre.gui2.ui import get_gui
|
||||
from calibre.gui2.widgets import CoverView
|
||||
@ -83,7 +83,7 @@ class Details(HTMLDisplay):
|
||||
def __init__(self, book_info, parent=None):
|
||||
HTMLDisplay.__init__(self, parent)
|
||||
self.book_info = book_info
|
||||
self.document().setDefaultStyleSheet(themed_css())
|
||||
self.document().setDefaultStyleSheet(self.default_css + css())
|
||||
|
||||
def sizeHint(self):
|
||||
return QSize(350, 350)
|
||||
|
@ -434,6 +434,13 @@ class HTMLDisplay(QTextBrowser):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QTextBrowser.__init__(self, parent)
|
||||
self.default_css = ''
|
||||
app = QApplication.instance()
|
||||
if app.is_dark_theme:
|
||||
pal = app.palette()
|
||||
col = pal.color(pal.Link)
|
||||
self.default_css = 'a { color: %s }\n\n' % col.name(col.HexRgb)
|
||||
self.document().setDefaultStyleSheet(self.default_css)
|
||||
font = self.font()
|
||||
f = QFontInfo(font)
|
||||
delta = tweaks['change_book_details_font_size_by'] + 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user