tests + profile.py
This commit is contained in:
parent
3ab7794d17
commit
14dd46b716
6 changed files with 78 additions and 22 deletions
|
@ -4,7 +4,8 @@ from PySide import QtCore, QtGui
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class LoginScreen(object):
|
|
||||||
|
class LoginScreen(QtGui.QWidget):
|
||||||
def setupUi(self, Form):
|
def setupUi(self, Form):
|
||||||
Form.setObjectName("Form")
|
Form.setObjectName("Form")
|
||||||
Form.resize(400, 200)
|
Form.resize(400, 200)
|
||||||
|
@ -63,15 +64,17 @@ class LoginScreen(object):
|
||||||
self.groupBox_2.setTitle(QtGui.QApplication.translate("Form", "Create new profile", None, QtGui.QApplication.UnicodeUTF8))
|
self.groupBox_2.setTitle(QtGui.QApplication.translate("Form", "Create new profile", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.toxygen.setText(QtGui.QApplication.translate("Form", "toxygen", None, QtGui.QApplication.UnicodeUTF8))
|
self.toxygen.setText(QtGui.QApplication.translate("Form", "toxygen", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
|
def update_select(self, data):
|
||||||
|
list_of_profiles = []
|
||||||
|
for elem in data:
|
||||||
|
list_of_profiles.append(self.tr(elem))
|
||||||
|
self.comboBox.addItems(list_of_profiles)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
|
|
||||||
ls = LoginScreen()
|
ls = LoginScreen()
|
||||||
win = QtGui.QMainWindow()
|
win = QtGui.QMainWindow()
|
||||||
ls.setupUi(win)
|
ls.setupUi(win)
|
||||||
win.show()
|
win.show()
|
||||||
|
|
||||||
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
|
20
src/main.py
20
src/main.py
|
@ -0,0 +1,20 @@
|
||||||
|
from loginscreen import LoginScreen
|
||||||
|
from settings import Settings
|
||||||
|
import sys
|
||||||
|
from PySide import QtCore, QtGui
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app = QtGui.QApplication(sys.argv)
|
||||||
|
settings = Settings()
|
||||||
|
if not settings['auto_profile']:
|
||||||
|
# show login screen if default profile not found
|
||||||
|
ls = LoginScreen()
|
||||||
|
win = QtGui.QMainWindow()
|
||||||
|
ls.setupUi(win)
|
||||||
|
|
||||||
|
ls.update_select(['tox_save'])
|
||||||
|
win.show()
|
||||||
|
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()"))
|
||||||
|
app.exec_()
|
||||||
|
# TODO: get result from loginscreen and open mainscreen
|
|
@ -111,6 +111,7 @@ class MainWindow(QtGui.QWidget):
|
||||||
def initUI(self):
|
def initUI(self):
|
||||||
grid = QtGui.QGridLayout()
|
grid = QtGui.QGridLayout()
|
||||||
search = QtGui.QWidget()
|
search = QtGui.QWidget()
|
||||||
|
grid.setColumnStretch(1, 1)
|
||||||
self.setup_left_center(search)
|
self.setup_left_center(search)
|
||||||
grid.addWidget(search, 1, 0)
|
grid.addWidget(search, 1, 0)
|
||||||
name = QtGui.QWidget()
|
name = QtGui.QWidget()
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
from settings import Settings
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class Profile(object):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def find_profiles():
|
||||||
|
path = Settings.get_default_path()
|
||||||
|
result = []
|
||||||
|
# check default path
|
||||||
|
for fl in os.listdir(path):
|
||||||
|
if fl.endswith(".tox"):
|
||||||
|
name = fl[:-4]
|
||||||
|
result.append((path, name))
|
||||||
|
path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
# check current directory
|
||||||
|
for fl in os.listdir(path):
|
||||||
|
if fl.endswith(".tox"):
|
||||||
|
name = fl[:-4]
|
||||||
|
result.append((path, name))
|
||||||
|
return result
|
||||||
|
|
|
@ -18,24 +18,25 @@ class Settings(dict):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_default_settings():
|
def get_default_settings():
|
||||||
return {
|
return {
|
||||||
"theme": "default",
|
'theme': 'default',
|
||||||
"ipv6_enabled": True,
|
'ipv6_enabled': True,
|
||||||
"udp_enabled": True,
|
'udp_enabled': True,
|
||||||
"proxy_type": 0,
|
'proxy_type': 0,
|
||||||
"proxy_host": "0",
|
'proxy_host': '0',
|
||||||
"proxy_port": 0,
|
'proxy_port': 0,
|
||||||
"start_port": 0,
|
'start_port': 0,
|
||||||
"end_port": 0,
|
'end_port': 0,
|
||||||
"tcp_port": 0,
|
'tcp_port': 0,
|
||||||
"notifications": True,
|
'notifications': True,
|
||||||
"sound_notifications": False,
|
'sound_notifications': False,
|
||||||
"language": "en-en",
|
'language': 'en-en',
|
||||||
"save_history": False,
|
'save_history': False,
|
||||||
"allow_inline": True,
|
'allow_inline': True,
|
||||||
"allow_auto_accept": False,
|
'allow_auto_accept': False,
|
||||||
"auto_accept_from_friends": [],
|
'auto_accept_from_friends': [],
|
||||||
"friends_aliases": [],
|
'friends_aliases': [],
|
||||||
"typing_notifications": True
|
'typing_notifications': True,
|
||||||
|
'auto_profile': ''
|
||||||
}
|
}
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from src.settings import Settings
|
from src.settings import Settings
|
||||||
from src.tox import Tox
|
from src.tox import Tox
|
||||||
import sys
|
import sys
|
||||||
|
from src.profile import Profile
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,3 +35,10 @@ class TestTox():
|
||||||
assert tox.get_savedata_size()
|
assert tox.get_savedata_size()
|
||||||
except:
|
except:
|
||||||
assert 0
|
assert 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestProfile():
|
||||||
|
|
||||||
|
def test_search(self):
|
||||||
|
arr = Profile.find_profiles()
|
||||||
|
assert arr
|
||||||
|
|
Loading…
Reference in a new issue