From 2903ed1877ef032af2f1b64ce18bb187bb2f0533 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Mon, 9 May 2016 22:37:11 +0300 Subject: [PATCH] file transfer item fixes --- src/list_items.py | 38 +++++++++++++++++++++----------------- src/menu.py | 25 ++++++++++++++----------- src/profile.py | 3 ++- src/styles/style.qss | 5 +++++ 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/list_items.py b/src/list_items.py index 486709f..1478fd0 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -139,16 +139,18 @@ class FileTransferItem(QtGui.QListWidget): def __init__(self, file_name, size, time, user, friend_number, file_number, state, width, parent=None): QtGui.QListWidget.__init__(self, parent) - self.resize(QtCore.QSize(width, 50)) - if state != FILE_TRANSFER_MESSAGE_STATUS['CANCELLED']: - self.setStyleSheet('QWidget { background-color: green; }') + self.resize(QtCore.QSize(width, 34)) + if state == FILE_TRANSFER_MESSAGE_STATUS['CANCELLED']: + self.setStyleSheet('QListWidget { border: 1px solid #B40404; }') + elif state in (FILE_TRANSFER_MESSAGE_STATUS['INCOMING_NOT_STARTED'], FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND']): + self.setStyleSheet('QListWidget { border: 1px solid #FF8000; }') else: - self.setStyleSheet('QWidget { background-color: #B40404; }') + self.setStyleSheet('QListWidget { border: 1px solid green; }') self.state = state self.name = DataLabel(self) - self.name.setGeometry(QtCore.QRect(1, 15, 95, 20)) + self.name.setGeometry(QtCore.QRect(7, 5, 95, 20)) self.name.setTextFormat(QtCore.Qt.PlainText) font = QtGui.QFont() font.setFamily("Times New Roman") @@ -156,28 +158,26 @@ class FileTransferItem(QtGui.QListWidget): font.setBold(True) self.name.setFont(font) self.name.setText(user) - self.name.setStyleSheet('QLabel { color: black; }') self.time = QtGui.QLabel(self) - self.time.setGeometry(QtCore.QRect(570, 2, 50, 46)) + self.time.setGeometry(QtCore.QRect(width - 50, 7, 50, 20)) font.setPointSize(10) font.setBold(False) self.time.setFont(font) self.time.setText(convert_time(time)) - self.time.setStyleSheet('QLabel { color: black; }') self.cancel = QtGui.QPushButton(self) - self.cancel.setGeometry(QtCore.QRect(500, 2, 46, 46)) + self.cancel.setGeometry(QtCore.QRect(width - 120, 2, 30, 30)) pixmap = QtGui.QPixmap(curr_directory() + '/images/decline.png') icon = QtGui.QIcon(pixmap) self.cancel.setIcon(icon) self.cancel.setIconSize(QtCore.QSize(30, 30)) self.cancel.setVisible(state > 1) self.cancel.clicked.connect(lambda: self.cancel_transfer(friend_number, file_number)) - self.cancel.setStyleSheet('QPushButton:hover { border: 1px solid #3A3939; }') + self.cancel.setStyleSheet('QPushButton:hover { border: 1px solid #3A3939; background-color: none;}') self.accept_or_pause = QtGui.QPushButton(self) - self.accept_or_pause.setGeometry(QtCore.QRect(450, 2, 46, 46)) + self.accept_or_pause.setGeometry(QtCore.QRect(width - 170, 2, 30, 30)) if state == FILE_TRANSFER_MESSAGE_STATUS['INCOMING_NOT_STARTED']: self.accept_or_pause.setVisible(True) self.button_update('accept') @@ -191,17 +191,17 @@ class FileTransferItem(QtGui.QListWidget): self.button_update('pause') self.accept_or_pause.clicked.connect(lambda: self.accept_or_pause_transfer(friend_number, file_number, size)) - self.accept_or_pause.setStyleSheet('QPushButton:hover { border: 1px solid #3A3939; }') + self.accept_or_pause.setStyleSheet('QPushButton:hover { border: 1px solid #3A3939; background-color: none}') self.pb = QtGui.QProgressBar(self) - self.pb.setGeometry(QtCore.QRect(100, 15, 100, 20)) + self.pb.setGeometry(QtCore.QRect(100, 7, 100, 20)) self.pb.setValue(0) self.pb.setStyleSheet('QProgressBar { background-color: #302F2F; }') if state < 2: self.pb.setVisible(False) self.file_name = DataLabel(self) - self.file_name.setGeometry(QtCore.QRect(210, 2, width - 400, 46)) + self.file_name.setGeometry(QtCore.QRect(210, 7, width - 400, 20)) font.setPointSize(12) self.file_name.setFont(font) file_size = size / 1024 @@ -213,13 +213,13 @@ class FileTransferItem(QtGui.QListWidget): file_size = '{}KB'.format(file_size) file_data = u'{} {}'.format(file_size, file_name) self.file_name.setText(file_data) - self.file_name.setStyleSheet('QLabel { color: black; }') self.saved_name = file_name + self.setFocusPolicy(QtCore.Qt.NoFocus) def cancel_transfer(self, friend_number, file_number): pr = profile.Profile.get_instance() pr.cancel_transfer(friend_number, file_number) - self.setStyleSheet('QListWidget { background-color: #B40404; }') + self.setStyleSheet('QListWidget { border: 1px solid #B40404; }') self.cancel.setVisible(False) self.accept_or_pause.setVisible(False) self.pb.setVisible(False) @@ -255,7 +255,7 @@ class FileTransferItem(QtGui.QListWidget): state = self.convert(state) if self.state != state: if state == FILE_TRANSFER_MESSAGE_STATUS['CANCELLED']: - self.setStyleSheet('QListWidget { background-color: #B40404; }') + self.setStyleSheet('QListWidget { border: 1px solid #B40404; }') self.cancel.setVisible(False) self.accept_or_pause.setVisible(False) self.pb.setVisible(False) @@ -263,13 +263,17 @@ class FileTransferItem(QtGui.QListWidget): self.accept_or_pause.setVisible(False) self.pb.setVisible(False) self.cancel.setVisible(False) + self.setStyleSheet('QListWidget { border: 1px solid green; }') elif state == FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND']: self.accept_or_pause.setVisible(False) + self.setStyleSheet('QListWidget { border: 1px solid #FF8000; }') 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.accept_or_pause.setVisible(True) # setup to pause self.button_update('pause') + self.setStyleSheet('QListWidget { border: 1px solid green; }') self.state = state diff --git a/src/menu.py b/src/menu.py index 90005b2..2140bf0 100644 --- a/src/menu.py +++ b/src/menu.py @@ -204,7 +204,7 @@ class NetworkSettings(CenteredWidget): self.label_2 = QtGui.QLabel(self) self.label_2.setGeometry(QtCore.QRect(40, 165, 66, 17)) self.reconnect = QtGui.QPushButton(self) - self.reconnect.setGeometry(QtCore.QRect(40, 230, 200, 30)) + self.reconnect.setGeometry(QtCore.QRect(40, 230, 231, 30)) self.reconnect.clicked.connect(self.restart_core) settings = Settings.get_instance() self.ipv.setChecked(settings['ipv6_enabled']) @@ -235,16 +235,19 @@ class NetworkSettings(CenteredWidget): self.proxyport.setEnabled(bl) def restart_core(self): - settings = Settings.get_instance() - settings['ipv6_enabled'] = self.ipv.isChecked() - settings['udp_enabled'] = self.udp.isChecked() - settings['proxy_type'] = 2 - int(self.http.isChecked()) if self.proxy.isChecked() else 0 - settings['proxy_host'] = str(self.proxyip.text()) - settings['proxy_port'] = int(self.proxyport.text()) - settings.save() - # recreate tox instance - Profile.get_instance().reset(self.reset) - self.close() + try: + settings = Settings.get_instance() + settings['ipv6_enabled'] = self.ipv.isChecked() + settings['udp_enabled'] = self.udp.isChecked() + settings['proxy_type'] = 2 - int(self.http.isChecked()) if self.proxy.isChecked() else 0 + settings['proxy_host'] = str(self.proxyip.text()) + settings['proxy_port'] = int(self.proxyport.text()) + settings.save() + # recreate tox instance + Profile.get_instance().reset(self.reset) + self.close() + except: + pass class PrivacySettings(CenteredWidget): diff --git a/src/profile.py b/src/profile.py index 7a3010c..2283c56 100644 --- a/src/profile.py +++ b/src/profile.py @@ -420,6 +420,7 @@ class Profile(Contact, Singleton): elif message.get_type() == 2: item = self.create_file_transfer_item(message) if message.get_status() >= 2: # active file transfer + # TODO: fix bug with file_number == 65536L ft = self._file_transfers[(message.get_friend_number(), message.get_file_number())] ft.set_state_changed_handler(item.update) ft.signal() @@ -651,7 +652,7 @@ class Profile(Contact, Singleton): data.append(self._messages.width()) item = FileTransferItem(*data) elem = QtGui.QListWidgetItem() - elem.setSizeHint(QtCore.QSize(self._messages.width(), 50)) + elem.setSizeHint(QtCore.QSize(self._messages.width() - 30, 34)) if append: self._messages.addItem(elem) else: diff --git a/src/styles/style.qss b/src/styles/style.qss index aebc609..c6a1ad3 100644 --- a/src/styles/style.qss +++ b/src/styles/style.qss @@ -1268,4 +1268,9 @@ QCheckBox color: #bbb; margin-bottom: 2px; text-align: center; +} + +QListWidget > QLabel +{ + color: #A9A9A9; } \ No newline at end of file