file transfers - spacing, ui fixes. menu fixes
This commit is contained in:
parent
fd9bfa52f3
commit
e375dca9cc
@ -18,14 +18,15 @@ TOX_FILE_TRANSFER_STATE = {
|
||||
'CANCELLED': 2,
|
||||
'FINISHED': 3,
|
||||
'PAUSED_BY_FRIEND': 4,
|
||||
'INCOMING_NOT_STARTED': 5
|
||||
'INCOMING_NOT_STARTED': 5,
|
||||
'OUTGOING_NOT_STARTED': 6
|
||||
}
|
||||
|
||||
ACTIVE_FILE_TRANSFERS = (0, 1, 4, 5)
|
||||
ACTIVE_FILE_TRANSFERS = (0, 1, 4, 5, 6)
|
||||
|
||||
PAUSED_FILE_TRANSFERS = (1, 4, 5)
|
||||
PAUSED_FILE_TRANSFERS = (1, 4, 5, 6)
|
||||
|
||||
DO_NOT_SHOW_ACCEPT_BUTTON = (2, 3, 4)
|
||||
DO_NOT_SHOW_ACCEPT_BUTTON = (2, 3, 4, 6)
|
||||
|
||||
SHOW_PROGRESS_BAR = (0, 1, 4)
|
||||
|
||||
@ -51,7 +52,7 @@ class FileTransfer(QtCore.QObject):
|
||||
self._friend_number = friend_number
|
||||
self.state = TOX_FILE_TRANSFER_STATE['RUNNING']
|
||||
self._file_number = file_number
|
||||
self._creation_time = time()
|
||||
self._creation_time = None
|
||||
self._size = float(size)
|
||||
self._done = 0
|
||||
self._state_changed = StateSignal()
|
||||
@ -113,7 +114,7 @@ class SendTransfer(FileTransfer):
|
||||
else:
|
||||
size = 0
|
||||
super(SendTransfer, self).__init__(path, tox, friend_number, size)
|
||||
self.state = TOX_FILE_TRANSFER_STATE['PAUSED_BY_FRIEND']
|
||||
self.state = TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']
|
||||
self._file_number = tox.file_send(friend_number, kind, size, file_id,
|
||||
basename(path).encode('utf-8') if path else '')
|
||||
|
||||
@ -157,7 +158,7 @@ class SendFromBuffer(FileTransfer):
|
||||
|
||||
def __init__(self, tox, friend_number, data, file_name):
|
||||
super(SendFromBuffer, self).__init__(None, tox, friend_number, len(data))
|
||||
self.state = TOX_FILE_TRANSFER_STATE['PAUSED_BY_FRIEND']
|
||||
self.state = TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']
|
||||
self._data = data
|
||||
self._file_number = tox.file_send(friend_number, TOX_FILE_KIND['DATA'], len(data), None, file_name)
|
||||
|
||||
@ -169,10 +170,10 @@ class SendFromBuffer(FileTransfer):
|
||||
data = self._data[position:position + size]
|
||||
self._tox.file_send_chunk(self._friend_number, self._file_number, position, data)
|
||||
self._done += size
|
||||
self._state_changed.signal.emit(self.state, self._done / self._size)
|
||||
self.signal()
|
||||
else:
|
||||
self.state = TOX_FILE_TRANSFER_STATE['FINISHED']
|
||||
self._state_changed.signal.emit(self.state, 1)
|
||||
self.signal()
|
||||
|
||||
|
||||
class SendFromFileBuffer(SendTransfer):
|
||||
|
@ -110,7 +110,7 @@ class MessageItem(QtGui.QWidget):
|
||||
self.name.setText(user)
|
||||
|
||||
self.time = QtGui.QLabel(self)
|
||||
self.time.setGeometry(QtCore.QRect(parent.width() - 50, 0, 50, 25))
|
||||
self.time.setGeometry(QtCore.QRect(parent.width() - 50, 0, 50, 20))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
@ -277,9 +277,6 @@ class FileTransferItem(QtGui.QListWidget):
|
||||
elif state == TOX_FILE_TRANSFER_STATE['PAUSED_BY_USER']: # setup for continue
|
||||
self.accept_or_pause.setVisible(True)
|
||||
self.button_update('resume')
|
||||
elif state not in ACTIVE_FILE_TRANSFERS:
|
||||
self.accept_or_pause.setVisible(False)
|
||||
self.cancel.setVisible(False)
|
||||
else: # pause
|
||||
self.accept_or_pause.setVisible(True)
|
||||
self.button_update('pause')
|
||||
@ -372,6 +369,10 @@ class FileTransferItem(QtGui.QListWidget):
|
||||
self.button_update('resume') # setup button continue
|
||||
self.setStyleSheet('QListWidget { border: 1px solid green; }')
|
||||
self.state = state
|
||||
elif state == TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']:
|
||||
self.setStyleSheet('QListWidget { border: 1px solid #FF8000; }')
|
||||
self.accept_or_pause.setVisible(False)
|
||||
self.pb.setVisible(False)
|
||||
elif not self.paused: # active
|
||||
self.accept_or_pause.setVisible(True) # setup to pause
|
||||
self.button_update('pause')
|
||||
|
@ -242,6 +242,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.messages = QtGui.QListWidget(widget)
|
||||
self.messages.setGeometry(0, 0, 620, 310)
|
||||
self.messages.setObjectName("messages")
|
||||
self.messages.setSpacing(1)
|
||||
self.messages.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
|
||||
self.messages.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.messages.setFocusPolicy(QtCore.Qt.NoFocus)
|
||||
@ -398,35 +399,39 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def send_file(self):
|
||||
self.menu.hide()
|
||||
choose_file = QtGui.QApplication.translate("MainWindow", 'Choose file', None, QtGui.QApplication.UnicodeUTF8)
|
||||
choose = QtGui.QApplication.translate("MainWindow", choose_file, None, QtGui.QApplication.UnicodeUTF8)
|
||||
name = QtGui.QFileDialog.getOpenFileName(self, choose)
|
||||
if name[0]:
|
||||
self.profile.send_file(name[0])
|
||||
if self.profile.active_friend + 1:
|
||||
choose = QtGui.QApplication.translate("MainWindow", 'Choose file', None, QtGui.QApplication.UnicodeUTF8)
|
||||
name = QtGui.QFileDialog.getOpenFileName(self, choose)
|
||||
if name[0]:
|
||||
self.profile.send_file(name[0])
|
||||
|
||||
def send_screenshot(self, hide=False):
|
||||
self.menu.hide()
|
||||
self.sw = ScreenShotWindow(self)
|
||||
self.sw.show()
|
||||
if hide:
|
||||
self.hide()
|
||||
if self.profile.active_friend + 1:
|
||||
self.sw = ScreenShotWindow(self)
|
||||
self.sw.show()
|
||||
if hide:
|
||||
self.hide()
|
||||
|
||||
def send_smiley(self):
|
||||
self.menu.hide()
|
||||
self.smiley = SmileyWindow(self)
|
||||
self.smiley.setGeometry(QtCore.QRect(self.x() if Settings.get_instance()['mirror_mode'] else 270 + self.x(),
|
||||
self.y() + self.height() - 200,
|
||||
self.smiley.width(),
|
||||
self.smiley.height()))
|
||||
self.smiley.show()
|
||||
if self.profile.active_friend + 1:
|
||||
self.smiley = SmileyWindow(self)
|
||||
self.smiley.setGeometry(QtCore.QRect(self.x() if Settings.get_instance()['mirror_mode'] else 270 + self.x(),
|
||||
self.y() + self.height() - 200,
|
||||
self.smiley.width(),
|
||||
self.smiley.height()))
|
||||
self.smiley.show()
|
||||
|
||||
def send_sticker(self):
|
||||
self.sticker = StickerWindow(self)
|
||||
self.sticker.setGeometry(QtCore.QRect(self.x() if Settings.get_instance()['mirror_mode'] else 270 + self.x(),
|
||||
self.y() + self.height() - 200,
|
||||
self.sticker.width(),
|
||||
self.sticker.height()))
|
||||
self.sticker.show()
|
||||
self.menu.hide()
|
||||
if self.profile.active_friend + 1:
|
||||
self.sticker = StickerWindow(self)
|
||||
self.sticker.setGeometry(QtCore.QRect(self.x() if Settings.get_instance()['mirror_mode'] else 270 + self.x(),
|
||||
self.y() + self.height() - 200,
|
||||
self.sticker.width(),
|
||||
self.sticker.height()))
|
||||
self.sticker.show()
|
||||
|
||||
def active_call(self):
|
||||
self.update_call_state('finish_call')
|
||||
|
@ -904,7 +904,7 @@ class Profile(contact.Contact, Singleton):
|
||||
self._file_transfers[(friend.number, st.get_file_number())] = st
|
||||
tm = TransferMessage(MESSAGE_OWNER['ME'],
|
||||
time.time(),
|
||||
TOX_FILE_TRANSFER_STATE['PAUSED_BY_FRIEND'], # OUTGOING NOT STARTED
|
||||
TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED'],
|
||||
len(data),
|
||||
file_name,
|
||||
friend.number,
|
||||
@ -934,7 +934,7 @@ class Profile(contact.Contact, Singleton):
|
||||
self._file_transfers[(friend_number, st.get_file_number())] = st
|
||||
tm = TransferMessage(MESSAGE_OWNER['ME'],
|
||||
time.time(),
|
||||
TOX_FILE_TRANSFER_STATE['PAUSED_BY_FRIEND'], # OUTGOING NOT STARTED
|
||||
TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED'],
|
||||
os.path.getsize(path),
|
||||
os.path.basename(path),
|
||||
friend_number,
|
||||
|
Loading…
Reference in New Issue
Block a user