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