env var to override the headless platform used by Qt

This commit is contained in:
Kovid Goyal 2024-04-19 07:50:52 +05:30
parent f0c0378e92
commit cc9afd6371
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1189,10 +1189,9 @@ class Application(QApplication):
args = [override_program_name] + args[1:] args = [override_program_name] + args[1:]
self.palette_manager = PaletteManager(force_calibre_style, headless) self.palette_manager = PaletteManager(force_calibre_style, headless)
if headless: if headless:
args.extend(('-platformpluginpath', plugins_loc, '-platform', 'headless')) args.extend(('-platformpluginpath', plugins_loc, '-platform', os.environ.get('CALIBRE_HEADLESS_PLATFORM', 'headless')))
else: else:
args.extend(self.palette_manager.args_to_qt) args.extend(self.palette_manager.args_to_qt)
self.headless = headless self.headless = headless
from calibre_extensions import progress_indicator from calibre_extensions import progress_indicator
self.pi = progress_indicator self.pi = progress_indicator
@ -1583,7 +1582,7 @@ def ensure_app(headless=True):
args = sys.argv[:1] args = sys.argv[:1]
has_headless = ismacos or islinux or isbsd has_headless = ismacos or islinux or isbsd
if headless and has_headless: if headless and has_headless:
args += ['-platformpluginpath', plugins_loc, '-platform', 'headless'] args += ['-platformpluginpath', plugins_loc, '-platform', os.environ.get('CALIBRE_HEADLESS_PLATFORM', 'headless')]
if ismacos: if ismacos:
os.environ['QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM'] = '1' os.environ['QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM'] = '1'
if headless and iswindows: if headless and iswindows: