From a984b624b5b8894135856c576cc9152cb9c1913d Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 4 Mar 2020 00:34:10 +0300 Subject: [PATCH] Added ability to paste image --- toxygen/mainscreen_widgets.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/toxygen/mainscreen_widgets.py b/toxygen/mainscreen_widgets.py index 0d1c26b..dcbc075 100644 --- a/toxygen/mainscreen_widgets.py +++ b/toxygen/mainscreen_widgets.py @@ -73,8 +73,16 @@ class MessageArea(QtWidgets.QPlainTextEdit): if text.startswith('file://'): file_name = self.parse_file_name(text) self.parent.profile.send_file(file_name) - else: + elif text: self.insertPlainText(text) + else: + image = QtWidgets.QApplication.clipboard().image() + if image is not None: + byte_array = QtCore.QByteArray() + buffer = QtCore.QBuffer(byte_array) + buffer.open(QtCore.QIODevice.WriteOnly) + image.save(buffer, 'PNG') + self.parent.profile.send_screenshot(bytes(byte_array.data())) def parse_file_name(self, file_name): import urllib