file transfer item #1
This commit is contained in:
parent
ff8aeef8af
commit
52bfacb978
2 changed files with 51 additions and 3 deletions
|
@ -154,3 +154,39 @@ class StatusCircle(QtGui.QWidget):
|
|||
paint.setPen(color)
|
||||
paint.drawEllipse(center, rad_x + 3, rad_y + 3)
|
||||
paint.end()
|
||||
|
||||
|
||||
class FileTransferItem(QtGui.QListWidget):
|
||||
def __init__(self, file_name, time, user, friend_number, file_number, parent=None):
|
||||
QtGui.QListWidget.__init__(self, parent)
|
||||
self.name = QtGui.QLabel(self)
|
||||
self.name.setGeometry(QtCore.QRect(0, 2, 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.setObjectName("name")
|
||||
self.name.setText(file_name)
|
||||
|
||||
self.time = QtGui.QLabel(self)
|
||||
self.time.setGeometry(QtCore.QRect(500, 0, 50, 25))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
font.setBold(False)
|
||||
self.time.setFont(font)
|
||||
self.time.setObjectName("time")
|
||||
self.time.setText(time)
|
||||
|
||||
self.cancel = QtGui.QPushButton(self)
|
||||
self.cancel.setGeometry(QtCore.QRect(100, 2, 200, 20))
|
||||
self.cancel.setText("Cancel")
|
||||
self.cancel.clicked.connect(lambda: self.click(friend_number, file_number))
|
||||
|
||||
def click(self, friend_number, file_number):
|
||||
from profile import Profile
|
||||
profile = Profile.get_instance()
|
||||
profile.cancel_transfer(friend_number, file_number)
|
||||
self.name.setText('Cancelled')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from list_items import MessageItem, ContactItem
|
||||
from list_items import MessageItem, ContactItem, FileTransferItem
|
||||
from PySide import QtCore, QtGui
|
||||
from tox import Tox
|
||||
import os
|
||||
|
@ -557,7 +557,7 @@ class Profile(Contact, Singleton):
|
|||
self._history.export(directory)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Factories for friend and message items
|
||||
# Factories for friend, message and file transfer items
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
def create_friend_item(self):
|
||||
|
@ -580,6 +580,14 @@ class Profile(Contact, Singleton):
|
|||
self._messages.setItemWidget(elem, item)
|
||||
self._messages.repaint()
|
||||
|
||||
def create_file_transfer_item(self, file_name, friend_number, file_number):
|
||||
item = FileTransferItem(file_name, curr_time(), '', friend_number, file_number)
|
||||
elem = QtGui.QListWidgetItem(self._messages)
|
||||
elem.setSizeHint(QtCore.QSize(500, 100))
|
||||
self._messages.addItem(elem)
|
||||
self._messages.setItemWidget(elem, item)
|
||||
self._messages.repaint()
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Work with friends (remove, set alias, get public key)
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
@ -713,9 +721,13 @@ class Profile(Contact, Singleton):
|
|||
self._file_transfers[(friend_number, file_number)] = rt
|
||||
self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['RESUME'])
|
||||
else:
|
||||
self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['CANCEL'])
|
||||
self.create_file_transfer_item(file_name + ' ' + str(size), friend_number, file_number)
|
||||
#self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['CANCEL'])
|
||||
# TODO: show info about incoming transfer
|
||||
|
||||
def cancel_transfer(self, friend_number, file_number):
|
||||
self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['CANCEL'])
|
||||
|
||||
def incoming_avatar(self, friend_number, file_number, size):
|
||||
"""
|
||||
Friend changed avatar
|
||||
|
|
Loading…
Reference in a new issue