From d4363da44f60aa4f07a0f4ea2eedd8e29ade6d93 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 24 Mar 2025 09:04:26 +0530 Subject: [PATCH] macOS: Fix regression in previous release that caused calibre:// URLs to no longer work Fixes #2103949 [Calibre URL Scheme broken in Calibre 8](https://bugs.launchpad.net/calibre/+bug/2103949) Qt regression: https://bugreports.qt.io/browse/QTBUG-134316 --- src/calibre/gui2/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index f18e1a38d4..c184e37f2a 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1213,6 +1213,8 @@ class Application(QApplication): QApplication.setDesktopFileName(override_program_name) QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts, True) # needed for webengine QApplication.__init__(self, args) + # See https://bugreports.qt.io/browse/QTBUG-134316 + QDesktopServices.setUrlHandler('calibre', self.handle_calibre_url) set_image_allocation_limit() self.palette_manager.initialize() icon_resource_manager.initialize() @@ -1413,10 +1415,8 @@ class Application(QApplication): added_event = True elif qurl.isValid(): if qurl.scheme() == 'calibre': - url = qurl.toString(QUrl.ComponentFormattingOption.FullyEncoded) - with self._file_open_lock: - self._file_open_paths.append(url) - added_event = True + added_event = True + self.handle_calibre_url(qurl) if added_event: QTimer.singleShot(1000, self._send_file_open_events) return True @@ -1425,6 +1425,13 @@ class Application(QApplication): self.palette_manager.on_qt_palette_change() return QApplication.event(self, e) + @pyqtSlot(QUrl) + def handle_calibre_url(self, qurl): + url = qurl.toString(QUrl.ComponentFormattingOption.FullyEncoded) + with self._file_open_lock: + self._file_open_paths.append(url) + QTimer.singleShot(100, self._send_file_open_events) + @property def current_custom_colors(self): from qt.core import QColorDialog