group peer context menu

This commit is contained in:
ingvar1995 2018-07-22 14:08:47 +03:00
parent 5521b768bc
commit eba7e0c0dc
3 changed files with 25 additions and 1 deletions

View File

@ -194,3 +194,20 @@ class GroupMenuGenerator(BaseContactMenuGenerator):
).build() ).build()
return menu return menu
class GroupPeerMenuGenerator(BaseContactMenuGenerator):
def generate(self, plugin_loader, contacts_manager, main_screen, settings, number, groups_service):
copy_menu_builder = self._generate_copy_menu_builder(main_screen)
builder = ContactMenuBuilder()
menu = (builder
.with_action(util_ui.tr('Set alias'), lambda: main_screen.set_alias(number))
.with_submenu(copy_menu_builder)
.with_action(util_ui.tr('Quit chat'),
lambda: contacts_manager.remove_group_peer(self._contact))
.with_action(util_ui.tr('Notes'), lambda: main_screen.show_note(self._contact))
).build()
return menu

View File

@ -362,6 +362,12 @@ class ContactsManager(ToxSave):
contact.reset_avatar(self._settings['identicons']) contact.reset_avatar(self._settings['identicons'])
self._save_profile() self._save_profile()
def remove_group_peer(self, group_peer_contact):
contact = self.get_contact_by_tox_id(group_peer_contact.tox_id)
self._cleanup_contact_data(contact)
num = self._contacts.index(contact)
self._delete_contact(num)
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Friend requests # Friend requests
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
import contacts.contact import contacts.contact
from contacts.contact_menu import GroupPeerMenuGenerator
class GroupPeerContact(contacts.contact.Contact): class GroupPeerContact(contacts.contact.Contact):
@ -16,4 +17,4 @@ class GroupPeerContact(contacts.contact.Contact):
pass pass
def get_context_menu_generator(self): def get_context_menu_generator(self):
return None return GroupPeerMenuGenerator(self)