From 7bdc506ff2cf8699013382a593db7fd11b382e35 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 18 Jun 2016 00:43:30 +0300 Subject: [PATCH] f transfers short update --- src/file_transfers.py | 2 +- src/list_items.py | 5 ++--- src/profile.py | 15 ++++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/file_transfers.py b/src/file_transfers.py index 556f86b..bd74077 100644 --- a/src/file_transfers.py +++ b/src/file_transfers.py @@ -259,7 +259,7 @@ class ReceiveToBuffer(FileTransfer): self.state = TOX_FILE_TRANSFER_STATE['FINISHED'] self.signal() else: - data = bytearray(data) + data = ''.join(chr(x) for x in data) l = len(data) if self._data_size < position: self._data += ('\0' * (position - self._data_size)) diff --git a/src/list_items.py b/src/list_items.py index fca7024..8308def 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -126,14 +126,13 @@ class MessageItem(QtGui.QWidget): self.time.setText(time) self.message = MessageEdit(text, parent.width() - 150, self) - self.message.setGeometry(QtCore.QRect(100, 0, parent.width() - 150, self.message.height())) - self.setFixedHeight(self.message.height()) - if message_type != TOX_MESSAGE_TYPE['NORMAL']: self.name.setStyleSheet("QLabel { color: #5CB3FF; }") self.message.setStyleSheet("QTextEdit { color: #5CB3FF; font: italic; font-size: 20px; }") self.message.setAlignment(QtCore.Qt.AlignCenter) self.time.setStyleSheet("QLabel { color: #5CB3FF; }") + self.message.setGeometry(QtCore.QRect(100, 0, parent.width() - 150, self.message.height())) + self.setFixedHeight(self.message.height()) def mark_as_sent(self): if hasattr(self, 't'): diff --git a/src/profile.py b/src/profile.py index ab0faf6..2bef97c 100644 --- a/src/profile.py +++ b/src/profile.py @@ -273,8 +273,8 @@ class Profile(contact.Contact, Singleton): friend.clear_unsent_files() if friend_number == self.get_active_number(): self.update() - except: - pass + except Exception as ex: + print 'Exception in file sending: ' + str(ex) def friend_exit(self, friend_number): """ @@ -492,7 +492,12 @@ class Profile(contact.Contact, Singleton): return item def create_message_item(self, text, time, owner, message_type, append=True): - name = self.get_active_name() if owner == MESSAGE_OWNER['FRIEND'] else self.name + if message_type == MESSAGE_TYPE['INFO_MESSAGE']: + name = '' + elif owner == MESSAGE_OWNER['FRIEND']: + name = self.get_active_name() + else: + name = self._name item = MessageItem(text, time, name, owner != MESSAGE_OWNER['NOT_SENT'], message_type, self._messages) elem = QtGui.QListWidgetItem() elem.setSizeHint(QtCore.QSize(self._messages.width(), item.height())) @@ -558,7 +563,6 @@ class Profile(contact.Contact, Singleton): title = QtGui.QApplication.translate('MainWindow', 'Set alias', None, QtGui.QApplication.UnicodeUTF8) - text, ok = QtGui.QInputDialog.getText(None, title, dialog, @@ -837,7 +841,8 @@ class Profile(contact.Contact, Singleton): if friend_number == self.get_active_number(): tmp = self._messages.count() + i if tmp >= 0: - self._messages.itemWidget(self._messages.item(tmp)).update(TOX_FILE_TRANSFER_STATE['CANCELLED'], 0) + self._messages.itemWidget(self._messages.item(tmp)).update(TOX_FILE_TRANSFER_STATE['CANCELLED'], + 0, -1) def cancel_not_started_transfer(self, time): self._friends[self._active_friend].delete_one_unsent_file(time)