notifications #3 + docs update
This commit is contained in:
parent
111d72ceaa
commit
c9fb52e29c
@ -36,8 +36,7 @@ def invoke_in_main_thread(fn, *args, **kwargs):
|
|||||||
|
|
||||||
def self_connection_status(tox_link):
|
def self_connection_status(tox_link):
|
||||||
"""
|
"""
|
||||||
:param tox_link: tox instance
|
Current user changed connection status (offline, UDP, TCP)
|
||||||
:return: function for tox.callback_self_connection_status
|
|
||||||
"""
|
"""
|
||||||
def wrapped(tox, connection, user_data):
|
def wrapped(tox, connection, user_data):
|
||||||
print 'Connection status: ', str(connection)
|
print 'Connection status: ', str(connection)
|
||||||
@ -85,6 +84,9 @@ def friend_connection_status(tox, friend_num, new_status, user_data):
|
|||||||
|
|
||||||
|
|
||||||
def friend_name(tox, friend_num, name, size, user_data):
|
def friend_name(tox, friend_num, name, size, user_data):
|
||||||
|
"""
|
||||||
|
Friend changed his name
|
||||||
|
"""
|
||||||
profile = Profile.get_instance()
|
profile = Profile.get_instance()
|
||||||
friend = profile.get_friend_by_number(friend_num)
|
friend = profile.get_friend_by_number(friend_num)
|
||||||
print 'New name: ', str(friend_num), str(name)
|
print 'New name: ', str(friend_num), str(name)
|
||||||
@ -108,9 +110,7 @@ def friend_status_message(tox, friend_num, status_message, size, user_data):
|
|||||||
|
|
||||||
def friend_message(window, tray):
|
def friend_message(window, tray):
|
||||||
"""
|
"""
|
||||||
:param window: main window
|
New message from friend
|
||||||
:param tray: tray
|
|
||||||
:return: function for tox.callback_friend_message. Adds new message to list
|
|
||||||
"""
|
"""
|
||||||
def wrapped(tox, friend_number, message_type, message, size, user_data):
|
def wrapped(tox, friend_number, message_type, message, size, user_data):
|
||||||
profile = Profile.get_instance()
|
profile = Profile.get_instance()
|
||||||
@ -139,6 +139,9 @@ def friend_request(tox, public_key, message, message_size, user_data):
|
|||||||
|
|
||||||
|
|
||||||
def tox_file_recv(window, tray):
|
def tox_file_recv(window, tray):
|
||||||
|
"""
|
||||||
|
New incoming file
|
||||||
|
"""
|
||||||
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
|
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
|
||||||
profile = Profile.get_instance()
|
profile = Profile.get_instance()
|
||||||
settings = Settings.get_instance()
|
settings = Settings.get_instance()
|
||||||
@ -166,6 +169,9 @@ def tox_file_recv(window, tray):
|
|||||||
|
|
||||||
|
|
||||||
def file_recv_chunk(tox, friend_number, file_number, position, chunk, length, user_data):
|
def file_recv_chunk(tox, friend_number, file_number, position, chunk, length, user_data):
|
||||||
|
"""
|
||||||
|
Incoming chunk
|
||||||
|
"""
|
||||||
invoke_in_main_thread(Profile.get_instance().incoming_chunk,
|
invoke_in_main_thread(Profile.get_instance().incoming_chunk,
|
||||||
friend_number,
|
friend_number,
|
||||||
file_number,
|
file_number,
|
||||||
@ -174,6 +180,9 @@ def file_recv_chunk(tox, friend_number, file_number, position, chunk, length, us
|
|||||||
|
|
||||||
|
|
||||||
def file_chunk_request(tox, friend_number, file_number, position, size, user_data):
|
def file_chunk_request(tox, friend_number, file_number, position, size, user_data):
|
||||||
|
"""
|
||||||
|
Outgoing chunk
|
||||||
|
"""
|
||||||
Profile.get_instance().outgoing_chunk(
|
Profile.get_instance().outgoing_chunk(
|
||||||
friend_number,
|
friend_number,
|
||||||
file_number,
|
file_number,
|
||||||
@ -182,6 +191,9 @@ def file_chunk_request(tox, friend_number, file_number, position, size, user_dat
|
|||||||
|
|
||||||
|
|
||||||
def file_recv_control(tox, friend_number, file_number, file_control, user_data):
|
def file_recv_control(tox, friend_number, file_number, file_control, user_data):
|
||||||
|
"""
|
||||||
|
Friend cancelled, paused or resumed file transfer
|
||||||
|
"""
|
||||||
if file_control == TOX_FILE_CONTROL['CANCEL']:
|
if file_control == TOX_FILE_CONTROL['CANCEL']:
|
||||||
Profile.get_instance().cancel_transfer(friend_number, file_number, True)
|
Profile.get_instance().cancel_transfer(friend_number, file_number, True)
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class ContactItem(QtGui.QWidget):
|
|||||||
self.avatar_label.setGeometry(QtCore.QRect(3, 3, 64, 64))
|
self.avatar_label.setGeometry(QtCore.QRect(3, 3, 64, 64))
|
||||||
self.avatar_label.setScaledContents(True)
|
self.avatar_label.setScaledContents(True)
|
||||||
self.name = DataLabel(self)
|
self.name = DataLabel(self)
|
||||||
self.name.setGeometry(QtCore.QRect(70, 10, 170, 25))
|
self.name.setGeometry(QtCore.QRect(70, 10, 160, 25))
|
||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setFamily("Times New Roman")
|
font.setFamily("Times New Roman")
|
||||||
font.setPointSize(12)
|
font.setPointSize(12)
|
||||||
@ -99,7 +99,7 @@ class ContactItem(QtGui.QWidget):
|
|||||||
self.status_message.setFont(font)
|
self.status_message.setFont(font)
|
||||||
self.status_message.setObjectName("status_message")
|
self.status_message.setObjectName("status_message")
|
||||||
self.connection_status = StatusCircle(self)
|
self.connection_status = StatusCircle(self)
|
||||||
self.connection_status.setGeometry(QtCore.QRect(230, 5, 32, 32))
|
self.connection_status.setGeometry(QtCore.QRect(220, 5, 32, 32))
|
||||||
self.connection_status.setObjectName("connection_status")
|
self.connection_status.setObjectName("connection_status")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from PySide import QtGui, QtCore
|
from PySide import QtGui, QtCore
|
||||||
from PySide.phonon import Phonon
|
from PySide.phonon import Phonon
|
||||||
from util import curr_directory
|
from util import curr_directory
|
||||||
# TODO: make app icon active
|
|
||||||
# TODO: rewrite sound notifications
|
# TODO: rewrite sound notifications
|
||||||
|
|
||||||
|
|
||||||
@ -14,6 +13,8 @@ SOUND_NOTIFICATION = {
|
|||||||
|
|
||||||
def tray_notification(title, text, tray, window):
|
def tray_notification(title, text, tray, window):
|
||||||
"""
|
"""
|
||||||
|
Show tray notification and activate window icon
|
||||||
|
NOTE: different behaviour on different OS
|
||||||
:param title: Name of user who sent message or file
|
:param title: Name of user who sent message or file
|
||||||
:param text: text of message or file info
|
:param text: text of message or file info
|
||||||
:param tray: ref to tray icon
|
:param tray: ref to tray icon
|
||||||
@ -23,6 +24,7 @@ def tray_notification(title, text, tray, window):
|
|||||||
if len(text) > 30:
|
if len(text) > 30:
|
||||||
text = text[:27] + '...'
|
text = text[:27] + '...'
|
||||||
tray.showMessage(title, text, QtGui.QSystemTrayIcon.NoIcon, 3000)
|
tray.showMessage(title, text, QtGui.QSystemTrayIcon.NoIcon, 3000)
|
||||||
|
QtGui.QApplication.alert(window, 0)
|
||||||
|
|
||||||
def message_clicked():
|
def message_clicked():
|
||||||
window.setWindowState(window.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
window.setWindowState(window.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
||||||
@ -31,6 +33,10 @@ def tray_notification(title, text, tray, window):
|
|||||||
|
|
||||||
|
|
||||||
def sound_notification(t):
|
def sound_notification(t):
|
||||||
|
"""
|
||||||
|
Plays sound notification
|
||||||
|
:param t: type of notification
|
||||||
|
"""
|
||||||
if t == SOUND_NOTIFICATION['MESSAGE']:
|
if t == SOUND_NOTIFICATION['MESSAGE']:
|
||||||
f = curr_directory() + '/sounds/message.wav'
|
f = curr_directory() + '/sounds/message.wav'
|
||||||
elif t == SOUND_NOTIFICATION['FILE_TRANSFER']:
|
elif t == SOUND_NOTIFICATION['FILE_TRANSFER']:
|
||||||
|
@ -2,13 +2,6 @@ from src.bootstrap import node_generator
|
|||||||
from src.profile import *
|
from src.profile import *
|
||||||
from src.tox_dns import tox_dns
|
from src.tox_dns import tox_dns
|
||||||
|
|
||||||
class TestSettings():
|
|
||||||
|
|
||||||
def test_creation(self):
|
|
||||||
s = Settings()
|
|
||||||
assert s['ipv6_enabled'] is not None
|
|
||||||
assert s['notifications'] is not None
|
|
||||||
|
|
||||||
|
|
||||||
class TestProfile():
|
class TestProfile():
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user