2016-02-18 17:15:38 +01:00
|
|
|
from loginscreen import LoginScreen
|
|
|
|
from settings import Settings
|
2016-02-19 11:41:54 +01:00
|
|
|
from mainscreen import MainWindow
|
2016-02-18 18:13:55 +01:00
|
|
|
from profile import Profile
|
2016-02-18 17:15:38 +01:00
|
|
|
import sys
|
|
|
|
from PySide import QtCore, QtGui
|
|
|
|
|
|
|
|
|
2016-02-19 11:41:54 +01:00
|
|
|
class login(object):
|
|
|
|
def __init__(self, arr):
|
|
|
|
self.arr = arr
|
|
|
|
|
|
|
|
def login_screen_close(self, t, number=-1, default=False, name=None):
|
|
|
|
print str(t), str(number), str(default), str(name)
|
|
|
|
self.t = t
|
|
|
|
self.num = number
|
|
|
|
self.default = default
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.arr[self.num]
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2016-02-18 17:15:38 +01:00
|
|
|
app = QtGui.QApplication(sys.argv)
|
2016-02-19 11:41:54 +01:00
|
|
|
app.setWindowIcon(QtGui.QIcon('images/icon.png'))
|
2016-02-18 17:15:38 +01:00
|
|
|
settings = Settings()
|
|
|
|
if not settings['auto_profile']:
|
|
|
|
# show login screen if default profile not found
|
|
|
|
ls = LoginScreen()
|
2016-02-19 11:41:54 +01:00
|
|
|
ls.setWindowIconText("Toxygen")
|
2016-02-18 18:13:55 +01:00
|
|
|
profiles = Profile.find_profiles()
|
|
|
|
ls.update_select(map(lambda x: x[1], profiles))
|
2016-02-19 11:41:54 +01:00
|
|
|
_login = login(profiles)
|
|
|
|
ls.update_on_close(_login.login_screen_close)
|
|
|
|
ls.show()
|
2016-02-18 17:15:38 +01:00
|
|
|
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
|
|
|
app.exec_()
|
2016-02-19 11:41:54 +01:00
|
|
|
if not _login.t:
|
|
|
|
return
|
|
|
|
elif _login.t == 1: # create new profile
|
|
|
|
# TODO: add creation of new profile
|
|
|
|
path = Settings.get_default_path()
|
|
|
|
name = _login.name if _login.name else 'Toxygen User'
|
|
|
|
return
|
|
|
|
else: # load existing profile
|
|
|
|
path, name = _login.get_data()
|
|
|
|
if _login.default:
|
|
|
|
settings['auto_profile'] = (path, name)
|
|
|
|
settings.save()
|
2016-02-18 18:13:55 +01:00
|
|
|
else:
|
|
|
|
path, name = settings['auto_profile']
|
2016-02-19 11:41:54 +01:00
|
|
|
# loading profile
|
|
|
|
print str(path), str(name)
|
|
|
|
data = Profile.open_profile(path, name)
|
|
|
|
ms = MainWindow()
|
|
|
|
ms.show()
|
|
|
|
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
|
|
|
app.exec_()
|
2016-02-18 18:13:55 +01:00
|
|
|
# TODO: open mainscreen
|
2016-02-19 11:41:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|