command line argument - path to profile - added. windows qcombobox color fix
This commit is contained in:
parent
89be47dc72
commit
2b8da1deb4
4 changed files with 63 additions and 52 deletions
99
src/main.py
99
src/main.py
|
@ -13,9 +13,10 @@ import locale
|
|||
|
||||
class Toxygen(object):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, path=None):
|
||||
super(Toxygen, self).__init__()
|
||||
self.tox = self.ms = self.init = self.mainloop = self.avloop = None
|
||||
self.path = path
|
||||
|
||||
def main(self):
|
||||
"""
|
||||
|
@ -28,51 +29,57 @@ class Toxygen(object):
|
|||
with open(curr_directory() + '/styles/style.qss') as fl:
|
||||
dark_style = fl.read()
|
||||
app.setStyleSheet(dark_style)
|
||||
|
||||
auto_profile = Settings.get_auto_profile()
|
||||
if not auto_profile:
|
||||
# show login screen if default profile not found
|
||||
current_locale = QtCore.QLocale()
|
||||
curr_lang = current_locale.languageToString(current_locale.language())
|
||||
langs = Settings.supported_languages()
|
||||
if curr_lang in map(lambda x: x[0], langs):
|
||||
lang_path = filter(lambda x: x[0] == curr_lang, langs)[0][1]
|
||||
translator = QtCore.QTranslator()
|
||||
translator.load(curr_directory() + '/translations/' + lang_path)
|
||||
app.installTranslator(translator)
|
||||
app.translator = translator
|
||||
ls = LoginScreen()
|
||||
ls.setWindowIconText("Toxygen")
|
||||
profiles = ProfileHelper.find_profiles()
|
||||
ls.update_select(map(lambda x: x[1], profiles))
|
||||
_login = self.Login(profiles)
|
||||
ls.update_on_close(_login.login_screen_close)
|
||||
ls.show()
|
||||
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
||||
app.exec_()
|
||||
if not _login.t:
|
||||
return
|
||||
elif _login.t == 1: # create new profile
|
||||
name = _login.name if _login.name else 'toxygen_user'
|
||||
self.tox = tox_factory()
|
||||
self.tox.self_set_name(_login.name if _login.name else 'Toxygen User')
|
||||
self.tox.self_set_status_message('Toxing on Toxygen')
|
||||
ProfileHelper.save_profile(self.tox.get_savedata(), name)
|
||||
path = Settings.get_default_path()
|
||||
settings = Settings(name)
|
||||
else: # load existing profile
|
||||
path, name = _login.get_data()
|
||||
if _login.default:
|
||||
Settings.set_auto_profile(path, name)
|
||||
data = ProfileHelper.open_profile(path, name)
|
||||
settings = Settings(name)
|
||||
self.tox = tox_factory(data, settings)
|
||||
else:
|
||||
path, name = auto_profile
|
||||
path = path.encode(locale.getpreferredencoding())
|
||||
if self.path is not None:
|
||||
path = os.path.dirname(self.path.encode(locale.getpreferredencoding())) + '/'
|
||||
name = os.path.basename(self.path.encode(locale.getpreferredencoding()))[:-4]
|
||||
data = ProfileHelper.open_profile(path, name)
|
||||
settings = Settings(name)
|
||||
self.tox = tox_factory(data, settings)
|
||||
else:
|
||||
auto_profile = Settings.get_auto_profile()
|
||||
if not auto_profile:
|
||||
# show login screen if default profile not found
|
||||
current_locale = QtCore.QLocale()
|
||||
curr_lang = current_locale.languageToString(current_locale.language())
|
||||
langs = Settings.supported_languages()
|
||||
if curr_lang in map(lambda x: x[0], langs):
|
||||
lang_path = filter(lambda x: x[0] == curr_lang, langs)[0][1]
|
||||
translator = QtCore.QTranslator()
|
||||
translator.load(curr_directory() + '/translations/' + lang_path)
|
||||
app.installTranslator(translator)
|
||||
app.translator = translator
|
||||
ls = LoginScreen()
|
||||
ls.setWindowIconText("Toxygen")
|
||||
profiles = ProfileHelper.find_profiles()
|
||||
ls.update_select(map(lambda x: x[1], profiles))
|
||||
_login = self.Login(profiles)
|
||||
ls.update_on_close(_login.login_screen_close)
|
||||
ls.show()
|
||||
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
||||
app.exec_()
|
||||
if not _login.t:
|
||||
return
|
||||
elif _login.t == 1: # create new profile
|
||||
name = _login.name if _login.name else 'toxygen_user'
|
||||
self.tox = tox_factory()
|
||||
self.tox.self_set_name(_login.name if _login.name else 'Toxygen User')
|
||||
self.tox.self_set_status_message('Toxing on Toxygen')
|
||||
ProfileHelper.save_profile(self.tox.get_savedata(), name)
|
||||
path = Settings.get_default_path()
|
||||
settings = Settings(name)
|
||||
else: # load existing profile
|
||||
path, name = _login.get_data()
|
||||
if _login.default:
|
||||
Settings.set_auto_profile(path, name)
|
||||
data = ProfileHelper.open_profile(path, name)
|
||||
settings = Settings(name)
|
||||
self.tox = tox_factory(data, settings)
|
||||
else:
|
||||
path, name = auto_profile
|
||||
path = path.encode(locale.getpreferredencoding())
|
||||
data = ProfileHelper.open_profile(path, name)
|
||||
settings = Settings(name)
|
||||
self.tox = tox_factory(data, settings)
|
||||
|
||||
if ProfileHelper.is_active_profile(path, name): # profile is in use
|
||||
reply = QtGui.QMessageBox.question(None,
|
||||
|
@ -252,6 +259,8 @@ class Toxygen(object):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# TODO: add command line options
|
||||
toxygen = Toxygen()
|
||||
if len(sys.argv) == 1:
|
||||
toxygen = Toxygen()
|
||||
else: # path to profile
|
||||
toxygen = Toxygen(sys.argv[1])
|
||||
toxygen.main()
|
||||
|
|
|
@ -668,7 +668,7 @@ QComboBox QAbstractItemView
|
|||
background-color: #201F1F;
|
||||
border-radius: 2px;
|
||||
border: 1px solid #444;
|
||||
selection-background-color: #3d8ec9;
|
||||
selection-background-color: #A9A9A9;
|
||||
}
|
||||
|
||||
QComboBox::drop-down
|
||||
|
|
|
@ -32,6 +32,7 @@ def bin_to_string(raw_id, length):
|
|||
|
||||
|
||||
class Tox(object):
|
||||
|
||||
libtoxcore = LibToxCore()
|
||||
|
||||
def __init__(self, tox_options=None, tox_pointer=None):
|
||||
|
@ -57,9 +58,9 @@ class Tox(object):
|
|||
raise MemoryError('The function was unable to allocate enough '
|
||||
'memory to store the internal structures for the Tox object.')
|
||||
elif tox_err_new == TOX_ERR_NEW['PORT_ALLOC']:
|
||||
raise MemoryError('The function was unable to bind to a port. This may mean that all ports have already'
|
||||
' been bound, e.g. by other Tox instances, or it may mean a permission error. You may'
|
||||
' be able to gather more information from errno.')
|
||||
raise RuntimeError('The function was unable to bind to a port. This may mean that all ports have '
|
||||
'already been bound, e.g. by other Tox instances, or it may mean a permission error.'
|
||||
' You may be able to gather more information from errno.')
|
||||
elif tox_err_new == TOX_ERR_NEW['PROXY_BAD_TYPE']:
|
||||
raise ArgumentError('proxy_type was invalid.')
|
||||
elif tox_err_new == TOX_ERR_NEW['PROXY_BAD_HOST']:
|
||||
|
|
|
@ -27,14 +27,15 @@ def convert_time(t):
|
|||
return '%02d:%02d' % (h, m)
|
||||
|
||||
|
||||
# obsolete
|
||||
def get_style(style):
|
||||
if style != 'default':
|
||||
return style
|
||||
else:
|
||||
if system() == 'Linux':
|
||||
return 'gtk'
|
||||
elif system() == 'Windows':
|
||||
if system() == 'Windows':
|
||||
return 'windows'
|
||||
else:
|
||||
return 'gtk'
|
||||
|
||||
|
||||
class Singleton(object):
|
||||
|
|
Loading…
Reference in a new issue