Simplify the inserting and processing of messages.

Message widgets are now inserted into the listView through the `rowsInserted` callback of the messages model.

Messages are processed in the GetMessagesTask and GetApplicationMessagesTask when fetching multiple new messages. Single new incoming messages are processed in ProcessMessageTask.
This commit is contained in:
dries.k
2023-05-13 18:13:21 +02:00
parent bc221d6c8f
commit 7d47c79898
7 changed files with 105 additions and 151 deletions

View File

@@ -23,9 +23,9 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
app: QtWidgets.QApplication,
parent: QtWidgets.QWidget,
message_item: MessagesModelItem,
image_path: str = "",
icon: QtGui.QIcon = None,
):
super(MessageWidget, self).__init__()
super(MessageWidget, self).__init__(parent)
self.app = app
self.parent = parent
self.setupUi(self)
@@ -59,15 +59,9 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
self.label_message.setText(convert_links(message.message))
# Show the application icon
if image_path:
if icon:
image_size = settings.value("MessageWidget/image/size", type=int)
self.label_image.setFixedSize(QtCore.QSize(image_size, image_size))
pixmap = QtGui.QPixmap(image_path).scaled(
image_size,
image_size,
aspectRatioMode=QtCore.Qt.AspectRatioMode.KeepAspectRatioByExpanding,
transformMode=QtCore.Qt.TransformationMode.SmoothTransformation,
)
pixmap = icon.pixmap(QtCore.QSize(image_size, image_size))
self.label_image.setPixmap(pixmap)
else:
self.label_image.hide()