menu update + group leaving
This commit is contained in:
parent
bb4e80ca09
commit
8a53fc8727
@ -582,14 +582,8 @@ class MainWindow(QtGui.QMainWindow):
|
||||
if len(submenu):
|
||||
plug = self.listMenu.addMenu(QtGui.QApplication.translate("MainWindow", 'Plugins', None, QtGui.QApplication.UnicodeUTF8))
|
||||
plug.addActions(submenu)
|
||||
self.connect(set_alias_item, QtCore.SIGNAL("triggered()"), lambda: self.set_alias(num))
|
||||
self.connect(remove_item, QtCore.SIGNAL("triggered()"), lambda: self.remove_friend(num))
|
||||
self.connect(copy_key_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_friend_key(num))
|
||||
self.connect(clear_history_item, QtCore.SIGNAL("triggered()"), lambda: self.clear_history(num))
|
||||
self.connect(auto_accept_item, QtCore.SIGNAL("triggered()"), lambda: self.auto_accept(num, not allowed))
|
||||
self.connect(notes_item, QtCore.SIGNAL("triggered()"), lambda: self.show_note(friend))
|
||||
self.connect(copy_name_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_name(friend))
|
||||
self.connect(copy_status_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_status(friend))
|
||||
else:
|
||||
copy_menu = self.listMenu.addMenu(
|
||||
QtGui.QApplication.translate("MainWindow", 'Copy', None, QtGui.QApplication.UnicodeUTF8))
|
||||
@ -601,13 +595,17 @@ class MainWindow(QtGui.QMainWindow):
|
||||
QtGui.QApplication.translate("MainWindow", 'Public key', None, QtGui.QApplication.UnicodeUTF8))
|
||||
leave_item = self.listMenu.addAction(QtGui.QApplication.translate("MainWindow", 'Leave group', None, QtGui.QApplication.UnicodeUTF8))
|
||||
set_alias_item = self.listMenu.addAction(QtGui.QApplication.translate("MainWindow", 'Set alias', None, QtGui.QApplication.UnicodeUTF8))
|
||||
clear_history_item = self.listMenu.addAction(QtGui.QApplication.translate("MainWindow", 'Clear history', None, QtGui.QApplication.UnicodeUTF8))
|
||||
notes_item = self.listMenu.addAction(QtGui.QApplication.translate("MainWindow", 'Notes', None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.connect(notes_item, QtCore.SIGNAL("triggered()"), lambda: self.show_note(friend))
|
||||
self.connect(copy_name_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_name(friend))
|
||||
self.connect(copy_status_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_status(friend))
|
||||
self.connect(copy_key_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_friend_key(num))
|
||||
self.connect(leave_item, QtCore.SIGNAL("triggered()"), lambda: Profile.get_instance().leave_group(num))
|
||||
self.connect(set_alias_item, QtCore.SIGNAL("triggered()"), lambda: self.set_alias(num))
|
||||
|
||||
self.connect(notes_item, QtCore.SIGNAL("triggered()"), lambda: self.show_note(friend))
|
||||
self.connect(set_alias_item, QtCore.SIGNAL("triggered()"), lambda: self.set_alias(num))
|
||||
self.connect(clear_history_item, QtCore.SIGNAL("triggered()"), lambda: self.clear_history(num))
|
||||
self.connect(copy_name_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_name(friend))
|
||||
self.connect(copy_status_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_status(friend))
|
||||
self.connect(copy_key_item, QtCore.SIGNAL("triggered()"), lambda: self.copy_friend_key(num))
|
||||
|
||||
parent_position = self.friends_list.mapToGlobal(QtCore.QPoint(0, 0))
|
||||
self.listMenu.move(parent_position + pos)
|
||||
self.listMenu.show()
|
||||
|
@ -694,11 +694,12 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||
def friend_public_key(self, num):
|
||||
return self._friends_and_gc[num].tox_id
|
||||
|
||||
def delete_friend_or_gc(self, num, is_gc=False):
|
||||
def delete_friend_or_gc(self, num, is_gc=False, message=None):
|
||||
"""
|
||||
Removes friend or gc from contact list
|
||||
:param num: number of friend or gc in list
|
||||
:param is_gc: is a group chat
|
||||
:param message: message in gc
|
||||
"""
|
||||
friend = self._friends_and_gc[num]
|
||||
settings = Settings.get_instance()
|
||||
@ -715,10 +716,12 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||
self._history.delete_friend_from_db(friend.tox_id)
|
||||
if not is_gc:
|
||||
self._tox.friend_delete(friend.number)
|
||||
else:
|
||||
self._tox.group_leave(num, message)
|
||||
del self._friends_and_gc[num]
|
||||
self._screen.friends_list.takeItem(num)
|
||||
if num == self._active_friend_or_gc: # active friend was deleted
|
||||
if not len(self._friends_and_gc): # last friend was deleted
|
||||
if num == self._active_friend_or_gc: # active friend or gc was deleted
|
||||
if not len(self._friends_and_gc): # last contact was deleted
|
||||
self.set_active(-1)
|
||||
else:
|
||||
self.set_active(0)
|
||||
@ -1309,9 +1312,7 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||
self._tox.group_invite_friend(group_number, friend_number)
|
||||
|
||||
def leave_group(self, num, message=None):
|
||||
number = self._friends_and_gc[num].number
|
||||
self._tox.group_leave(number, message)
|
||||
self.delete_friend_or_gc(num, False)
|
||||
self.delete_friend_or_gc(num, True, message)
|
||||
|
||||
|
||||
def tox_factory(data=None, settings=None):
|
||||
|
Loading…
Reference in New Issue
Block a user