From 6297da1c69a62a175c6dd38f9da3fd60777d8432 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 19 Jul 2016 20:18:29 +0300 Subject: [PATCH] drag n drop (windows) --- toxygen/mainscreen_widgets.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/toxygen/mainscreen_widgets.py b/toxygen/mainscreen_widgets.py index 041658b..09c3f36 100644 --- a/toxygen/mainscreen_widgets.py +++ b/toxygen/mainscreen_widgets.py @@ -20,7 +20,12 @@ class MessageArea(QtGui.QPlainTextEdit): def keyPressEvent(self, event): if event.matches(QtGui.QKeySequence.Paste): - self.pasteEvent() + mimeData = QtGui.QApplication.clipboard().mimeData() + if mimeData.hasUrls(): + for url in mimeData.urls(): + self.pasteEvent(url.toString()) + else: + self.pasteEvent() elif event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): modifiers = event.modifiers() if modifiers & QtCore.Qt.ControlModifier or modifiers & QtCore.Qt.ShiftModifier: @@ -51,9 +56,13 @@ class MessageArea(QtGui.QPlainTextEdit): e.accept() def dropEvent(self, e): - if e.mimeData().hasFormat('text/plain'): + if e.mimeData().hasFormat('text/plain') or e.mimeData().hasFormat('text/html'): e.accept() self.pasteEvent(e.mimeData().text()) + elif e.mimeData().hasUrls(): + for url in e.mimeData().urls(): + self.pasteEvent(url.toString()) + e.accept() else: e.ignore() @@ -383,4 +392,3 @@ class WelcomeScreen(CenteredWidget): s = settings.Settings.get_instance() s['show_welcome_screen'] = False s.save() -