diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 290b572d2f..a8ee72ed7f 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1394,16 +1394,21 @@ class Application(QApplication): def event(self, e): etype = e.type() if etype == QEvent.Type.FileOpen: - url = e.url().toString(QUrl.ComponentFormattingOption.FullyEncoded) - if url and url.startswith('calibre://'): + added_event = False + qurl = e.url() + if qurl.isLocalFile(): with self._file_open_lock: - self._file_open_paths.append(url) - QTimer.singleShot(1000, self._send_file_open_events) - return True - path = str(e.file()) - if path and os.access(path, os.R_OK): - with self._file_open_lock: - self._file_open_paths.append(path) + path = qurl.toLocalFile() + if os.access(path, os.R_OK): + self._file_open_paths.append(path) + 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 + if added_event: QTimer.singleShot(1000, self._send_file_open_events) return True else: