Fix desktop chat wrapping, character rendering, and unread alerts
This commit is contained in:
@@ -8,6 +8,7 @@ from PyQt6.QtCore import Qt, pyqtSignal
|
||||
class ChatBubble(QWidget):
|
||||
def __init__(self, author, text, time_str, is_self, on_link_clicked):
|
||||
super().__init__()
|
||||
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
layout = QHBoxLayout(self)
|
||||
layout.setContentsMargins(5, 2, 5, 2)
|
||||
|
||||
@@ -39,6 +40,7 @@ class ChatBubble(QWidget):
|
||||
|
||||
# Author
|
||||
author_lbl = QLabel("You" if is_self else author)
|
||||
author_lbl.setTextFormat(Qt.TextFormat.PlainText)
|
||||
author_lbl.setStyleSheet(f"color: {author_color}; font-weight: bold; font-size: 11px; background: transparent;")
|
||||
bubble_layout.addWidget(author_lbl)
|
||||
|
||||
@@ -47,6 +49,7 @@ class ChatBubble(QWidget):
|
||||
# width of 0 lets the label wrap within whatever space the bubble
|
||||
# actually receives rather than expanding the bubble outward.
|
||||
self.text_lbl = QLabel(text)
|
||||
self.text_lbl.setTextFormat(Qt.TextFormat.RichText)
|
||||
self.text_lbl.setWordWrap(True)
|
||||
self.text_lbl.setMinimumWidth(0)
|
||||
self.text_lbl.setSizePolicy(
|
||||
@@ -71,6 +74,14 @@ class ChatBubble(QWidget):
|
||||
layout.addWidget(self.bubble)
|
||||
layout.addStretch()
|
||||
|
||||
def resizeEvent(self, event):
|
||||
super().resizeEvent(event)
|
||||
# Recalculate after the scrollbar or splitter changes the available width.
|
||||
# A fixed row height prevents the scroll layout squeezing wrapped text.
|
||||
height = self.layout().heightForWidth(event.size().width())
|
||||
if height >= 0:
|
||||
self.setFixedHeight(height)
|
||||
|
||||
|
||||
class SystemMessageWidget(QWidget):
|
||||
def __init__(self, text):
|
||||
|
||||
Reference in New Issue
Block a user