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):
|
def event(self, e):
|
||||||
etype = e.type()
|
etype = e.type()
|
||||||
if etype == QEvent.Type.FileOpen:
|
if etype == QEvent.Type.FileOpen:
|
||||||
url = e.url().toString(QUrl.ComponentFormattingOption.FullyEncoded)
|
added_event = False
|
||||||
if url and url.startswith('calibre://'):
|
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:
|
with self._file_open_lock:
|
||||||
self._file_open_paths.append(url)
|
self._file_open_paths.append(url)
|
||||||
QTimer.singleShot(1000, self._send_file_open_events)
|
added_event = True
|
||||||
return True
|
if added_event:
|
||||||
path = str(e.file())
|
|
||||||
if path and os.access(path, os.R_OK):
|
|
||||||
with self._file_open_lock:
|
|
||||||
self._file_open_paths.append(path)
|
|
||||||
QTimer.singleShot(1000, self._send_file_open_events)
|
QTimer.singleShot(1000, self._send_file_open_events)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user