From ce84cc526b372b2580e35d11ef1fcc6f865b6b95 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sun, 8 Apr 2018 11:48:40 +0300 Subject: [PATCH] drag n drop fixes --- toxygen/mainscreen_widgets.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/toxygen/mainscreen_widgets.py b/toxygen/mainscreen_widgets.py index 9955771..0d1c26b 100644 --- a/toxygen/mainscreen_widgets.py +++ b/toxygen/mainscreen_widgets.py @@ -3,6 +3,7 @@ from widgets import RubberBandWindow, create_menu, QRightClickButton, CenteredWi from profile import Profile import smileys import util +import platform class MessageArea(QtWidgets.QPlainTextEdit): @@ -70,10 +71,18 @@ class MessageArea(QtWidgets.QPlainTextEdit): def pasteEvent(self, text=None): text = text or QtWidgets.QApplication.clipboard().text() if text.startswith('file://'): - self.parent.profile.send_file(text[7:]) + file_name = self.parse_file_name(text) + self.parent.profile.send_file(file_name) else: self.insertPlainText(text) + def parse_file_name(self, file_name): + import urllib + if file_name.endswith('\r\n'): + file_name = file_name[:-2] + file_name = urllib.parse.unquote(file_name) + return file_name[8 if platform.system() == 'Windows' else 7:] + class ScreenShotWindow(RubberBandWindow):