Ignore Qt generated application palette changes when using a fixed palette. Fixes #1982050 [Calibre 6.0+ Switching from Dark Mode to Light after Editing Metadata and Reconnecting RDP](https://bugs.launchpad.net/calibre/+bug/1982050)

This commit is contained in:
Kovid Goyal 2022-07-19 13:45:43 +05:30
parent c049126bcb
commit 56c7f3e007
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1415,7 +1415,18 @@ class Application(QApplication):
return True
else:
if etype == QEvent.Type.ApplicationPaletteChange:
if DEBUG:
if self.ignore_palette_changes:
print('ApplicationPaletteChange event ignored', file=sys.stderr)
else:
print('ApplicationPaletteChange event received', file=sys.stderr)
if not self.ignore_palette_changes:
if gprefs['color_palette'] != 'system':
pal = dark_palette() if gprefs['color_palette'] == 'dark' else self.original_palette
if self.palette().color(QPalette.ColorRole.Window) != pal.color(QPalette.ColorRole.Window):
if DEBUG:
print('Detected a spontaneous palette change in windows, reverting it', file=sys.stderr)
self.set_palette(pal)
self.on_palette_change()
return QApplication.event(self, e)