Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix drag and drop bug on non-Windows platforms #7

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

Jobsecond
Copy link

@Jobsecond Jobsecond commented Jan 9, 2023

Currently, the drag and drop only works on Windows, not on macOS.

This is because file urls are different:

Platform Path URL .replace('file:///', '')
Windows D:/audio/sample.wav file:///D:/audio/sample.wav D:/audio/sample.wav
macOS /Users/apple/sample.wav file:///Users/apple/sample.wav Users/apple/sample.wav

So, simply removing file:/// is not portable across platforms.

A portable solution is to use urls() method of QMimeData to get a list of file urls (QUrl), iterate through the list and use toLocalFile() method to convert the URL to path string.

@flutydeer flutydeer merged commit fa9dc3c into flutydeer:main Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants