From e21a9355e7b9f5814eb30362e2aec959ccc74c7e Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Fri, 11 May 2018 22:02:03 +0300 Subject: [PATCH] minor fixes - context menu --- toxygen/contacts/contact_menu.py | 5 +++-- toxygen/ui/main_screen.py | 15 ++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/toxygen/contacts/contact_menu.py b/toxygen/contacts/contact_menu.py index d49c975..d924702 100644 --- a/toxygen/contacts/contact_menu.py +++ b/toxygen/contacts/contact_menu.py @@ -110,6 +110,7 @@ class FriendMenuGenerator(BaseContactMenuGenerator): .with_action(util_ui.tr('Export as text'), lambda: main_screen.export_history(number)) .with_action(util_ui.tr('Export as HTML'), lambda: main_screen.export_history(number, False)) ).build() + return history_menu def _generate_copy_menu(self, main_screen): @@ -134,11 +135,11 @@ class FriendMenuGenerator(BaseContactMenuGenerator): plugins_menu = (plugins_menu_builder .with_name(util_ui.tr('Plugins')) .with_actions(plugins_actions) - ) + ).build() return plugins_menu - def _generate_groups_menu(self, contacts_manager): + def _generate_groups_menu(self, contacts_manager): # TODO: fix chats = contacts_manager.get_group_chats() if not len(chats) or self._contact.status is None: return None diff --git a/toxygen/ui/main_screen.py b/toxygen/ui/main_screen.py index 5c96e97..b318ccc 100644 --- a/toxygen/ui/main_screen.py +++ b/toxygen/ui/main_screen.py @@ -574,19 +574,16 @@ class MainWindow(QtWidgets.QMainWindow): # ----------------------------------------------------------------------------------------------------------------- def friend_right_click(self, pos): - # TODO: move to contact? item = self.friends_list.itemAt(pos) number = self.friends_list.indexFromItem(item).row() contact = self._contacts_manager.get_contact(number) - if contact is None: + if contact is None or item is None: return - if item is not None: - generator = contact.get_context_menu_generator() - self.listMenu = generator.generate(self._plugins_loader, self._contacts_manager, self, - self._settings, number) - parent_position = self.friends_list.mapToGlobal(QtCore.QPoint(0, 0)) - self.listMenu.move(parent_position + pos) - self.listMenu.show() + generator = contact.get_context_menu_generator() + self.listMenu = generator.generate(self._plugins_loader, self._contacts_manager, self, self._settings, number) + parent_position = self.friends_list.mapToGlobal(QtCore.QPoint(0, 0)) + self.listMenu.move(parent_position + pos) + self.listMenu.show() def show_note(self, friend): note = self._settings['notes'][friend.tox_id] if friend.tox_id in self._settings['notes'] else ''