f transfers short update

This commit is contained in:
ingvar1995 2016-06-18 00:43:30 +03:00
parent 23b045070a
commit 7bdc506ff2
3 changed files with 13 additions and 9 deletions

View file

@ -259,7 +259,7 @@ class ReceiveToBuffer(FileTransfer):
self.state = TOX_FILE_TRANSFER_STATE['FINISHED'] self.state = TOX_FILE_TRANSFER_STATE['FINISHED']
self.signal() self.signal()
else: else:
data = bytearray(data) data = ''.join(chr(x) for x in data)
l = len(data) l = len(data)
if self._data_size < position: if self._data_size < position:
self._data += ('\0' * (position - self._data_size)) self._data += ('\0' * (position - self._data_size))

View file

@ -126,14 +126,13 @@ class MessageItem(QtGui.QWidget):
self.time.setText(time) self.time.setText(time)
self.message = MessageEdit(text, parent.width() - 150, self) 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']: if message_type != TOX_MESSAGE_TYPE['NORMAL']:
self.name.setStyleSheet("QLabel { color: #5CB3FF; }") self.name.setStyleSheet("QLabel { color: #5CB3FF; }")
self.message.setStyleSheet("QTextEdit { color: #5CB3FF; font: italic; font-size: 20px; }") self.message.setStyleSheet("QTextEdit { color: #5CB3FF; font: italic; font-size: 20px; }")
self.message.setAlignment(QtCore.Qt.AlignCenter) self.message.setAlignment(QtCore.Qt.AlignCenter)
self.time.setStyleSheet("QLabel { color: #5CB3FF; }") 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): def mark_as_sent(self):
if hasattr(self, 't'): if hasattr(self, 't'):

View file

@ -273,8 +273,8 @@ class Profile(contact.Contact, Singleton):
friend.clear_unsent_files() friend.clear_unsent_files()
if friend_number == self.get_active_number(): if friend_number == self.get_active_number():
self.update() self.update()
except: except Exception as ex:
pass print 'Exception in file sending: ' + str(ex)
def friend_exit(self, friend_number): def friend_exit(self, friend_number):
""" """
@ -492,7 +492,12 @@ class Profile(contact.Contact, Singleton):
return item return item
def create_message_item(self, text, time, owner, message_type, append=True): 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) item = MessageItem(text, time, name, owner != MESSAGE_OWNER['NOT_SENT'], message_type, self._messages)
elem = QtGui.QListWidgetItem() elem = QtGui.QListWidgetItem()
elem.setSizeHint(QtCore.QSize(self._messages.width(), item.height())) elem.setSizeHint(QtCore.QSize(self._messages.width(), item.height()))
@ -558,7 +563,6 @@ class Profile(contact.Contact, Singleton):
title = QtGui.QApplication.translate('MainWindow', title = QtGui.QApplication.translate('MainWindow',
'Set alias', 'Set alias',
None, QtGui.QApplication.UnicodeUTF8) None, QtGui.QApplication.UnicodeUTF8)
text, ok = QtGui.QInputDialog.getText(None, text, ok = QtGui.QInputDialog.getText(None,
title, title,
dialog, dialog,
@ -837,7 +841,8 @@ class Profile(contact.Contact, Singleton):
if friend_number == self.get_active_number(): if friend_number == self.get_active_number():
tmp = self._messages.count() + i tmp = self._messages.count() + i
if tmp >= 0: 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): def cancel_not_started_transfer(self, time):
self._friends[self._active_friend].delete_one_unsent_file(time) self._friends[self._active_friend].delete_one_unsent_file(time)