mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-30 23:00:21 -04:00
Set the background color for the image popup explicitly instead of relying on QPalette which is apparently broken on some Linux systems. Sigh. Fixes #2110503 [[Enhancement] Use a dark background for the Image viewer when using a dark theme](https://bugs.launchpad.net/calibre/+bug/2110503)
This commit is contained in:
parent
1b49390bcf
commit
e4a3f7d14e
@ -32,6 +32,7 @@ from qt.core import (
|
||||
|
||||
from calibre import fit_image
|
||||
from calibre.gui2 import NO_URL_FORMATTING, choose_save_file, gprefs, max_available_height
|
||||
from calibre.gui2.palette import dark_palette
|
||||
|
||||
|
||||
def render_svg(widget, path):
|
||||
@ -61,7 +62,7 @@ class Label(QLabel):
|
||||
def __init__(self, scrollarea):
|
||||
super().__init__(scrollarea)
|
||||
scrollarea.zoom_requested.connect(self.zoom_requested)
|
||||
self.setBackgroundRole(QPalette.ColorRole.Text if QApplication.instance().is_dark_theme else QPalette.ColorRole.Base)
|
||||
self.setBackgroundRole(QPalette.ColorRole.NoRole)
|
||||
self.setSizePolicy(QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Ignored)
|
||||
self.setScaledContents(True)
|
||||
self.default_cursor = self.cursor()
|
||||
@ -163,6 +164,10 @@ class ImageView(QDialog):
|
||||
ac.triggered.connect(self.rotate_image)
|
||||
|
||||
self.scrollarea = sa = ScrollArea()
|
||||
pal = sa.palette()
|
||||
pal.setColor(QPalette.ColorRole.Dark,
|
||||
dark_palette().color(QPalette.ColorRole.Base) if QApplication.instance().is_dark_theme else Qt.GlobalColor.darkGray)
|
||||
sa.setPalette(pal)
|
||||
sa.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter)
|
||||
sa.setBackgroundRole(QPalette.ColorRole.Dark)
|
||||
self.label = l = Label(sa)
|
||||
|
Loading…
x
Reference in New Issue
Block a user