sending pause control fix

This commit is contained in:
ingvar1995 2016-05-11 12:01:29 +03:00
parent 6192688e0c
commit 57b4e2af67
2 changed files with 14 additions and 4 deletions

View file

@ -215,6 +215,7 @@ class FileTransferItem(QtGui.QListWidget):
self.file_name.setText(file_data) self.file_name.setText(file_data)
self.saved_name = file_name self.saved_name = file_name
self.setFocusPolicy(QtCore.Qt.NoFocus) self.setFocusPolicy(QtCore.Qt.NoFocus)
self.paused = False
def cancel_transfer(self, friend_number, file_number): def cancel_transfer(self, friend_number, file_number):
pr = profile.Profile.get_instance() 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) pr.accept_transfer(self, directory + '/' + self.saved_name, friend_number, file_number, size)
self.button_update('pause') self.button_update('pause')
elif self.state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER']: # resume elif self.state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER']: # resume
self.paused = False
profile.Profile.get_instance().resume_transfer(friend_number, file_number) profile.Profile.get_instance().resume_transfer(friend_number, file_number)
self.button_update('pause')
self.state = FILE_TRANSFER_MESSAGE_STATUS['OUTGOING']
else: # pause else: # pause
profile.Profile.get_instance().pause_transfer(friend_number, file_number) self.paused = True
self.state = FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER'] 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() self.accept_or_pause.clearFocus()
def button_update(self, path): def button_update(self, path):
@ -259,18 +265,22 @@ class FileTransferItem(QtGui.QListWidget):
self.cancel.setVisible(False) self.cancel.setVisible(False)
self.accept_or_pause.setVisible(False) self.accept_or_pause.setVisible(False)
self.pb.setVisible(False) self.pb.setVisible(False)
self.state = state
elif state == FILE_TRANSFER_MESSAGE_STATUS['FINISHED']: elif state == FILE_TRANSFER_MESSAGE_STATUS['FINISHED']:
self.accept_or_pause.setVisible(False) self.accept_or_pause.setVisible(False)
self.pb.setVisible(False) self.pb.setVisible(False)
self.cancel.setVisible(False) self.cancel.setVisible(False)
self.setStyleSheet('QListWidget { border: 1px solid green; }') self.setStyleSheet('QListWidget { border: 1px solid green; }')
self.state = state
elif state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND']: elif state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND']:
self.accept_or_pause.setVisible(False) self.accept_or_pause.setVisible(False)
self.setStyleSheet('QListWidget { border: 1px solid #FF8000; }') self.setStyleSheet('QListWidget { border: 1px solid #FF8000; }')
self.state = state
elif state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER']: elif state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER']:
self.button_update('resume') # setup button continue self.button_update('resume') # setup button continue
self.setStyleSheet('QListWidget { border: 1px solid green; }') 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.accept_or_pause.setVisible(True) # setup to pause
self.button_update('pause') self.button_update('pause')
self.setStyleSheet('QListWidget { border: 1px solid green; }') self.setStyleSheet('QListWidget { border: 1px solid green; }')

View file

@ -974,7 +974,7 @@ class Profile(Contact, Singleton):
if by_friend: if by_friend:
tr.state = TOX_FILE_TRANSFER_STATE['RUNNING'] tr.state = TOX_FILE_TRANSFER_STATE['RUNNING']
tr.signal() tr.signal()
else: else: # send seek control?
tr.send_control(TOX_FILE_CONTROL['RESUME']) tr.send_control(TOX_FILE_CONTROL['RESUME'])
def accept_transfer(self, item, path, friend_number, file_number, size, inline=False): def accept_transfer(self, item, path, friend_number, file_number, size, inline=False):