From 183dfadc776cbfba5dfab911c8ef0ad55e7fd90a Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 15 Jun 2016 16:15:23 +0300 Subject: [PATCH] bug fixes --- src/list_items.py | 54 ++++++----------------------------------------- src/menu.py | 6 ++++-- src/profile.py | 18 +++++++++------- 3 files changed, 20 insertions(+), 58 deletions(-) diff --git a/src/list_items.py b/src/list_items.py index a6a5cd4..c2210f4 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -356,58 +356,16 @@ class FileTransferItem(QtGui.QListWidget): self.state = state -class UnsentFileItem(QtGui.QListWidget): +class UnsentFileItem(FileTransferItem): def __init__(self, file_name, size, user, time, width, parent=None): - QtGui.QListWidget.__init__(self, parent) - self.resize(QtCore.QSize(width, 34)) - self.time = time - self.setStyleSheet('QListWidget { border: 1px solid #FF8000; }') + super(UnsentFileItem, self).__init__(file_name, size, time, user, -1, -1, + FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND'], width, parent) + self._time = time - self.name = DataLabel(self) - self.name.setGeometry(QtCore.QRect(3, 7, 95, 20)) - self.name.setTextFormat(QtCore.Qt.PlainText) - font = QtGui.QFont() - font.setFamily("Times New Roman") - font.setPointSize(11) - font.setBold(True) - self.name.setFont(font) - self.name.setText(user) - - self.time = QtGui.QLabel(self) - self.time.setGeometry(QtCore.QRect(width - 53, 7, 50, 20)) - font.setPointSize(10) - font.setBold(False) - self.time.setFont(font) - self.time.setText(convert_time(time)) - - self.cancel = QtGui.QPushButton(self) - self.cancel.setGeometry(QtCore.QRect(width - 120, 2, 30, 30)) - pixmap = QtGui.QPixmap(curr_directory() + '/images/decline.png') - icon = QtGui.QIcon(pixmap) - self.cancel.setIcon(icon) - self.cancel.setIconSize(QtCore.QSize(30, 30)) - self.cancel.clicked.connect(self.cancel_transfer) - self.cancel.setStyleSheet('QPushButton:hover { border: 1px solid #3A3939; background-color: none;}') - - self.file_name = DataLabel(self) - self.file_name.setGeometry(QtCore.QRect(210, 7, width - 400, 20)) - font.setPointSize(12) - self.file_name.setFont(font) - file_size = size / 1024 - if not file_size: - file_size = '{}B'.format(size) - elif file_size >= 1024: - file_size = '{}MB'.format(file_size / 1024) - else: - file_size = '{}KB'.format(file_size) - file_data = u'{} {}'.format(file_size, file_name) - self.file_name.setText(file_data) - self.setFocusPolicy(QtCore.Qt.NoFocus) - - def cancel_transfer(self): + def cancel_transfer(self, *args): pr = profile.Profile.get_instance() - pr.cancel_not_started_transfer(self.time) + pr.cancel_not_started_transfer(self._time) class InlineImageItem(QtGui.QWidget): diff --git a/src/menu.py b/src/menu.py index 4b18c44..a7ed8bd 100644 --- a/src/menu.py +++ b/src/menu.py @@ -673,8 +673,10 @@ class PluginsSettings(CenteredWidget): self.window.show() else: msgBox = QtGui.QMessageBox() - text = (QtGui.QApplication.translate("PluginsForm", 'No GUI found for this plugin', None, - QtGui.QApplication.UnicodeUTF8)) + text = QtGui.QApplication.translate("PluginsForm", 'No GUI found for this plugin', None, + QtGui.QApplication.UnicodeUTF8) + msgBox.setWindowTitle(QtGui.QApplication.translate("PluginsForm", 'Error', None, + QtGui.QApplication.UnicodeUTF8)) msgBox.setText(text) msgBox.exec_() diff --git a/src/profile.py b/src/profile.py index 293ce25..2695c3b 100644 --- a/src/profile.py +++ b/src/profile.py @@ -276,11 +276,11 @@ class Profile(contact.Contact, Singleton): self.friend_typing(friend_number, False) if friend_number in self._call: self._call.finish_call(friend_number, True) - for key in filter(lambda x: x[0] == friend_number, self._file_transfers.keys()): - if type(self._file_transfers[key]) in (ReceiveAvatar, SendAvatar): - self._file_transfers[key].cancelled() - else: - self._file_transfers[key].pause(False) + # for key in filter(lambda x: x[0] == friend_number, self._file_transfers.keys()): + # if type(self._file_transfers[key]) in (ReceiveAvatar, SendAvatar): + # self._file_transfers[key].cancelled() + # else: + # self._file_transfers[key].pause(False) # ----------------------------------------------------------------------------------------------------------------- # Typing notifications @@ -885,14 +885,14 @@ class Profile(contact.Contact, Singleton): self.update() return elif friend.status is None and is_resend: - raise Exception() + raise RuntimeError() st = SendFromBuffer(self._tox, friend.number, data, file_name) self._file_transfers[(friend.number, st.get_file_number())] = st tm = TransferMessage(MESSAGE_OWNER['ME'], time.time(), FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND'], # OUTGOING NOT STARTED len(data), - 'toxygen_inline.png', + file_name, friend.number, st.get_file_number()) item = self.create_file_transfer_item(tm) @@ -905,6 +905,7 @@ class Profile(contact.Contact, Singleton): Send file to current active friend :param path: file path :param number: friend_number + :param is_resend: is 'offline' message """ friend_number = number or self.get_active_number() friend = self.get_friend_by_number(friend_number) @@ -914,7 +915,7 @@ class Profile(contact.Contact, Singleton): self.update() return elif friend.status is None and is_resend: - raise Exception() + raise RuntimeError() st = SendTransfer(path, self._tox, friend_number) self._file_transfers[(friend_number, st.get_file_number())] = st tm = TransferMessage(MESSAGE_OWNER['ME'], @@ -973,6 +974,7 @@ class Profile(contact.Contact, Singleton): FILE_TRANSFER_MESSAGE_STATUS['FINISHED'], inline) #self.update() + # TODO: fix else: self.get_friend_by_number(friend_number).update_transfer_data(file_number, FILE_TRANSFER_MESSAGE_STATUS['FINISHED'])