mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Linux: When Qt fails to open a file with the system default application fallback to xdg-open explicitly
Who knows what Qt does these days. Portals and desktop heauristics and platform plugins. Sigh. Linux is such a clusterfuck.
This commit is contained in:
parent
4bd1ea9f70
commit
4a7c5dbd5a
@ -1462,7 +1462,18 @@ def open_url(qurl):
|
|||||||
# Qt 5 requires QApplication to be constructed before trying to use
|
# Qt 5 requires QApplication to be constructed before trying to use
|
||||||
# QDesktopServices::openUrl()
|
# QDesktopServices::openUrl()
|
||||||
ensure_app()
|
ensure_app()
|
||||||
QDesktopServices.openUrl(qurl)
|
ok = QDesktopServices.openUrl(qurl)
|
||||||
|
if not ok:
|
||||||
|
# this happens a lot with Qt 6.5.3 on some Linux distros
|
||||||
|
print('QDesktopServices.openUrl() failed for url:', qurl, file=sys.stderr)
|
||||||
|
if islinux:
|
||||||
|
if qurl.isLocalFile():
|
||||||
|
cmd = ['xdg-open', qurl.toLocalFile()]
|
||||||
|
else:
|
||||||
|
cmd = ['xdg-open', qurl.toString()]
|
||||||
|
if DEBUG:
|
||||||
|
print('Running opener:', cmd)
|
||||||
|
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
def safe_open_url(qurl):
|
def safe_open_url(qurl):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user