created file transfer item for autoaccept
This commit is contained in:
parent
9d405b6c12
commit
046a091ed8
@ -160,7 +160,7 @@ class StatusCircle(QtGui.QWidget):
|
|||||||
|
|
||||||
|
|
||||||
class FileTransferItem(QtGui.QListWidget):
|
class FileTransferItem(QtGui.QListWidget):
|
||||||
def __init__(self, file_name, size, time, user, friend_number, file_number, is_incoming_transfer, parent=None):
|
def __init__(self, file_name, size, time, user, friend_number, file_number, show_accept, parent=None):
|
||||||
QtGui.QListWidget.__init__(self, parent)
|
QtGui.QListWidget.__init__(self, parent)
|
||||||
self.resize(QtCore.QSize(600, 50))
|
self.resize(QtCore.QSize(600, 50))
|
||||||
self.setStyleSheet('QListWidget { background-color: green; }')
|
self.setStyleSheet('QListWidget { background-color: green; }')
|
||||||
@ -201,7 +201,7 @@ class FileTransferItem(QtGui.QListWidget):
|
|||||||
self.accept.setIcon(icon)
|
self.accept.setIcon(icon)
|
||||||
self.accept.setIconSize(QtCore.QSize(50, 50))
|
self.accept.setIconSize(QtCore.QSize(50, 50))
|
||||||
self.accept.clicked.connect(lambda: self.accept_transfer(friend_number, file_number, size))
|
self.accept.clicked.connect(lambda: self.accept_transfer(friend_number, file_number, size))
|
||||||
self.accept.setVisible(is_incoming_transfer)
|
self.accept.setVisible(show_accept)
|
||||||
|
|
||||||
self.pb = QtGui.QProgressBar(self)
|
self.pb = QtGui.QProgressBar(self)
|
||||||
self.pb.setGeometry(QtCore.QRect(100, 15, 100, 20))
|
self.pb.setGeometry(QtCore.QRect(100, 15, 100, 20))
|
||||||
|
@ -493,7 +493,7 @@ class Profile(Contact, Singleton):
|
|||||||
self._messages.scrollToBottom()
|
self._messages.scrollToBottom()
|
||||||
self._friends[self._active_friend].append_message((message.decode('utf-8'),
|
self._friends[self._active_friend].append_message((message.decode('utf-8'),
|
||||||
MESSAGE_OWNER['FRIEND'],
|
MESSAGE_OWNER['FRIEND'],
|
||||||
time.time(),
|
int(time.time()),
|
||||||
message_type))
|
message_type))
|
||||||
else:
|
else:
|
||||||
friend = filter(lambda x: x.number == friend_num, self._friends)[0]
|
friend = filter(lambda x: x.number == friend_num, self._friends)[0]
|
||||||
@ -580,9 +580,9 @@ class Profile(Contact, Singleton):
|
|||||||
self._messages.setItemWidget(elem, item)
|
self._messages.setItemWidget(elem, item)
|
||||||
self._messages.repaint()
|
self._messages.repaint()
|
||||||
|
|
||||||
def create_file_transfer_item(self, file_name, size, friend_number, file_number, is_incoming_transfer):
|
def create_file_transfer_item(self, file_name, size, friend_number, file_number, show_accept):
|
||||||
friend = self.get_friend_by_number(friend_number)
|
friend = self.get_friend_by_number(friend_number)
|
||||||
item = FileTransferItem(file_name, size, curr_time(), friend.name, friend_number, file_number, is_incoming_transfer)
|
item = FileTransferItem(file_name, size, curr_time(), friend.name, friend_number, file_number, show_accept)
|
||||||
elem = QtGui.QListWidgetItem(self._messages)
|
elem = QtGui.QListWidgetItem(self._messages)
|
||||||
elem.setSizeHint(QtCore.QSize(600, 50))
|
elem.setSizeHint(QtCore.QSize(600, 50))
|
||||||
self._messages.addItem(elem)
|
self._messages.addItem(elem)
|
||||||
@ -720,8 +720,10 @@ class Profile(Contact, Singleton):
|
|||||||
if settings['allow_auto_accept'] and friend.tox_id in settings['auto_accept_from_friends']:
|
if settings['allow_auto_accept'] and friend.tox_id in settings['auto_accept_from_friends']:
|
||||||
path = settings['auto_accept_path'] or curr_directory()
|
path = settings['auto_accept_path'] or curr_directory()
|
||||||
self.accept_transfer(path + '/' + file_name.decode('utf-8'), friend_number, file_number)
|
self.accept_transfer(path + '/' + file_name.decode('utf-8'), friend_number, file_number)
|
||||||
|
item = self.create_file_transfer_item(file_name.decode('utf-8'), size, friend_number, file_number, False)
|
||||||
else:
|
else:
|
||||||
self.create_file_transfer_item(file_name.decode('utf-8'), size, friend_number, file_number, True)
|
item = self.create_file_transfer_item(file_name.decode('utf-8'), size, friend_number, file_number, True)
|
||||||
|
friend.append_file_transfer((item, MESSAGE_OWNER['FRIEND'], int(time.time()), 2))
|
||||||
|
|
||||||
def cancel_transfer(self, friend_number, file_number):
|
def cancel_transfer(self, friend_number, file_number):
|
||||||
if (friend_number, file_number) in self._file_transfers:
|
if (friend_number, file_number) in self._file_transfers:
|
||||||
|
Loading…
Reference in New Issue
Block a user