tray icon on message

This commit is contained in:
ingvar1995 2016-06-03 13:48:41 +03:00
parent cc8c5f7e99
commit b02e063302
4 changed files with 14 additions and 6 deletions

View file

@ -127,6 +127,7 @@ def friend_message(window, tray):
invoke_in_main_thread(tray_notification, friend.name, message.decode('utf8'), tray, window) invoke_in_main_thread(tray_notification, friend.name, message.decode('utf8'), tray, window)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']: if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['MESSAGE']) sound_notification(SOUND_NOTIFICATION['MESSAGE'])
tray.setIcon(QtGui.QIcon(curr_directory() + '/images/icon_new_messages.png'))
return wrapped return wrapped

View file

@ -129,12 +129,12 @@ class Toxygen(object):
app.installTranslator(translator) app.installTranslator(translator)
app.translator = translator app.translator = translator
self.ms = MainWindow(self.tox, self.reset)
# tray icon # tray icon
self.tray = QtGui.QSystemTrayIcon(QtGui.QIcon(curr_directory() + '/images/icon.png')) self.tray = QtGui.QSystemTrayIcon(QtGui.QIcon(curr_directory() + '/images/icon.png'))
self.tray.setObjectName('tray') self.tray.setObjectName('tray')
self.ms = MainWindow(self.tox, self.reset, self.tray)
class Menu(QtGui.QMenu): class Menu(QtGui.QMenu):
def newStatus(self, status): def newStatus(self, status):
@ -186,6 +186,7 @@ class Toxygen(object):
sub.connect(onl, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(0)) sub.connect(onl, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(0))
sub.connect(away, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(1)) sub.connect(away, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(1))
sub.connect(busy, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(2)) sub.connect(busy, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(2))
self.tray.setContextMenu(m) self.tray.setContextMenu(m)
self.tray.show() self.tray.show()

View file

@ -42,9 +42,10 @@ class MessageArea(QtGui.QPlainTextEdit):
class MainWindow(QtGui.QMainWindow): class MainWindow(QtGui.QMainWindow):
def __init__(self, tox, reset): def __init__(self, tox, reset, tray):
super(MainWindow, self).__init__() super(MainWindow, self).__init__()
self.reset = reset self.reset = reset
self.tray = tray
self.initUI(tox) self.initUI(tox)
def setup_menu(self, MainWindow): def setup_menu(self, MainWindow):
@ -110,6 +111,11 @@ class MainWindow(QtGui.QMainWindow):
def languageChange(self, *args, **kwargs): def languageChange(self, *args, **kwargs):
self.retranslateUi() self.retranslateUi()
def event(self, event):
if event.type() == QtCore.QEvent.WindowActivate:
self.tray.setIcon(QtGui.QIcon(curr_directory() + '/images/icon.png'))
return super(MainWindow, self).event(event)
def retranslateUi(self): def retranslateUi(self):
self.menuPlugins.setTitle(QtGui.QApplication.translate("MainWindow", "Plugins", None, QtGui.QApplication.UnicodeUTF8)) self.menuPlugins.setTitle(QtGui.QApplication.translate("MainWindow", "Plugins", None, QtGui.QApplication.UnicodeUTF8))
self.pluginData.setText(QtGui.QApplication.translate("MainWindow", "List of plugins", None, QtGui.QApplication.UnicodeUTF8)) self.pluginData.setText(QtGui.QApplication.translate("MainWindow", "List of plugins", None, QtGui.QApplication.UnicodeUTF8))

View file

@ -238,7 +238,7 @@ class Friend(Contact):
:param value: new name :param value: new name
""" """
if not self._alias: if not self._alias:
super(self.__class__, self).set_name(value) super(Friend, self).set_name(value)
def set_alias(self, alias): def set_alias(self, alias):
self._alias = bool(alias) self._alias = bool(alias)
@ -341,11 +341,11 @@ class Profile(Contact, Singleton):
self._tox.self_set_status(status) self._tox.self_set_status(status)
def set_name(self, value): def set_name(self, value):
super(self.__class__, self).set_name(value) super(Profile, self).set_name(value)
self._tox.self_set_name(self._name.encode('utf-8')) self._tox.self_set_name(self._name.encode('utf-8'))
def set_status_message(self, value): def set_status_message(self, value):
super(self.__class__, self).set_status_message(value) super(Profile, self).set_status_message(value)
self._tox.self_set_status_message(self._status_message.encode('utf-8')) self._tox.self_set_status_message(self._status_message.encode('utf-8'))
def new_nospam(self): def new_nospam(self):