From 99136cd4e3b009c223265794635ef4ebbf8c4a6b Mon Sep 17 00:00:00 2001 From: emdee Date: Mon, 11 Dec 2023 16:00:54 +0000 Subject: [PATCH] grouppeer status fixes --- toxygen/contacts/contacts_manager.py | 3 ++- toxygen/contacts/group_chat.py | 2 +- toxygen/contacts/group_peer_contact.py | 5 +++-- toxygen/contacts/group_peer_factory.py | 5 ++++- toxygen/ui/contact_items.py | 3 ++- toxygen/ui/group_peers_list.py | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/toxygen/contacts/contacts_manager.py b/toxygen/contacts/contacts_manager.py index ddcdca8..68621ab 100644 --- a/toxygen/contacts/contacts_manager.py +++ b/toxygen/contacts/contacts_manager.py @@ -291,7 +291,7 @@ class ContactsManager(ToxSave): def get_or_create_group_peer_contact(self, group_number, peer_id): group = self.get_group_by_number(group_number) peer = group.get_peer_by_id(peer_id) - if peer: # broken? + if peer is None: # broken? is 0 allowed? if not hasattr(peer, 'public_key') or not peer.public_key: LOG.error(f'no peer public_key ' + repr(dir(peer))) else: @@ -300,6 +300,7 @@ class ContactsManager(ToxSave): return self.get_contact_by_tox_id(peer.public_key) else: LOG.warn(f'no peer group_number={group_number} peer_id={peer_id}') + return peer def check_if_contact_exists(self, tox_id): return any(filter(lambda c: c.tox_id == tox_id, self._contacts)) diff --git a/toxygen/contacts/group_chat.py b/toxygen/contacts/group_chat.py index 764c6b3..d77535b 100644 --- a/toxygen/contacts/group_chat.py +++ b/toxygen/contacts/group_chat.py @@ -84,7 +84,7 @@ class GroupChat(contact.Contact, ToxSave): LOG_WARN(f"add_peer id={peer_id} > {self._peers_limit}") return - status_message = f"From {self.name}" + status_message = f"Private in {self.name}" LOG_TRACE(f"GC.add_peer id={peer_id} status_message={status_message}") peer = GroupChatPeer(peer_id, self._tox.group_peer_get_name(self._number, peer_id), diff --git a/toxygen/contacts/group_peer_contact.py b/toxygen/contacts/group_peer_contact.py index 8854198..3d232eb 100644 --- a/toxygen/contacts/group_peer_contact.py +++ b/toxygen/contacts/group_peer_contact.py @@ -4,8 +4,9 @@ from contacts.contact_menu import GroupPeerMenuGenerator class GroupPeerContact(contacts.contact.Contact): - def __init__(self, profile_manager, message_getter, peer_number, name, widget, tox_id, group_pk): - super().__init__(profile_manager, message_getter, peer_number, name, str(), widget, tox_id) + def __init__(self, profile_manager, message_getter, peer_number, name, widget, tox_id, group_pk, status_message=None): + if status_message is None: status_message=str() + super().__init__(profile_manager, message_getter, peer_number, name, status_message, widget, tox_id) self._group_pk = group_pk def get_group_pk(self): diff --git a/toxygen/contacts/group_peer_factory.py b/toxygen/contacts/group_peer_factory.py index 38b3a20..772cf4f 100644 --- a/toxygen/contacts/group_peer_factory.py +++ b/toxygen/contacts/group_peer_factory.py @@ -14,7 +14,10 @@ class GroupPeerFactory(ToxSave): item = self._create_group_peer_item() message_getter = self._db.messages_getter(peer.public_key) group_peer_contact = GroupPeerContact(self._profile_manager, message_getter, peer.id, peer.name, - item, peer.public_key, group.tox_id) + item, + peer.public_key, + group.tox_id, + status_message=peer.status_message) group_peer_contact.status = peer.status return group_peer_contact diff --git a/toxygen/ui/contact_items.py b/toxygen/ui/contact_items.py index 98a1dcd..1963247 100644 --- a/toxygen/ui/contact_items.py +++ b/toxygen/ui/contact_items.py @@ -32,7 +32,8 @@ class ContactItem(QtWidgets.QWidget): self.status_message.setFont(font) self.kind = DataLabel(self) self.kind.setGeometry(QtCore.QRect(50 if mode else 75, 38 if mode else 48, 190, 15 if mode else 20)) - font.setBold(True) + font.setBold(False) + font.setItalic(True) self.kind.setFont(font) self.connection_status = StatusCircle(self) self.connection_status.setGeometry(QtCore.QRect(230, -2 if mode else 5, 32, 32)) diff --git a/toxygen/ui/group_peers_list.py b/toxygen/ui/group_peers_list.py index 16a6cfc..b559a56 100644 --- a/toxygen/ui/group_peers_list.py +++ b/toxygen/ui/group_peers_list.py @@ -15,7 +15,7 @@ class PeerItem(QtWidgets.QWidget): self.nameLabel.setText(name) if peer.status == TOX_USER_STATUS['NONE']: if peer.is_current_user: - style = 'QLabel {color: green;}' + style = 'QLabel {color: magenta}' else: style = 'QLabel {color: green}' elif peer.status == TOX_USER_STATUS['AWAY']: