tray menu #2 + notifications for friend connection status

This commit is contained in:
ingvar1995 2016-04-01 17:38:24 +03:00
parent c3f3f8f24f
commit cea5344e4b
3 changed files with 11 additions and 2 deletions

View file

@ -62,6 +62,8 @@ def friend_status(tox, friend_num, new_status, user_data):
print "Friend's #{} status changed! New status: {}".format(friend_num, new_status) print "Friend's #{} status changed! New status: {}".format(friend_num, new_status)
profile = Profile.get_instance() profile = Profile.get_instance()
friend = profile.get_friend_by_number(friend_num) friend = profile.get_friend_by_number(friend_num)
if friend.status is None and Settings.get_instance()['sound_notifications']:
sound_notification(SOUND_NOTIFICATION['FRIEND_CONNECTION_STATUS'])
invoke_in_main_thread(friend.set_status, new_status) invoke_in_main_thread(friend.set_status, new_status)
invoke_in_main_thread(profile.update_filtration) invoke_in_main_thread(profile.update_filtration)
@ -76,6 +78,8 @@ def friend_connection_status(tox, friend_num, new_status, user_data):
if new_status == TOX_CONNECTION['NONE']: if new_status == TOX_CONNECTION['NONE']:
invoke_in_main_thread(friend.set_status, None) invoke_in_main_thread(friend.set_status, None)
invoke_in_main_thread(profile.update_filtration) invoke_in_main_thread(profile.update_filtration)
if Settings.get_instance()['sound_notifications']:
sound_notification(SOUND_NOTIFICATION['FRIEND_CONNECTION_STATUS'])
elif friend.status is None: elif friend.status is None:
invoke_in_main_thread(profile.send_avatar, friend_num) invoke_in_main_thread(profile.send_avatar, friend_num)

View file

@ -69,7 +69,12 @@ class Toxygen(object):
m = QtGui.QMenu() m = QtGui.QMenu()
show = m.addAction('Open Toxygen') show = m.addAction('Open Toxygen')
exit = m.addAction('Exit') exit = m.addAction('Exit')
m.connect(show, QtCore.SIGNAL("triggered()"), lambda: self.ms.activateWindow())
def show_window():
self.ms.setWindowState(self.ms.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
self.ms.activateWindow()
m.connect(show, QtCore.SIGNAL("triggered()"), show_window)
m.connect(exit, QtCore.SIGNAL("triggered()"), lambda: app.exit()) m.connect(exit, QtCore.SIGNAL("triggered()"), lambda: app.exit())
self.tray.setContextMenu(m) self.tray.setContextMenu(m)
self.tray.show() self.tray.show()

View file

@ -25,7 +25,7 @@ def sound_notification(t):
elif t == SOUND_NOTIFICATION['FILE_TRANSFER']: elif t == SOUND_NOTIFICATION['FILE_TRANSFER']:
f = curr_directory() + '/sounds/file.wav' f = curr_directory() + '/sounds/file.wav'
else: else:
return f = curr_directory() + '/sounds/contact.wav'
m = Phonon.MediaSource(f) m = Phonon.MediaSource(f)
player = Phonon.createPlayer(Phonon.MusicCategory, m) player = Phonon.createPlayer(Phonon.MusicCategory, m)
player.play() player.play()