Fix emoji in new RoomList

This commit is contained in:
Nicolas Werner 2021-05-22 10:16:42 +02:00
parent beeb60e4a1
commit f3d956aebc
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
6 changed files with 17 additions and 2 deletions

View File

@ -13,7 +13,7 @@ Label {
property alias elideWidth: metrics.elideWidth
color: Nheko.colors.text
text: metrics.elidedText
text: (textFormat == Text.PlainText) ? metrics.elidedText : TimelineManager.escapeEmoji(TimelineManager.htmlEscape(metrics.elidedText))
maximumLineCount: 1
elide: Text.ElideRight
textFormat: Text.PlainText

View File

@ -119,6 +119,7 @@ Page {
color: roomItem.importantText
elideWidth: textContent.width - timestamp.width - Nheko.paddingMedium
fullText: model.roomName
textFormat: Text.RichText
}
Item {
@ -146,6 +147,7 @@ Page {
font.pixelSize: fontMetrics.font.pixelSize * 0.9
elideWidth: textContent.width - (notificationBubble.visible ? notificationBubble.width : 0) - Nheko.paddingSmall
fullText: model.lastMessage
textFormat: Text.RichText
}
Item {

View File

@ -62,7 +62,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const
case Roles::AvatarUrl:
return room->roomAvatarUrl();
case Roles::RoomName:
return room->roomName();
return room->plainRoomName();
case Roles::RoomId:
return room->roomId();
case Roles::LastMessage:

View File

@ -1890,6 +1890,17 @@ TimelineModel::roomName() const
QString::fromStdString(info[room_id_].name).toHtmlEscaped());
}
QString
TimelineModel::plainRoomName() const
{
auto info = cache::getRoomInfo({room_id_.toStdString()});
if (!info.count(room_id_))
return "";
else
return QString::fromStdString(info[room_id_].name);
}
QString
TimelineModel::roomAvatarUrl() const
{

View File

@ -307,6 +307,7 @@ public slots:
}
QString roomName() const;
QString plainRoomName() const;
QString roomTopic() const;
InputBar *input() { return &input_; }
Permissions *permissions() { return &permissions_; }

View File

@ -67,6 +67,7 @@ public:
Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId);
Q_INVOKABLE QColor userColor(QString id, QColor background);
Q_INVOKABLE QString escapeEmoji(QString str) const;
Q_INVOKABLE QString htmlEscape(QString str) const { return str.toHtmlEscaped(); }
Q_INVOKABLE QString userPresence(QString id) const;
Q_INVOKABLE QString userStatus(QString id) const;