Add unread message markers, uiTickTime setting
This commit is contained in:
parent
7a70dbeaec
commit
c67ad859eb
|
@ -3,6 +3,8 @@
|
||||||
historyFetch = 20
|
historyFetch = 20
|
||||||
; How many messages can be collectively displayed in a conversation?
|
; How many messages can be collectively displayed in a conversation?
|
||||||
maxMessagesListed = 100
|
maxMessagesListed = 100
|
||||||
|
; How often to loop the UI in seconds. Lower values gives less CPU usage, but also a less reponsive UI.
|
||||||
|
uiTickTime = 0.1
|
||||||
|
|
||||||
[messageTracking]
|
[messageTracking]
|
||||||
; Save last message activity time into files? This is used to retrieve messages after experiencing a disconnect or similar. false = disabled, true = enabled
|
; Save last message activity time into files? This is used to retrieve messages after experiencing a disconnect or similar. false = disabled, true = enabled
|
||||||
|
|
|
@ -41,6 +41,8 @@ openGuis = []
|
||||||
guiTasks = []
|
guiTasks = []
|
||||||
ready = False
|
ready = False
|
||||||
online = True
|
online = True
|
||||||
|
unreadChannels = []
|
||||||
|
oldUnreadChannels = []
|
||||||
|
|
||||||
def doNothing():
|
def doNothing():
|
||||||
pass
|
pass
|
||||||
|
@ -61,12 +63,19 @@ def getTitle(text = False):
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def getChannelDisplayName(channel):
|
def getChannelDisplayName(channel):
|
||||||
|
channelName = "Unknown"
|
||||||
if type(channel) == discord.DMChannel:
|
if type(channel) == discord.DMChannel:
|
||||||
return channel.recipient.name + "#" +channel.recipient.discriminator
|
channelName = channel.recipient.name + "#" +channel.recipient.discriminator
|
||||||
elif type(channel) == discord.GroupChannel:
|
elif type(channel) == discord.GroupChannel:
|
||||||
if channel.name:
|
if channel.name:
|
||||||
return "Group: " +channel.name
|
channelName = "Group: " +channel.name
|
||||||
return "Group: [No name]"
|
else:
|
||||||
|
channelName = "Group: [No name]"
|
||||||
|
|
||||||
|
if channel in unreadChannels:
|
||||||
|
channelName = "* " +channelName
|
||||||
|
|
||||||
|
return channelName
|
||||||
|
|
||||||
def playNotificationSound():
|
def playNotificationSound():
|
||||||
if notificationSound: notificationSound.play()
|
if notificationSound: notificationSound.play()
|
||||||
|
@ -75,7 +84,7 @@ class dbfApp:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.app = QApplication(sys.argv)
|
self.app = QApplication(sys.argv)
|
||||||
self.uiTimer = QTimer(self.app)
|
self.uiTimer = QTimer(self.app)
|
||||||
self.uiTimer.setInterval(33)
|
self.uiTimer.setInterval(round(float(config["performance"]["uiTickTime"])*1000))
|
||||||
self.uiTimer.timeout.connect(self.update)
|
self.uiTimer.timeout.connect(self.update)
|
||||||
self.uiTimer.start()
|
self.uiTimer.start()
|
||||||
|
|
||||||
|
@ -89,8 +98,48 @@ class dbfApp:
|
||||||
del openGuis[index]
|
del openGuis[index]
|
||||||
length -= 1
|
length -= 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
if len(unreadChannels) > 0:
|
||||||
|
activeWindow = app.app.activeWindow()
|
||||||
|
if activeWindow != None:
|
||||||
|
index = 0
|
||||||
|
while index < length:
|
||||||
|
gui = openGuis[index]
|
||||||
|
if gui.window == activeWindow:
|
||||||
|
activeWindow = gui
|
||||||
|
break
|
||||||
|
index += 1
|
||||||
|
|
||||||
|
if activeWindow.type == "channel":
|
||||||
|
if activeWindow.channel in unreadChannels:
|
||||||
|
if activeWindow.messageLog.scrollbar.value() == activeWindow.messageLog.scrollbar.maximum():
|
||||||
|
del unreadChannels[unreadChannels.index(activeWindow.channel)]
|
||||||
|
|
||||||
|
index = 0
|
||||||
|
while index < length:
|
||||||
|
gui = openGuis[index]
|
||||||
|
if gui.type == "channel":
|
||||||
|
if gui.channel in unreadChannels:
|
||||||
|
if gui.read == False: index += 1; continue
|
||||||
|
gui.title = getChannelDisplayName(gui.channel)
|
||||||
|
gui.window.setWindowTitle(getTitle(gui.title))
|
||||||
|
gui.read = False
|
||||||
|
else:
|
||||||
|
if gui.read == True: index += 1; continue
|
||||||
|
gui.title = getChannelDisplayName(gui.channel)
|
||||||
|
gui.window.setWindowTitle(getTitle(gui.title))
|
||||||
|
gui.read = True
|
||||||
|
index += 1
|
||||||
|
|
||||||
|
global oldUnreadChannels
|
||||||
|
if oldUnreadChannels != unreadChannels:
|
||||||
|
for gui in openGuis:
|
||||||
|
if gui.type == "channels":
|
||||||
|
gui.repopulateChannels("conversations")
|
||||||
|
oldUnreadChannels = unreadChannels.copy()
|
||||||
|
|
||||||
conditions = []
|
conditions = []
|
||||||
length = len(guiTasks)
|
length = len(guiTasks)
|
||||||
while length > 0:
|
while length > 0:
|
||||||
|
@ -463,6 +512,7 @@ class guiChannel:
|
||||||
self.window.resize(self.width,self.height)
|
self.window.resize(self.width,self.height)
|
||||||
|
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
|
self.read = (not channel in unreadChannels)
|
||||||
self.messages = []
|
self.messages = []
|
||||||
self.pendingMessages = []
|
self.pendingMessages = []
|
||||||
|
|
||||||
|
@ -575,8 +625,12 @@ def discordClient(token):
|
||||||
setLastMessageTime(channel,newTime)
|
setLastMessageTime(channel,newTime)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if newTime == oldTime:
|
||||||
|
return False
|
||||||
|
|
||||||
fetchMsgs = False
|
fetchMsgs = False
|
||||||
guiLock.acquire()
|
guiLock.acquire()
|
||||||
|
if not channel in unreadChannels: unreadChannels.append(channel)
|
||||||
for gui in openGuis:
|
for gui in openGuis:
|
||||||
if gui.type == "channel":
|
if gui.type == "channel":
|
||||||
if channel != gui.channel: continue
|
if channel != gui.channel: continue
|
||||||
|
@ -681,6 +735,7 @@ def discordClient(token):
|
||||||
|
|
||||||
if type(message.channel) in channelFilter:
|
if type(message.channel) in channelFilter:
|
||||||
addGuiTask(None,playNotificationSound,(),{})
|
addGuiTask(None,playNotificationSound,(),{})
|
||||||
|
if not message.channel in unreadChannels: unreadChannels.append(message.channel)
|
||||||
|
|
||||||
for gui in openGuis:
|
for gui in openGuis:
|
||||||
if gui.type == "channels":
|
if gui.type == "channels":
|
||||||
|
@ -693,7 +748,7 @@ def discordClient(token):
|
||||||
addGuiTask(gui,gui.addMessage,(msg,),{})
|
addGuiTask(gui,gui.addMessage,(msg,),{})
|
||||||
guiLock.release()
|
guiLock.release()
|
||||||
|
|
||||||
@tasks.loop(seconds=0.033)
|
@tasks.loop(seconds=float(config["performance"]["uiTickTime"]))
|
||||||
async def guiLoop():
|
async def guiLoop():
|
||||||
guis = []
|
guis = []
|
||||||
guiLock.acquire()
|
guiLock.acquire()
|
||||||
|
|
Loading…
Reference in New Issue