some network menu updates

This commit is contained in:
ingvar1995 2016-03-14 22:30:51 +03:00
parent 614d3fedff
commit 03d3983d83
3 changed files with 33 additions and 7 deletions

View file

@ -9,7 +9,7 @@ from bootstrap import node_generator
from util import curr_directory, get_style
class login(object):
class Login(object):
def __init__(self, arr):
self.arr = arr
@ -44,7 +44,7 @@ def main():
ls.setWindowIconText("Toxygen")
profiles = ProfileHelper.find_profiles()
ls.update_select(map(lambda x: x[1], profiles))
_login = login(profiles)
_login = Login(profiles)
ls.update_on_close(_login.login_screen_close)
ls.show()
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
@ -120,5 +120,5 @@ class ToxIterateThread(QtCore.QThread):
if __name__ == '__main__':
# TODO: add command line options (example: portable, multiprofile)
# TODO: add command line options
main()

View file

@ -238,9 +238,20 @@ class NetworkSettings(CenteredWidget):
def closeEvent(self, *args, **kwargs):
settings = Settings.get_instance()
old_data = str(settings['ipv6_enabled']) + str(settings['udp_enabled']) + str(settings['proxy_type'])
# check if proxy data changed and recreate tox instance
old_data = str(settings['ipv6_enabled']) + str(settings['udp_enabled']) + str(bool(settings['proxy_type']))
new_data = str(self.ipv.isChecked()) + str(self.udp.isChecked()) + str(self.proxy.isChecked())
changed = old_data != new_data
if self.proxy.isChecked() and (self.proxyip.text() != settings['proxy_host'] or self.proxyport.text() != settings['proxy_port']):
changed = True
if changed:
settings['ipv6_enabled'] = self.ipv.isChecked()
settings['udp_enabled'] = self.udp.isChecked()
settings['proxy_type'] = int(self.proxy.isChecked())
settings['proxy_host'] = self.proxyip.text()
settings['proxy_port'] = self.proxyport.text()
settings.save()
# recreate tox instance
Profile.get_instance().reset()
class PrivacySettings(CenteredWidget):

View file

@ -449,6 +449,7 @@ class Profile(Contact, Singleton):
if friend_num == self.get_active_number(): # add message to list
user_name = Profile.get_instance().get_active_name()
self.create_message_item(message.decode('utf-8'), curr_time(), user_name, message_type)
self._messages.scrollToBottom()
self._friends[self._active_friend].append_message((message,
MESSAGE_OWNER['FRIEND'],
time.time(),
@ -477,6 +478,7 @@ class Profile(Contact, Singleton):
self.tox.friend_send_message(friend.number, message_type, text.encode('utf-8'))
self.create_message_item(text, curr_time(), self._name, message_type)
self.screen.messageEdit.clear()
self._messages.scrollToBottom()
friend.append_message((text,
MESSAGE_OWNER['ME'],
int(time.time()),
@ -631,6 +633,19 @@ class Profile(Contact, Singleton):
except Exception as ex: # something is wrong
log('Accept friend request failed! ' + str(ex))
# -----------------------------------------------------------------------------------------------------------------
# Reset
# -----------------------------------------------------------------------------------------------------------------
def reset(self):
"""
Recreate tox instance
"""
print 'In reset'
data = self.tox.get_savedata()
ProfileHelper.save_profile(data)
# TODO: recreate tox
def tox_factory(data=None, settings=None):
"""