Fix PyQt5 animated emotes (#105)

This commit is contained in:
Dpeta 2022-11-19 09:53:22 +01:00
parent 5981a27817
commit 0d5c68075c

View file

@ -348,18 +348,24 @@ class PesterMovie(QtGui.QMovie):
url = text.urls[movie].toString() url = text.urls[movie].toString()
html = str(text.toHtml()) html = str(text.toHtml())
if html.find(url) != -1: if html.find(url) != -1:
try:
# PyQt6
resource_type = QtGui.QTextDocument.ResourceType.ImageResource.value
except AttributeError:
# PyQt5
resource_type = QtGui.QTextDocument.ResourceType.ImageResource
if text.hasTabs: if text.hasTabs:
i = text.tabobject.tabIndices[text.parent().title()] i = text.tabobject.tabIndices[text.parent().title()]
if text.tabobject.tabs.currentIndex() == i: if text.tabobject.tabs.currentIndex() == i:
text.document().addResource( text.document().addResource(
QtGui.QTextDocument.ResourceType.ImageResource.value, resource_type,
text.urls[movie], text.urls[movie],
movie.currentPixmap(), movie.currentPixmap(),
) )
text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth()) text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth())
else: else:
text.document().addResource( text.document().addResource(
QtGui.QTextDocument.ResourceType.ImageResource.value, resource_type,
text.urls[movie], text.urls[movie],
movie.currentPixmap(), movie.currentPixmap(),
) )