quick_frontend, primitivus: better notifications handling

This commit is contained in:
Goffi 2016-07-24 17:56:14 +02:00
commit e32bd443a3
3 changed files with 44 additions and 26 deletions

View file

@ -31,8 +31,8 @@ class Const(constants.Const):
('selected_focus', 'default,bold', 'dark red'),
('default', 'default', 'default'),
('default_focus', 'default,bold', 'default'),
('cl_notifs', 'default,underline', 'yellow'),
('cl_notifs_focus', 'default,bold,underline', 'yellow'),
('cl_notifs', 'yellow', 'default'),
('cl_notifs_focus', 'yellow,bold', 'default'),
('cl_mention', 'dark red', 'default'),
('cl_mention_focus', 'dark red,bold', 'default'),
# Messages

View file

@ -143,7 +143,7 @@ class ContactList(PrimitivusWidget, QuickContactList):
self._emit('click', entity)
def onNotification(self, entity, notif, profile):
notifs = self.host.getNotifs(C.ENTITY_ALL, profile=self.profile)
notifs = list(self.host.getNotifs(C.ENTITY_ALL, profile=self.profile))
if notifs:
self.title_dynamic = u"({})".format(len(notifs))
else:
@ -197,11 +197,10 @@ class ContactList(PrimitivusWidget, QuickContactList):
else:
entity_attr = 'default'
notifs = self.host.getNotifs(entity.bare, profile=self.profile)
notifs = list(self.host.getNotifs(entity, exact_jid=special, profile=self.profile))
if notifs:
entity_attr = 'cl_notifs'
header = u'({}) '.format(len(notifs))
if self.host.getNotifs(entity.bare, C.NOTIFY_MENTION, profile=self.profile):
header = [('cl_notifs', u'({})'.format(len(notifs))), u' ']
if list(self.host.getNotifs(entity.bare, C.NOTIFY_MENTION, profile=self.profile)):
header = ('cl_mention', header)
else:
header = u''

View file

@ -673,11 +673,11 @@ class PrimitivusApp(QuickApp, InputHistory):
self.notif_bar.setProgress(percentage)
def contactSelected(self, contact_list, entity):
self.clearNotifs(entity, profile=contact_list.profile)
if entity.resource:
# we have clicked on a private MUC conversation
chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, force_hash = Chat.getPrivateHash(contact_list.profile, entity), profile=contact_list.profile)
else:
self.clearNotifs(entity, profile=contact_list.profile)
chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, profile=contact_list.profile)
self.selectWidget(chat_widget)
self.menu_roller.addMenu(_('Chat menu'), chat_widget.getMenu(), C.MENU_ID_WIDGET)