ui and docs update

This commit is contained in:
ingvar1995 2016-02-26 17:32:36 +03:00
parent 30aa254d39
commit b592ca3f00
3 changed files with 34 additions and 9 deletions

View File

@ -158,7 +158,7 @@ class MainWindow(QtGui.QMainWindow):
self.sendMessageButton.setText(QtGui.QApplication.translate("Form", "Send", None, QtGui.QApplication.UnicodeUTF8)) self.sendMessageButton.setText(QtGui.QApplication.translate("Form", "Send", None, QtGui.QApplication.UnicodeUTF8))
QtCore.QMetaObject.connectSlotsByName(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setup_left_center(self, Form): def setup_left_bottom(self, Form):
Form.setObjectName("left_center") Form.setObjectName("left_center")
Form.resize(500, 80) Form.resize(500, 80)
self.online_contacts = QtGui.QCheckBox(Form) self.online_contacts = QtGui.QCheckBox(Form)
@ -231,7 +231,7 @@ class MainWindow(QtGui.QMainWindow):
self.callButton.setText(QtGui.QApplication.translate("Form", "Start call", None, QtGui.QApplication.UnicodeUTF8)) self.callButton.setText(QtGui.QApplication.translate("Form", "Start call", None, QtGui.QApplication.UnicodeUTF8))
QtCore.QMetaObject.connectSlotsByName(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setup_left_bottom(self, widget): def setup_left_center(self, widget):
# widget.setFixedWidth(250) # widget.setFixedWidth(250)
# widget.setMinimumSize(QtCore.QSize(250, 500)) # widget.setMinimumSize(QtCore.QSize(250, 500))
# widget.setMaximumSize(QtCore.QSize(250, 500)) # widget.setMaximumSize(QtCore.QSize(250, 500))
@ -258,8 +258,8 @@ class MainWindow(QtGui.QMainWindow):
main = QtGui.QWidget() main = QtGui.QWidget()
grid = QtGui.QGridLayout() grid = QtGui.QGridLayout()
search = QtGui.QWidget() search = QtGui.QWidget()
self.setup_left_center(search) self.setup_left_bottom(search)
grid.addWidget(search, 1, 0) grid.addWidget(search, 2, 0)
name = QtGui.QWidget() name = QtGui.QWidget()
self.setup_left_top(name) self.setup_left_top(name)
grid.addWidget(name, 0, 0) grid.addWidget(name, 0, 0)
@ -270,8 +270,8 @@ class MainWindow(QtGui.QMainWindow):
self.setup_right_bottom(message) self.setup_right_bottom(message)
grid.addWidget(message, 2, 1) grid.addWidget(message, 2, 1)
main_list = QtGui.QWidget() main_list = QtGui.QWidget()
self.setup_left_bottom(main_list) self.setup_left_center(main_list)
grid.addWidget(main_list, 2, 0) grid.addWidget(main_list, 1, 0)
grid.setColumnMinimumWidth(1, 500) grid.setColumnMinimumWidth(1, 500)
grid.setColumnMinimumWidth(0, 250) grid.setColumnMinimumWidth(0, 250)
main.setLayout(grid) main.setLayout(grid)
@ -335,6 +335,7 @@ class MainWindow(QtGui.QMainWindow):
if self.profile.isActiveOnline() and text: if self.profile.isActiveOnline() and text:
num = self.profile.getActiveNumber() num = self.profile.getActiveNumber()
self.tox.friend_send_message(num, TOX_MESSAGE_TYPE['NORMAL'], text) self.tox.friend_send_message(num, TOX_MESSAGE_TYPE['NORMAL'], text)
self.messageEdit.clear()
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Functions which called when user click somewhere else # Functions which called when user click somewhere else

View File

@ -7,7 +7,9 @@ from ctypes import *
class ProfileHelper(object): class ProfileHelper(object):
"""
Class with static methods for search, load and save profiles
"""
@staticmethod @staticmethod
def find_profiles(): def find_profiles():
path = Settings.get_default_path() path = Settings.get_default_path()
@ -46,8 +48,14 @@ class ProfileHelper(object):
class Contact(object): class Contact(object):
"""
Class encapsulating TOX contact
Properties: name (alias of contact or name), status_message, status (connection status)
number - unique number of friend in list, widget - widget for update
"""
def __init__(self, name, status_message, number, widget): def __init__(self, name, status_message, number, widget):
# TODO: remove number
self._name, self._status_message, self._number = name, status_message, number self._name, self._status_message, self._number = name, status_message, number
self._status, self._widget = None, widget self._status, self._widget = None, widget
widget.name.setText(name) widget.name.setText(name)
@ -81,6 +89,9 @@ class Contact(object):
class Friend(Contact): class Friend(Contact):
"""
Friend in list of friends. Can be hidden, unread messages added
"""
def __init__(self, *args): def __init__(self, *args):
super(Friend, self).__init__(*args) super(Friend, self).__init__(*args)
@ -101,14 +112,17 @@ class Friend(Contact):
class Profile(Contact, Singleton): class Profile(Contact, Singleton):
"""
Profile of current toxygen user. Contains friends list, tox instance
"""
# TODO: add slices
def __init__(self, tox, widgets, widget): def __init__(self, tox, widgets, widget):
self._widget = widget self._widget = widget
self.tox = tox self.tox = tox
data = tox.self_get_friend_list() data = tox.self_get_friend_list()
self.friends, num, self._active_friend = [], 0, -1 self.friends, num, self._active_friend = [], 0, -1
for i in data: for i in data:
name = tox.friend_get_name(i) name = tox.friend_get_name(i) or 'Tox user' # tox.friend_get_public_key(i)
status_message = tox.friend_get_status_message(i) status_message = tox.friend_get_status_message(i)
self.friends.append(Friend(name, status_message, i, widgets[num])) self.friends.append(Friend(name, status_message, i, widgets[num]))
num += 1 num += 1
@ -136,6 +150,11 @@ class Profile(Contact, Singleton):
def tox_factory(data=None, settings=None): def tox_factory(data=None, settings=None):
"""
:param data: user data from .tox file. None = no saved data, create new profile
:param settings: current application settings. None = defaults settings will be used
:return: new tox instance
"""
if settings is None: if settings is None:
settings = Settings.get_default_settings() settings = Settings.get_default_settings()
tox_options = Tox.options_new() tox_options = Tox.options_new()

View File

@ -1,4 +1,5 @@
import os import os
import time
program_version = '0.0.1 (alpha)' program_version = '0.0.1 (alpha)'
@ -21,6 +22,10 @@ def curr_directory():
return os.path.dirname(os.path.realpath(__file__)) return os.path.dirname(os.path.realpath(__file__))
def curr_time():
return time.strftime("%H:%M:")
class Singleton(object): class Singleton(object):
def __new__(cls, *args): def __new__(cls, *args):