This commit is contained in:
Kovid Goyal 2023-11-25 08:10:56 +05:30
parent 93bde3df4d
commit 0fc95de045
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1464,14 +1464,13 @@ def open_url(qurl):
ensure_app() ensure_app()
ok = QDesktopServices.openUrl(qurl) ok = QDesktopServices.openUrl(qurl)
if not ok: if not ok:
# this happens a lot with Qt 6.5.3 on some Linux distros # this happens a lot with Qt 6.5.3. On Wayland, Qt requires
print('QDesktopServices.openUrl() failed for url:', qurl, file=sys.stderr) # BOTH a QApplication AND a top level window so it can use the
# xdg activation token system Wayland imposes.
print('QDesktopServices::openUrl() failed for url:', qurl, file=sys.stderr)
if islinux: if islinux:
import subprocess import subprocess
if qurl.isLocalFile(): cmd = ['xdg-open', qurl.toLocalFile() if qurl.isLocalFile() else qurl.toString()]
cmd = ['xdg-open', qurl.toLocalFile()]
else:
cmd = ['xdg-open', qurl.toString()]
if DEBUG: if DEBUG:
print('Running opener:', cmd) print('Running opener:', cmd)
subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)