Skip to content

Commit 52a2913

Browse files
committed
[ui.widgets] fix drag and drop support on Windows
fixes #1 with solution described in https://bugreports.qt.io/browse/QTBUG-46417
1 parent 14bbe8b commit 52a2913

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/slice/ui/widgets.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,15 @@ def __init__(self, parent, *args):
3131
self.setPlaceholderText("Drop a variable font here or click the Open button")
3232

3333
def dragEnterEvent(self, e):
34-
# mime data types are defined in
35-
# https://www.tutorialspoint.com/pyqt5/pyqt5_drag_and_drop.htm
36-
if e.mimeData().hasText():
34+
if e.mimeData().hasUrls():
3735
e.accept()
3836
else:
3937
e.ignore()
4038

4139
def dropEvent(self, e):
42-
cleaned_text = self.clean_file_path(e.mimeData().text())
40+
file_path = e.mimeData().urls()[0].toLocalFile()
4341
# set the text entry area
44-
self.setText(cleaned_text)
42+
self.setText(file_path)
4543
# call the parent method to load font on UI
46-
self.parent.load_font(cleaned_text)
44+
self.parent.load_font(file_path)
4745

48-
def clean_file_path(self, text):
49-
return text.replace("file://", "")

0 commit comments

Comments
 (0)