chat patch
This commit is contained in:
parent
e0e6abd453
commit
d845b4b1f4
@ -1,4 +1,4 @@
|
|||||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel
|
from PySide6.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel, QSizePolicy
|
||||||
from PySide6.QtGui import QPixmap, QPainter, QColor, QBrush
|
from PySide6.QtGui import QPixmap, QPainter, QColor, QBrush
|
||||||
from PySide6.QtCore import Qt
|
from PySide6.QtCore import Qt
|
||||||
from app.core.theme import theme_manager
|
from app.core.theme import theme_manager
|
||||||
@ -22,7 +22,7 @@ class ChatListItemWidget(QWidget):
|
|||||||
"""Инициализирует пользовательский интерфейс виджета."""
|
"""Инициализирует пользовательский интерфейс виджета."""
|
||||||
main_layout = QHBoxLayout(self)
|
main_layout = QHBoxLayout(self)
|
||||||
# Reduce right margin to bring unread badge closer to edge
|
# Reduce right margin to bring unread badge closer to edge
|
||||||
main_layout.setContentsMargins(10, 5, 6, 5)
|
main_layout.setContentsMargins(10, 5, 2, 5)
|
||||||
main_layout.setSpacing(10)
|
main_layout.setSpacing(10)
|
||||||
|
|
||||||
# Аватар
|
# Аватар
|
||||||
@ -49,9 +49,16 @@ class ChatListItemWidget(QWidget):
|
|||||||
|
|
||||||
# Delivery/read status icon (left of timestamp)
|
# Delivery/read status icon (left of timestamp)
|
||||||
self.status_label = QLabel("")
|
self.status_label = QLabel("")
|
||||||
self.status_label.setFixedWidth(16)
|
self.status_label.setFixedWidth(12)
|
||||||
|
self.status_label.setFixedHeight(14)
|
||||||
self.status_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
self.status_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||||
|
self.status_label.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.status_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||||
|
|
||||||
self.timestamp_label = QLabel(timestamp)
|
self.timestamp_label = QLabel(timestamp)
|
||||||
|
self.timestamp_label.setFixedHeight(14)
|
||||||
|
self.timestamp_label.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||||
|
self.timestamp_label.setContentsMargins(0, 0, 0, 0)
|
||||||
self.unread_label = QLabel(str(unread_count) if unread_count > 0 else "")
|
self.unread_label = QLabel(str(unread_count) if unread_count > 0 else "")
|
||||||
self.unread_label.setAlignment(Qt.AlignCenter)
|
self.unread_label.setAlignment(Qt.AlignCenter)
|
||||||
self.unread_label.setMargin(0)
|
self.unread_label.setMargin(0)
|
||||||
@ -59,13 +66,14 @@ class ChatListItemWidget(QWidget):
|
|||||||
|
|
||||||
# Put status and time on a single row aligned right
|
# Put status and time on a single row aligned right
|
||||||
time_row = QHBoxLayout()
|
time_row = QHBoxLayout()
|
||||||
time_row.setSpacing(4)
|
time_row.setSpacing(1)
|
||||||
time_row.setContentsMargins(0, 0, 0, 0)
|
time_row.setContentsMargins(0, 0, 0, 0)
|
||||||
time_row.addWidget(self.status_label)
|
time_row.addWidget(self.status_label)
|
||||||
time_row.addWidget(self.timestamp_label)
|
time_row.addWidget(self.timestamp_label)
|
||||||
time_row.addStretch()
|
time_row.addStretch()
|
||||||
meta_layout.addLayout(time_row)
|
meta_layout.addLayout(time_row)
|
||||||
meta_layout.addWidget(self.unread_label)
|
# Keep unread badge pinned to the far right
|
||||||
|
meta_layout.addWidget(self.unread_label, 0, Qt.AlignRight)
|
||||||
meta_layout.addStretch()
|
meta_layout.addStretch()
|
||||||
|
|
||||||
main_layout.addLayout(info_layout)
|
main_layout.addLayout(info_layout)
|
||||||
@ -87,7 +95,7 @@ class ChatListItemWidget(QWidget):
|
|||||||
if getattr(self, 'is_outgoing', False):
|
if getattr(self, 'is_outgoing', False):
|
||||||
if getattr(self, 'is_read', None) is True:
|
if getattr(self, 'is_read', None) is True:
|
||||||
status_color = palette['accent']
|
status_color = palette['accent']
|
||||||
self.status_label.setStyleSheet(f"font-size: 9pt; color: {status_color}; background-color: transparent;")
|
self.status_label.setStyleSheet(f"font-size: 7pt; color: {status_color}; background-color: transparent;")
|
||||||
self._update_status_icon()
|
self._update_status_icon()
|
||||||
|
|
||||||
unread_bg = palette['accent']
|
unread_bg = palette['accent']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user