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 from util import curr_directory, get_style
class login(object): class Login(object):
def __init__(self, arr): def __init__(self, arr):
self.arr = arr self.arr = arr
@ -33,7 +33,7 @@ class login(object):
def main(): def main():
""" """
main function of app. loads loginscreen if needed and starts mainscreen main function of app. loads login screen if needed and starts main screen
""" """
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)
app.setWindowIcon(QtGui.QIcon(curr_directory() + '/images/icon.png')) app.setWindowIcon(QtGui.QIcon(curr_directory() + '/images/icon.png'))
@ -44,7 +44,7 @@ def main():
ls.setWindowIconText("Toxygen") ls.setWindowIconText("Toxygen")
profiles = ProfileHelper.find_profiles() profiles = ProfileHelper.find_profiles()
ls.update_select(map(lambda x: x[1], 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.update_on_close(_login.login_screen_close)
ls.show() ls.show()
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()")) app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
@ -120,5 +120,5 @@ class ToxIterateThread(QtCore.QThread):
if __name__ == '__main__': if __name__ == '__main__':
# TODO: add command line options (example: portable, multiprofile) # TODO: add command line options
main() main()

View file

@ -238,9 +238,20 @@ class NetworkSettings(CenteredWidget):
def closeEvent(self, *args, **kwargs): def closeEvent(self, *args, **kwargs):
settings = Settings.get_instance() settings = Settings.get_instance()
old_data = str(settings['ipv6_enabled']) + str(settings['udp_enabled']) + str(settings['proxy_type']) 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())
# check if proxy data changed and recreate tox instance 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): class PrivacySettings(CenteredWidget):

View file

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