Add unread message markers, uiTickTime setting
This commit is contained in:
parent
7a70dbeaec
commit
c67ad859eb
|
@ -3,6 +3,8 @@
|
|||
historyFetch = 20
|
||||
; How many messages can be collectively displayed in a conversation?
|
||||
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]
|
||||
; 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 = []
|
||||
ready = False
|
||||
online = True
|
||||
unreadChannels = []
|
||||
oldUnreadChannels = []
|
||||
|
||||
def doNothing():
|
||||
pass
|
||||
|
@ -61,12 +63,19 @@ def getTitle(text = False):
|
|||
return title
|
||||
|
||||
def getChannelDisplayName(channel):
|
||||
channelName = "Unknown"
|
||||
if type(channel) == discord.DMChannel:
|
||||
return channel.recipient.name + "#" +channel.recipient.discriminator
|
||||
channelName = channel.recipient.name + "#" +channel.recipient.discriminator
|
||||
elif type(channel) == discord.GroupChannel:
|
||||
if channel.name:
|
||||
return "Group: " +channel.name
|
||||
return "Group: [No name]"
|
||||
channelName = "Group: " +channel.name
|
||||
else:
|
||||
channelName = "Group: [No name]"
|
||||
|
||||
if channel in unreadChannels:
|
||||
channelName = "* " +channelName
|
||||
|
||||
return channelName
|
||||
|
||||
def playNotificationSound():
|
||||
if notificationSound: notificationSound.play()
|
||||
|
@ -75,7 +84,7 @@ class dbfApp:
|
|||
def __init__(self):
|
||||
self.app = QApplication(sys.argv)
|
||||
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.start()
|
||||
|
||||
|
@ -89,8 +98,48 @@ class dbfApp:
|
|||
del openGuis[index]
|
||||
length -= 1
|
||||
continue
|
||||
|
||||
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 = []
|
||||
length = len(guiTasks)
|
||||
while length > 0:
|
||||
|
@ -463,6 +512,7 @@ class guiChannel:
|
|||
self.window.resize(self.width,self.height)
|
||||
|
||||
self.channel = channel
|
||||
self.read = (not channel in unreadChannels)
|
||||
self.messages = []
|
||||
self.pendingMessages = []
|
||||
|
||||
|
@ -575,8 +625,12 @@ def discordClient(token):
|
|||
setLastMessageTime(channel,newTime)
|
||||
return False
|
||||
|
||||
if newTime == oldTime:
|
||||
return False
|
||||
|
||||
fetchMsgs = False
|
||||
guiLock.acquire()
|
||||
if not channel in unreadChannels: unreadChannels.append(channel)
|
||||
for gui in openGuis:
|
||||
if gui.type == "channel":
|
||||
if channel != gui.channel: continue
|
||||
|
@ -681,6 +735,7 @@ def discordClient(token):
|
|||
|
||||
if type(message.channel) in channelFilter:
|
||||
addGuiTask(None,playNotificationSound,(),{})
|
||||
if not message.channel in unreadChannels: unreadChannels.append(message.channel)
|
||||
|
||||
for gui in openGuis:
|
||||
if gui.type == "channels":
|
||||
|
@ -693,7 +748,7 @@ def discordClient(token):
|
|||
addGuiTask(gui,gui.addMessage,(msg,),{})
|
||||
guiLock.release()
|
||||
|
||||
@tasks.loop(seconds=0.033)
|
||||
@tasks.loop(seconds=float(config["performance"]["uiTickTime"]))
|
||||
async def guiLoop():
|
||||
guis = []
|
||||
guiLock.acquire()
|
||||
|
|
Loading…
Reference in New Issue