From cea5344e4ba5e04b65acc5b8fd39114c89e028f0 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Fri, 1 Apr 2016 17:38:24 +0300 Subject: [PATCH] tray menu #2 + notifications for friend connection status --- src/callbacks.py | 4 ++++ src/main.py | 7 ++++++- src/notifications.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index 37a6ab3..c7f7c9a 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -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) profile = Profile.get_instance() 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(profile.update_filtration) @@ -76,6 +78,8 @@ def friend_connection_status(tox, friend_num, new_status, user_data): if new_status == TOX_CONNECTION['NONE']: invoke_in_main_thread(friend.set_status, None) 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: invoke_in_main_thread(profile.send_avatar, friend_num) diff --git a/src/main.py b/src/main.py index 3f896b1..052d06c 100644 --- a/src/main.py +++ b/src/main.py @@ -69,7 +69,12 @@ class Toxygen(object): m = QtGui.QMenu() show = m.addAction('Open Toxygen') 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()) self.tray.setContextMenu(m) self.tray.show() diff --git a/src/notifications.py b/src/notifications.py index b736f0e..21a0679 100644 --- a/src/notifications.py +++ b/src/notifications.py @@ -25,7 +25,7 @@ def sound_notification(t): elif t == SOUND_NOTIFICATION['FILE_TRANSFER']: f = curr_directory() + '/sounds/file.wav' else: - return + f = curr_directory() + '/sounds/contact.wav' m = Phonon.MediaSource(f) player = Phonon.createPlayer(Phonon.MusicCategory, m) player.play()