fix emote buttons on theme reload

This commit is contained in:
cidoku 2025-10-06 21:26:44 -03:00
parent ef34c72c09
commit d8e202bbad
2 changed files with 22 additions and 9 deletions

View File

@ -233,12 +233,12 @@ class EmoteButton(QtGui.QLabel):
return
painter = QtGui.QPainter(self)
painter.setRenderHint(QtGui.QPainter.TextAntialiasing, False)
painter.setPen(QtGui.QColor(255, 255, 255))
font = QtGui.QFont("Tahoma", 8)
font.setStyle(QtGui.QFont.StyleNormal)
font.setWeight(QtGui.QFont.Normal)
painter.setFont(font)
# painter.setRenderHint(QtGui.QPainter.TextAntialiasing, False)
# painter.setPen(QtGui.QColor(255, 255, 255))
# font = QtGui.QFont("Tahoma", 8)
# font.setStyle(QtGui.QFont.StyleNormal)
# font.setWeight(QtGui.QFont.Normal)
# painter.setFont(font)
if self.pixmap():
if self.pixmap().isNull():
@ -250,9 +250,9 @@ class EmoteButton(QtGui.QLabel):
painter.drawPixmap(0, 0, button_img)
else:
painter.drawPixmap(0, 0, self.pixmap())
else:
painter.fillRect(0, 0, 39, 39, QtGui.QColor(0, 0, 0))
painter.drawText(1, 1, str(self.emoteid))
# else:
# painter.fillRect(0, 0, 39, 39, QtGui.QColor(0, 0, 0))
# painter.drawText(1, 1, str(self.emoteid))
def mousePressEvent(self, event):
self.gamewindow.changeEmote(False, self.emoteid)

View File

@ -1483,6 +1483,7 @@ class GUI(QtGui.QWidget):
self.current_emote_page = 0
self.max_emotes_on_page = 0
self.emotebuttons = []
self.prevemotepage = buttons.BackEmoteButton(self)
self.prevemotepage.hide()
self.nextemotepage = buttons.NextEmoteButton(self)
@ -1692,6 +1693,13 @@ class GUI(QtGui.QWidget):
columns = (width - 40) / (spacing + 40) + 1
rows = (height - 40) / (spacing + 40) + 1
self.max_emotes_on_page = columns * rows
if len(self.emotebuttons) > 0:
for button in self.emotebuttons:
button.setParent(None)
button.deleteLater()
button = None
self.emotebuttons = []
for i in range(self.max_emotes_on_page):
@ -1706,6 +1714,7 @@ class GUI(QtGui.QWidget):
button.move(left + x_pos, top + y_pos)
button.clicked.connect(self.icchat_focus)
button.show()
button.lower()
self.emotebuttons.append(button)
self.prevemotepage.raise_()
@ -1714,6 +1723,10 @@ class GUI(QtGui.QWidget):
if switching:
self.setBackground()
self.setScene()
self.emotedropdown.setCurrentIndex(0)
self.set_emote_page()
self.gamewindow.setFixedSize(self.width, self.height)
self.gamewindow.center()
except Exception as e:
QtGui.QMessageBox.critical(None, "Unable to load theme", "There was a problem loading the current theme \"%s\":\n\n%s." % (theme, e))
os._exit(-2)