ui: show unread messages in friend's status
This commit is contained in:
parent
7622ecbda7
commit
1f0ce2d7da
@ -65,8 +65,6 @@ def friend_connection_status(tox, friend_num, new_status, user_data):
|
||||
friend = profile.get_friend_by_number(friend_num)
|
||||
if new_status == TOX_CONNECTION['NONE']:
|
||||
invoke_in_main_thread(friend.set_status, None)
|
||||
#elif friend.status is None:
|
||||
# invoke_in_main_thread(friend.set_status, TOX_USER_STATUS['NONE'])
|
||||
|
||||
|
||||
def friend_name(window):
|
||||
|
@ -1,6 +1,5 @@
|
||||
from toxcore_enums_and_consts import *
|
||||
from PySide import QtGui, QtCore
|
||||
# TODO: remove some hardcoded values
|
||||
|
||||
|
||||
class MessageEdit(QtGui.QPlainTextEdit):
|
||||
@ -121,14 +120,11 @@ class StatusCircle(QtGui.QWidget):
|
||||
"""
|
||||
Connection status
|
||||
"""
|
||||
# TODO: rewrite with showing unread messages
|
||||
def __init__(self, parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.setGeometry(0, 0, 32, 32)
|
||||
self.data = None
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
pass
|
||||
self.messages = False
|
||||
|
||||
def paintEvent(self, event):
|
||||
paint = QtGui.QPainter()
|
||||
@ -150,4 +146,10 @@ class StatusCircle(QtGui.QWidget):
|
||||
center = QtCore.QPoint(k, k)
|
||||
paint.setBrush(color)
|
||||
paint.drawEllipse(center, rad_x, rad_y)
|
||||
if self.messages:
|
||||
if color == QtCore.Qt.transparent:
|
||||
color = QtCore.Qt.darkRed
|
||||
paint.setBrush(QtCore.Qt.transparent)
|
||||
paint.setPen(color)
|
||||
paint.drawEllipse(center, rad_x + 5, rad_y + 5)
|
||||
paint.end()
|
||||
|
@ -234,8 +234,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.setup_menu(self)
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
# TODO: process click
|
||||
x, y = event.x(), event.y()
|
||||
pos = self.connection_status.pos()
|
||||
if (pos.x() < x < pos.x() + 32) and (pos.y() < y < pos.y() + 32):
|
||||
self.profile.change_status()
|
||||
else:
|
||||
super(self.__class__, self).mouseReleaseEvent(event)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Functions which called when user click in menu
|
||||
@ -293,8 +297,9 @@ class MainWindow(QtGui.QMainWindow):
|
||||
def friend_click(self, index):
|
||||
print 'row:', index.row()
|
||||
num = index.row()
|
||||
self.profile.set_active(num)
|
||||
if self.profile.set_active(num):
|
||||
self.update_active_friend()
|
||||
self.messages.clear()
|
||||
self.messageEdit.clear()
|
||||
|
||||
def filtering(self):
|
||||
|
@ -140,7 +140,8 @@ class Friend(Contact):
|
||||
return self._new_messages
|
||||
|
||||
def set_messages(self, value):
|
||||
self._new_messages = value
|
||||
self._widget.connection_status.messages = self._new_messages = value
|
||||
self._widget.connection_status.repaint()
|
||||
|
||||
messages = property(get_messages, set_messages)
|
||||
|
||||
@ -223,15 +224,19 @@ class Profile(Contact):
|
||||
return self._active_friend
|
||||
|
||||
def set_active(self, value):
|
||||
# TODO: rewrite to work with filtering
|
||||
if self._active_friend == value:
|
||||
return False
|
||||
try:
|
||||
visible_friends = filter(lambda elem: elem[1].visibility, enumerate(self._friends))
|
||||
self._active_friend = visible_friends[value][0]
|
||||
self.friends[self._active_friend].set_messages(False)
|
||||
self._friends[self._active_friend].set_messages(False)
|
||||
self._messages.clear()
|
||||
self._messages.repaint()
|
||||
# TODO: load history
|
||||
except: # no friend found. ignore
|
||||
log('Incorrect friend value: ' + str(value))
|
||||
return True
|
||||
|
||||
active_friend = property(get_active, set_active)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user