mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Clean up FileOpen event handling
This commit is contained in:
parent
28fded9122
commit
4c0df1ba17
@ -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:
|
||||
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)
|
||||
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)
|
||||
added_event = True
|
||||
if added_event:
|
||||
QTimer.singleShot(1000, self._send_file_open_events)
|
||||
return True
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user