toxygen/src/notifications.py
2016-03-15 22:12:37 +03:00

30 lines
756 B
Python

from PySide import QtGui
from PySide.phonon import Phonon
from util import curr_directory
# TODO: make app icon active
SOUND_NOTIFICATION = {
'MESSAGE': 0,
'FRIEND_CONNECTION_STATUS': 1,
'FILE_TRANSFER': 2
}
def tray_notification(title, text, tray):
if QtGui.QSystemTrayIcon.isSystemTrayAvailable():
if len(text) > 30:
text = text[:27] + '...'
tray.showMessage(title, text, QtGui.QSystemTrayIcon.NoIcon, 3000)
def sound_notification(t):
# TODO: add other sound notifications
if t == SOUND_NOTIFICATION['MESSAGE']:
f = curr_directory() + '/sounds/message.wav'
else:
return
m = Phonon.MediaSource(f)
player = Phonon.createPlayer(Phonon.MusicCategory, m)
player.play()