From 57b4e2af67c84e11b4c851e14f83bf237976ae81 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 11 May 2016 12:01:29 +0300 Subject: [PATCH] sending pause control fix --- src/list_items.py | 16 +++++++++++++--- src/profile.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/list_items.py b/src/list_items.py index 1dde736..bd4df31 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -215,6 +215,7 @@ class FileTransferItem(QtGui.QListWidget): self.file_name.setText(file_data) self.saved_name = file_name self.setFocusPolicy(QtCore.Qt.NoFocus) + self.paused = False def cancel_transfer(self, friend_number, file_number): pr = profile.Profile.get_instance() @@ -232,10 +233,15 @@ class FileTransferItem(QtGui.QListWidget): pr.accept_transfer(self, directory + '/' + self.saved_name, friend_number, file_number, size) self.button_update('pause') elif self.state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER']: # resume + self.paused = False profile.Profile.get_instance().resume_transfer(friend_number, file_number) + self.button_update('pause') + self.state = FILE_TRANSFER_MESSAGE_STATUS['OUTGOING'] else: # pause - profile.Profile.get_instance().pause_transfer(friend_number, file_number) + self.paused = True self.state = FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER'] + profile.Profile.get_instance().pause_transfer(friend_number, file_number) + self.button_update('resume') self.accept_or_pause.clearFocus() def button_update(self, path): @@ -259,22 +265,26 @@ class FileTransferItem(QtGui.QListWidget): self.cancel.setVisible(False) self.accept_or_pause.setVisible(False) self.pb.setVisible(False) + self.state = state elif state == FILE_TRANSFER_MESSAGE_STATUS['FINISHED']: self.accept_or_pause.setVisible(False) self.pb.setVisible(False) self.cancel.setVisible(False) self.setStyleSheet('QListWidget { border: 1px solid green; }') + self.state = state elif state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND']: self.accept_or_pause.setVisible(False) self.setStyleSheet('QListWidget { border: 1px solid #FF8000; }') + self.state = state elif state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER']: self.button_update('resume') # setup button continue self.setStyleSheet('QListWidget { border: 1px solid green; }') - else: # active + self.state = state + elif not self.paused: # active self.accept_or_pause.setVisible(True) # setup to pause self.button_update('pause') self.setStyleSheet('QListWidget { border: 1px solid green; }') - self.state = state + self.state = state class InlineImageItem(QtGui.QWidget): diff --git a/src/profile.py b/src/profile.py index d7b4999..48e70e1 100644 --- a/src/profile.py +++ b/src/profile.py @@ -974,7 +974,7 @@ class Profile(Contact, Singleton): if by_friend: tr.state = TOX_FILE_TRANSFER_STATE['RUNNING'] tr.signal() - else: + else: # send seek control? tr.send_control(TOX_FILE_CONTROL['RESUME']) def accept_transfer(self, item, path, friend_number, file_number, size, inline=False):