Fixed notification muting. It now highlights the tab (and tray icon) properly.

This commit is contained in:
karxi 2016-12-03 00:29:26 -05:00
parent 61bd147b06
commit 8336efbab7

View file

@ -134,6 +134,7 @@ class PesterTabWindow(QtGui.QFrame):
self.tabs.setTabTextColor(i, QtGui.QColor(self.mainwindow.theme["%s/tabs/newmsgcolor" % (self.type)])) self.tabs.setTabTextColor(i, QtGui.QColor(self.mainwindow.theme["%s/tabs/newmsgcolor" % (self.type)]))
convo = self.convos[handle] convo = self.convos[handle]
# Create a function for the icon to use # Create a function for the icon to use
# TODO: Let us disable this.
def func(): def func():
convo.showChat() convo.showChat()
self.mainwindow.waitingMessages.addMessage(handle, func) self.mainwindow.waitingMessages.addMessage(handle, func)
@ -667,6 +668,9 @@ class PesterConvo(QtGui.QFrame):
self.textArea.addMessage(lexmsg, chum) self.textArea.addMessage(lexmsg, chum)
def notifyNewMessage(self): def notifyNewMessage(self):
# Our imports have to be here to prevent circular import issues.
from memos import PesterMemo, MemoTabWindow
# first see if this conversation HASS the focus # first see if this conversation HASS the focus
title = self.title() title = self.title()
parent = self.parent() parent = self.parent()
@ -686,15 +690,21 @@ class PesterConvo(QtGui.QFrame):
(parent and parent.convoHasFocus(title))): (parent and parent.convoHasFocus(title))):
# ok if it has a tabconvo parent, send that the notify. # ok if it has a tabconvo parent, send that the notify.
if parent: if parent:
# Just let the icon highlight normally.
# This function *also* highlights the tab, mind.
parent.notifyNewMessage(title)
if not mutednots: if not mutednots:
# Stop the icon from highlighting # Remember that these two are descended from one another.
parent.notifyNewMessage(title) # TODO: Make these obey subclassing rules...ugh.
if type(parent).__name__ == "PesterTabWindow": # They should really just use the class's function and do
if self.always_flash or pesterblink: # the checks there.
self.mainwindow.gainAttention.emit(parent) # PesterTabWindow -> MemoTabWindow
elif type(parent).__name__ == "MemoTabWindow": if isinstance(parent, MemoTabWindow):
if self.always_flash or memoblink: if self.always_flash or memoblink:
self.mainwindow.gainAttention.emit(parent) self.mainwindow.gainAttention.emit(parent)
elif isinstance(parent, PesterTabWindow):
if self.always_flash or pesterblink:
self.mainwindow.gainAttention.emit(parent)
# if not change the window title and update system tray # if not change the window title and update system tray
else: else:
self.newmessage = True self.newmessage = True
@ -704,13 +714,14 @@ class PesterConvo(QtGui.QFrame):
def func(): def func():
self.showChat() self.showChat()
self.mainwindow.waitingMessages.addMessage(title, func) self.mainwindow.waitingMessages.addMessage(title, func)
if not self.notifications_muted: if not mutednots:
if type(self).__name__ == "PesterConvo": # Once again, PesterMemo inherits from PesterConvo.
if self.always_flash or pesterblink: if isinstance(self, PesterMemo):
self.mainwindow.gainAttention.emit(self)
elif type(self).__name__ == "PesterMemo":
if self.always_flash or memoblink: if self.always_flash or memoblink:
self.mainwindow.gainAttention.emit(self) self.mainwindow.gainAttention.emit(self)
elif isinstance(self, PesterConvo):
if self.always_flash or pesterblink:
self.mainwindow.gainAttention.emit(self)
def clearNewMessage(self): def clearNewMessage(self):
if self.parent(): if self.parent():