ui: statuses
@ -64,8 +64,8 @@ class Contact(object):
|
|||||||
return self._status
|
return self._status
|
||||||
|
|
||||||
def set_status(self, value):
|
def set_status(self, value):
|
||||||
self._widget.connection_status.data = self._status = value
|
self._status = value
|
||||||
self._widget.connection_status.repaint()
|
self._widget.connection_status.update(value)
|
||||||
|
|
||||||
status = property(get_status, set_status)
|
status = property(get_status, set_status)
|
||||||
|
|
||||||
|
@ -188,12 +188,12 @@ class Friend(contact.Contact):
|
|||||||
return self._new_messages
|
return self._new_messages
|
||||||
|
|
||||||
def inc_messages(self):
|
def inc_messages(self):
|
||||||
self._widget.connection_status.messages = self._new_messages + 1
|
self._new_messages += 1
|
||||||
self._widget.connection_status.repaint()
|
self._widget.connection_status.update(self.status, True)
|
||||||
|
|
||||||
def reset_messages(self):
|
def reset_messages(self):
|
||||||
self._widget.connection_status.messages = self._new_messages = 0
|
self._new_messages = 0
|
||||||
self._widget.connection_status.repaint()
|
self._widget.connection_status.update(self.status, False)
|
||||||
|
|
||||||
messages = property(get_messages)
|
messages = property(get_messages)
|
||||||
|
|
||||||
|
BIN
src/images/busy.png
Normal file
After Width: | Height: | Size: 329 B |
BIN
src/images/busy_notification.png
Normal file
After Width: | Height: | Size: 609 B |
BIN
src/images/idle.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
src/images/idle_notification.png
Normal file
After Width: | Height: | Size: 405 B |
BIN
src/images/offline.png
Normal file
After Width: | Height: | Size: 159 B |
BIN
src/images/offline_notification.png
Normal file
After Width: | Height: | Size: 445 B |
BIN
src/images/online.png
Normal file
After Width: | Height: | Size: 201 B |
BIN
src/images/online_notification.png
Normal file
After Width: | Height: | Size: 351 B |
@ -140,6 +140,8 @@ class MessageItem(QtGui.QWidget):
|
|||||||
def mark_as_sent(self):
|
def mark_as_sent(self):
|
||||||
if hasattr(self, 't'):
|
if hasattr(self, 't'):
|
||||||
self.time.setText(self.t)
|
self.time.setText(self.t)
|
||||||
|
self.time.repaint()
|
||||||
|
del self.t
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -170,7 +172,7 @@ class ContactItem(QtGui.QWidget):
|
|||||||
self.status_message.setFont(font)
|
self.status_message.setFont(font)
|
||||||
self.status_message.setObjectName("status_message")
|
self.status_message.setObjectName("status_message")
|
||||||
self.connection_status = StatusCircle(self)
|
self.connection_status = StatusCircle(self)
|
||||||
self.connection_status.setGeometry(QtCore.QRect(220, 5, 32, 32))
|
self.connection_status.setGeometry(QtCore.QRect(243, 5, 32, 32))
|
||||||
self.connection_status.setObjectName("connection_status")
|
self.connection_status.setObjectName("connection_status")
|
||||||
|
|
||||||
|
|
||||||
@ -178,40 +180,30 @@ class StatusCircle(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Connection status
|
Connection status
|
||||||
"""
|
"""
|
||||||
# TODO: rewrite
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QtGui.QWidget.__init__(self, parent)
|
QtGui.QWidget.__init__(self, parent)
|
||||||
self.setGeometry(0, 0, 32, 32)
|
self.setGeometry(0, 0, 32, 32)
|
||||||
self.data = None
|
self.label = QtGui.QLabel(self)
|
||||||
self.messages = False
|
self.label.setGeometry(QtCore.QRect(0, 0, 32, 32))
|
||||||
|
self.unread = False
|
||||||
|
|
||||||
def paintEvent(self, event):
|
def update(self, status, unread_messages=None):
|
||||||
paint = QtGui.QPainter()
|
if unread_messages is None:
|
||||||
paint.begin(self)
|
unread_messages = self.unread
|
||||||
paint.setRenderHint(QtGui.QPainter.Antialiasing)
|
|
||||||
k = 16
|
|
||||||
rad_x = rad_y = 5
|
|
||||||
if self.data is None:
|
|
||||||
color = QtCore.Qt.transparent
|
|
||||||
else:
|
else:
|
||||||
if self.data == TOX_USER_STATUS['NONE']:
|
self.unread = unread_messages
|
||||||
color = QtGui.QColor(50, 205, 50)
|
if status == TOX_USER_STATUS['NONE']:
|
||||||
elif self.data == TOX_USER_STATUS['AWAY']:
|
name = 'online'
|
||||||
color = QtGui.QColor(255, 200, 50)
|
elif status == TOX_USER_STATUS['AWAY']:
|
||||||
else: # self.data == TOX_USER_STATUS['BUSY']:
|
name = 'idle'
|
||||||
color = QtGui.QColor(255, 50, 0)
|
elif status == TOX_USER_STATUS['BUSY']:
|
||||||
|
name = 'busy'
|
||||||
paint.setPen(color)
|
else:
|
||||||
center = QtCore.QPoint(k, k)
|
name = 'offline'
|
||||||
paint.setBrush(color)
|
if unread_messages:
|
||||||
paint.drawEllipse(center, rad_x, rad_y)
|
name += '_notification'
|
||||||
if self.messages:
|
pixmap = QtGui.QPixmap(curr_directory() + '/images/{}.png'.format(name))
|
||||||
if color == QtCore.Qt.transparent:
|
self.label.setPixmap(pixmap)
|
||||||
color = QtCore.Qt.darkRed
|
|
||||||
paint.setBrush(QtCore.Qt.transparent)
|
|
||||||
paint.setPen(color)
|
|
||||||
paint.drawEllipse(center, rad_x + 3, rad_y + 3)
|
|
||||||
paint.end()
|
|
||||||
|
|
||||||
|
|
||||||
class FileTransferItem(QtGui.QListWidget):
|
class FileTransferItem(QtGui.QListWidget):
|
||||||
@ -376,6 +368,7 @@ class UnsentFileItem(FileTransferItem):
|
|||||||
super(UnsentFileItem, self).__init__(file_name, size, time, user, -1, -1,
|
super(UnsentFileItem, self).__init__(file_name, size, time, user, -1, -1,
|
||||||
FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND'], width, parent)
|
FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND'], width, parent)
|
||||||
self._time = time
|
self._time = time
|
||||||
|
self.pb.setVisible(False)
|
||||||
|
|
||||||
def cancel_transfer(self, *args):
|
def cancel_transfer(self, *args):
|
||||||
pr = profile.Profile.get_instance()
|
pr = profile.Profile.get_instance()
|
||||||
|
@ -183,10 +183,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
Form.status_message.setFont(font)
|
Form.status_message.setFont(font)
|
||||||
Form.status_message.setObjectName("status_message")
|
Form.status_message.setObjectName("status_message")
|
||||||
self.connection_status = Form.connection_status = StatusCircle(Form)
|
self.connection_status = Form.connection_status = StatusCircle(Form)
|
||||||
Form.connection_status.setGeometry(QtCore.QRect(230, 29, 64, 64))
|
Form.connection_status.setGeometry(QtCore.QRect(245, 35, 32, 32))
|
||||||
Form.connection_status.setMinimumSize(QtCore.QSize(32, 32))
|
|
||||||
Form.connection_status.setMaximumSize(QtCore.QSize(32, 32))
|
|
||||||
Form.connection_status.setBaseSize(QtCore.QSize(32, 32))
|
|
||||||
self.avatar_label.mouseReleaseEvent = self.profile_settings
|
self.avatar_label.mouseReleaseEvent = self.profile_settings
|
||||||
self.status_message.mouseReleaseEvent = self.profile_settings
|
self.status_message.mouseReleaseEvent = self.profile_settings
|
||||||
self.name.mouseReleaseEvent = self.profile_settings
|
self.name.mouseReleaseEvent = self.profile_settings
|
||||||
|