group peer context menu
This commit is contained in:
parent
5521b768bc
commit
eba7e0c0dc
@ -194,3 +194,20 @@ class GroupMenuGenerator(BaseContactMenuGenerator):
|
||||
).build()
|
||||
|
||||
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
|
||||
|
@ -362,6 +362,12 @@ class ContactsManager(ToxSave):
|
||||
contact.reset_avatar(self._settings['identicons'])
|
||||
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
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1,4 +1,5 @@
|
||||
import contacts.contact
|
||||
from contacts.contact_menu import GroupPeerMenuGenerator
|
||||
|
||||
|
||||
class GroupPeerContact(contacts.contact.Contact):
|
||||
@ -16,4 +17,4 @@ class GroupPeerContact(contacts.contact.Contact):
|
||||
pass
|
||||
|
||||
def get_context_menu_generator(self):
|
||||
return None
|
||||
return GroupPeerMenuGenerator(self)
|
||||
|
Loading…
Reference in New Issue
Block a user