Skip to content

Commit

Permalink
Merge pull request flutydeer#7 from Jobsecond/patch-drag-and-drop
Browse files Browse the repository at this point in the history
Fix drag and drop bug on non-Windows platforms
  • Loading branch information
flutydeer authored Jan 16, 2023
2 parents d23b965 + 34e9447 commit fa9dc3c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ def closeEvent(self, event):
event.ignore()

def dragEnterEvent(self, event):
paths = str.splitlines(event.mimeData().text())
urls = event.mimeData().urls()
has_wav = False
for path in paths:
for url in urls:
path = url.toLocalFile()
ext = os.path.splitext(path)[1]
if ext.lower() == '.wav':
has_wav = True
Expand All @@ -205,13 +206,14 @@ def dragEnterEvent(self, event):
event.accept()

def dropEvent(self, event):
paths = str.splitlines(event.mimeData().text())
for path in paths:
urls = event.mimeData().urls()
for url in urls:
path = url.toLocalFile()
ext = os.path.splitext(path)[1]
if ext.lower() != '.wav':
continue
item = QListWidgetItem()
item.setText(QFileInfo(path).fileName())
item.setData(Qt.ItemDataRole.UserRole + 1,
path.replace('file:///', ''))
path)
self.ui.listWidgetTaskList.addItem(item)

0 comments on commit fa9dc3c

Please sign in to comment.