mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Some improvements to palette change handling
1) Dont use the paletteChanged signal since it is deprecated in Qt 6 2) Dont apply the workaround for: https://bugreports.qt.io/browse/QTBUG-75321 as its not needed as far as I can tell i Qt 6 and it causes switching back to the light theme to have some incorrect colors
This commit is contained in:
parent
da775a7adc
commit
a497e7698b
@ -1123,18 +1123,8 @@ class Application(QApplication):
|
||||
prints('Using calibre Qt style:', self.using_calibre_style)
|
||||
if self.using_calibre_style:
|
||||
self.load_calibre_style()
|
||||
self.paletteChanged.connect(self.on_palette_change)
|
||||
self.on_palette_change()
|
||||
|
||||
def fix_combobox_text_color(self):
|
||||
# Workaround for https://bugreports.qt.io/browse/QTBUG-75321
|
||||
# Buttontext is set to black for some reason
|
||||
pal = QPalette(self.palette())
|
||||
pal.setColor(QPalette.ColorRole.ButtonText, pal.color(QPalette.ColorRole.WindowText))
|
||||
self.ignore_palette_changes = True
|
||||
self.setPalette(pal, 'QComboBox')
|
||||
self.ignore_palette_changes = False
|
||||
|
||||
def set_palette(self, pal):
|
||||
self.ignore_palette_changes = True
|
||||
self.setPalette(pal)
|
||||
@ -1146,12 +1136,8 @@ class Application(QApplication):
|
||||
self.ignore_palette_changes = False
|
||||
|
||||
def on_palette_change(self):
|
||||
if self.ignore_palette_changes:
|
||||
return
|
||||
self.is_dark_theme = is_dark_theme()
|
||||
self.setProperty('is_dark_theme', self.is_dark_theme)
|
||||
if ismacos and self.is_dark_theme and self.using_calibre_style:
|
||||
QTimer.singleShot(0, self.fix_combobox_text_color)
|
||||
if self.using_calibre_style:
|
||||
ss = 'QTabBar::tab:selected { font-style: italic }\n\n'
|
||||
if self.is_dark_theme:
|
||||
@ -1213,7 +1199,8 @@ class Application(QApplication):
|
||||
self.installTranslator(self._translator)
|
||||
|
||||
def event(self, e):
|
||||
if callable(self.file_event_hook) and e.type() == QEvent.Type.FileOpen:
|
||||
etype = e.type()
|
||||
if callable(self.file_event_hook) and etype == QEvent.Type.FileOpen:
|
||||
url = e.url().toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
||||
if url and url.startswith('calibre://'):
|
||||
with self._file_open_lock:
|
||||
@ -1227,6 +1214,9 @@ class Application(QApplication):
|
||||
QTimer.singleShot(1000, self._send_file_open_events)
|
||||
return True
|
||||
else:
|
||||
if etype == QEvent.Type.ApplicationPaletteChange:
|
||||
if not self.ignore_palette_changes:
|
||||
self.on_palette_change()
|
||||
return QApplication.event(self, e)
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user