tab && bug fix
This commit is contained in:
parent
65167de1fe
commit
1ea919bdc2
3 changed files with 26 additions and 4 deletions
|
@ -32,11 +32,15 @@ class GroupChat(contact.Contact):
|
||||||
def remove_invalid_unsent_files(self):
|
def remove_invalid_unsent_files(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_full_status(self):
|
def get_names(self):
|
||||||
peers_count = self._tox.group_number_peers(self._number)
|
peers_count = self._tox.group_number_peers(self._number)
|
||||||
names = []
|
names = []
|
||||||
for i in range(peers_count):
|
for i in range(peers_count):
|
||||||
name = self._tox.group_peername(self._number, i)
|
name = self._tox.group_peername(self._number, i)
|
||||||
names.append(name)
|
names.append(name)
|
||||||
names = sorted(names, key=lambda n: n.lower())
|
names = sorted(names, key=lambda n: n.lower())
|
||||||
|
return names
|
||||||
|
|
||||||
|
def get_full_status(self):
|
||||||
|
names = self.get_names()
|
||||||
return '\n'.join(names)
|
return '\n'.join(names)
|
||||||
|
|
|
@ -34,6 +34,10 @@ class MessageArea(QtWidgets.QPlainTextEdit):
|
||||||
self.parent.send_message()
|
self.parent.send_message()
|
||||||
elif event.key() == QtCore.Qt.Key_Up and not self.toPlainText():
|
elif event.key() == QtCore.Qt.Key_Up and not self.toPlainText():
|
||||||
self.appendPlainText(Profile.get_instance().get_last_message())
|
self.appendPlainText(Profile.get_instance().get_last_message())
|
||||||
|
elif event.key() == QtCore.Qt.Key_Tab and not self.parent.profile.is_active_a_friend():
|
||||||
|
text = self.toPlainText()
|
||||||
|
pos = self.textCursor().position()
|
||||||
|
self.insertPlainText(Profile.get_instance().get_gc_peer_name(text[:pos]))
|
||||||
else:
|
else:
|
||||||
self.parent.profile.send_typing(True)
|
self.parent.profile.send_typing(True)
|
||||||
if self.timer.isActive():
|
if self.timer.isActive():
|
||||||
|
|
|
@ -17,6 +17,7 @@ import items_factory
|
||||||
import cv2
|
import cv2
|
||||||
import threading
|
import threading
|
||||||
from group_chat import *
|
from group_chat import *
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Profile(basecontact.BaseContact, Singleton):
|
class Profile(basecontact.BaseContact, Singleton):
|
||||||
|
@ -130,6 +131,7 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||||
filter_str = filter_str.lower()
|
filter_str = filter_str.lower()
|
||||||
settings = Settings.get_instance()
|
settings = Settings.get_instance()
|
||||||
number = self.get_active_number()
|
number = self.get_active_number()
|
||||||
|
is_friend = self.is_active_a_friend()
|
||||||
if sorting > 1:
|
if sorting > 1:
|
||||||
if sorting & 2:
|
if sorting & 2:
|
||||||
self._contacts = sorted(self._contacts, key=lambda x: int(x.status is not None), reverse=True)
|
self._contacts = sorted(self._contacts, key=lambda x: int(x.status is not None), reverse=True)
|
||||||
|
@ -165,7 +167,7 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||||
self._sorting, self._filter_string = sorting, filter_str
|
self._sorting, self._filter_string = sorting, filter_str
|
||||||
settings['sorting'] = self._sorting
|
settings['sorting'] = self._sorting
|
||||||
settings.save()
|
settings.save()
|
||||||
self.set_active_by_number(number)
|
self.set_active_by_number_and_type(number, is_friend)
|
||||||
|
|
||||||
def update_filtration(self):
|
def update_filtration(self):
|
||||||
"""
|
"""
|
||||||
|
@ -291,9 +293,10 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||||
log('Error in set active: ' + str(ex))
|
log('Error in set active: ' + str(ex))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def set_active_by_number(self, number):
|
def set_active_by_number_and_type(self, number, is_friend):
|
||||||
for i in range(len(self._contacts)):
|
for i in range(len(self._contacts)):
|
||||||
if self._contacts[i].number == number:
|
c = self._contacts[i]
|
||||||
|
if c.number == number and (type(c) is Friend == is_friend):
|
||||||
self._active_friend = i
|
self._active_friend = i
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -1402,6 +1405,17 @@ class Profile(basecontact.BaseContact, Singleton):
|
||||||
friend = self._contacts[friend_num]
|
friend = self._contacts[friend_num]
|
||||||
self._tox.invite_friend(friend.number, group_number)
|
self._tox.invite_friend(friend.number, group_number)
|
||||||
|
|
||||||
|
def get_gc_peer_name(self, text):
|
||||||
|
gc = self.get_curr_friend()
|
||||||
|
if type(gc) is not GroupChat:
|
||||||
|
return '\t'
|
||||||
|
names = gc.get_names()
|
||||||
|
name = re.split("\s+", text)[-1]
|
||||||
|
suggested_names = list(filter(lambda x: x.startswith(name), names))
|
||||||
|
if not len(suggested_names):
|
||||||
|
return '\t'
|
||||||
|
return suggested_names[0][len(name):]
|
||||||
|
|
||||||
|
|
||||||
def tox_factory(data=None, settings=None):
|
def tox_factory(data=None, settings=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue