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)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['MESSAGE'])
tray.setIcon(QtGui.QIcon(curr_directory() + '/images/icon_new_messages.png'))
return wrapped

View File

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

View File

@ -42,9 +42,10 @@ class MessageArea(QtGui.QPlainTextEdit):
class MainWindow(QtGui.QMainWindow):
def __init__(self, tox, reset):
def __init__(self, tox, reset, tray):
super(MainWindow, self).__init__()
self.reset = reset
self.tray = tray
self.initUI(tox)
def setup_menu(self, MainWindow):
@ -110,6 +111,11 @@ class MainWindow(QtGui.QMainWindow):
def languageChange(self, *args, **kwargs):
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):
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))

View File

@ -238,7 +238,7 @@ class Friend(Contact):
:param value: new name
"""
if not self._alias:
super(self.__class__, self).set_name(value)
super(Friend, self).set_name(value)
def set_alias(self, alias):
self._alias = bool(alias)
@ -341,11 +341,11 @@ class Profile(Contact, Singleton):
self._tox.self_set_status(status)
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'))
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'))
def new_nospam(self):