drag and drop for windows
This commit is contained in:
2
main.py
2
main.py
@@ -149,7 +149,7 @@ class MainWindow(QMainWindow):
|
||||
self._update_recent_files_menu()
|
||||
|
||||
def dragEnterEvent(self, e: QDragEnterEvent):
|
||||
if e.mimeData().hasFormat('text/plain') and url_is_file(e.mimeData().text()):
|
||||
if url_is_file(e.mimeData().text()):
|
||||
e.accept()
|
||||
else:
|
||||
e.ignore()
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
import sys
|
||||
|
||||
|
||||
def url_to_path(url: str) -> str:
|
||||
p = urlparse(url)
|
||||
if sys.platform == 'win32' or sys.platform == 'cygwin':
|
||||
return os.path.abspath(p.path[1:])
|
||||
return os.path.abspath(os.path.join(p.netloc, p.path))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user