From ae3e84e3d27ddf775dce1956f8db18173d8db396 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sun, 21 Feb 2016 17:32:38 +0300 Subject: [PATCH] added menu to main screen, some bug fixes --- src/main.py | 9 ++++---- src/mainscreen.py | 59 ++++++++++++++++++++++++++++++++++++++++++++--- tests/tests.py | 24 +------------------ 3 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/main.py b/src/main.py index 1fac50f..9748ceb 100644 --- a/src/main.py +++ b/src/main.py @@ -64,7 +64,7 @@ def main(): if not _login.t: return elif _login.t == 1: # create new profile - # TODO: add creation of new profile + # TODO: add possibility to create new profile path = Settings.get_default_path() name = _login.name if _login.name else 'Toxygen User' return @@ -81,19 +81,17 @@ def main(): ms = MainWindow() # creating tox instance tox = tox_factory(data, settings) + ms.show() # bootstrap for data in node_generator(): tox.bootstrap(*data) - # TODO: set all callbacks + # TODO: set all callbacks (create callback.py) and init it with ms tox.callback_friend_message(message, 0) tox.callback_self_connection_status(status, 0) - #tox.callback_friend_connection_status(friend_status, 0) - # starting thread for tox iterate mainloop = ToxIterateThread(tox) mainloop.start() - ms.show() app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()")) app.exec_() mainloop.stop = True @@ -115,4 +113,5 @@ class ToxIterateThread(QtCore.QThread): if __name__ == '__main__': + # TODO: add command line options? main() diff --git a/src/mainscreen.py b/src/mainscreen.py index 32b4aa5..d014a04 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -4,12 +4,63 @@ import sys from PySide import QtGui, QtCore -class MainWindow(QtGui.QWidget): +class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.initUI() + def setup_menu(self, MainWindow): + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setObjectName("menubar") + self.menuProfile = QtGui.QMenu(self.menubar) + self.menuProfile.setObjectName("menuProfile") + self.menuSettings = QtGui.QMenu(self.menubar) + self.menuSettings.setObjectName("menuSettings") + self.menuAbout = QtGui.QMenu(self.menubar) + self.menuAbout.setObjectName("menuAbout") + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + self.actionAdd_friend = QtGui.QAction(MainWindow) + self.actionAdd_friend.setObjectName("actionAdd_friend") + self.actionProfile_settings = QtGui.QAction(MainWindow) + self.actionProfile_settings.setObjectName("actionProfile_settings") + self.actionPrivacy_settings = QtGui.QAction(MainWindow) + self.actionPrivacy_settings.setObjectName("actionPrivacy_settings") + self.actionInterface_settings = QtGui.QAction(MainWindow) + self.actionInterface_settings.setObjectName("actionInterface_settings") + self.actionNotifications = QtGui.QAction(MainWindow) + self.actionNotifications.setObjectName("actionNotifications") + self.actionNetwork = QtGui.QAction(MainWindow) + self.actionNetwork.setObjectName("actionNetwork") + self.actionAbout_program = QtGui.QAction(MainWindow) + self.actionAbout_program.setObjectName("actionAbout_program") + self.actionSettings = QtGui.QAction(MainWindow) + self.actionSettings.setObjectName("actionSettings") + self.menuProfile.addAction(self.actionAdd_friend) + self.menuProfile.addAction(self.actionSettings) + self.menuSettings.addAction(self.actionPrivacy_settings) + self.menuSettings.addAction(self.actionInterface_settings) + self.menuSettings.addAction(self.actionNotifications) + self.menuSettings.addAction(self.actionNetwork) + self.menuAbout.addAction(self.actionAbout_program) + self.menubar.addAction(self.menuProfile.menuAction()) + self.menubar.addAction(self.menuSettings.menuAction()) + self.menubar.addAction(self.menuAbout.menuAction()) + + self.menuProfile.setTitle(QtGui.QApplication.translate("MainWindow", "Profile", None, QtGui.QApplication.UnicodeUTF8)) + self.menuSettings.setTitle(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.menuAbout.setTitle(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8)) + self.actionAdd_friend.setText(QtGui.QApplication.translate("MainWindow", "Add contact", None, QtGui.QApplication.UnicodeUTF8)) + self.actionProfile_settings.setText(QtGui.QApplication.translate("MainWindow", "Profile", None, QtGui.QApplication.UnicodeUTF8)) + self.actionPrivacy_settings.setText(QtGui.QApplication.translate("MainWindow", "Privacy", None, QtGui.QApplication.UnicodeUTF8)) + self.actionInterface_settings.setText(QtGui.QApplication.translate("MainWindow", "Interface", None, QtGui.QApplication.UnicodeUTF8)) + self.actionNotifications.setText(QtGui.QApplication.translate("MainWindow", "Notifications", None, QtGui.QApplication.UnicodeUTF8)) + self.actionNetwork.setText(QtGui.QApplication.translate("MainWindow", "Network", None, QtGui.QApplication.UnicodeUTF8)) + self.actionAbout_program.setText(QtGui.QApplication.translate("MainWindow", "About program", None, QtGui.QApplication.UnicodeUTF8)) + self.actionSettings.setText(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8)) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + def setup_right_bottom(self, Form): Form.setObjectName("right_bottom") Form.resize(500, 150) @@ -109,6 +160,7 @@ class MainWindow(QtGui.QWidget): QtCore.QMetaObject.connectSlotsByName(Form) def initUI(self): + main = QtGui.QWidget() grid = QtGui.QGridLayout() search = QtGui.QWidget() grid.setColumnStretch(1, 1) @@ -123,11 +175,12 @@ class MainWindow(QtGui.QWidget): message = QtGui.QWidget() self.setup_right_bottom(message) grid.addWidget(message, 2, 1) - self.setLayout(grid) + main.setLayout(grid) + self.setup_menu(main) + self.setCentralWidget(main) self.setMinimumSize(800, 400) self.setGeometry(400, 400, 800, 400) self.setWindowTitle('Toxygen') - self.show() if __name__ == '__main__': app = QtGui.QApplication(sys.argv) diff --git a/tests/tests.py b/tests/tests.py index 9583687..806527c 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -18,29 +18,7 @@ class TestSettings(): os.remove(path) Settings() assert os.path.exists(path) - - -class TestTox(): - - def test_public_key(self): - settings = Settings() - data = Profile.open_profile(Settings.get_default_path(), 'tox_save') - try: - tox = Tox(data, settings) - except: - raise - assert 0 - try: - key = tox.self_get_public_key() - except: - raise - assert 0 - assert len(key.raw) == 32 - try: - del tox - except: - raise - + class TestProfile():