mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Sanitize room info for display
This commit is contained in:
parent
69bab127dd
commit
87ecb28558
2 changed files with 17 additions and 13 deletions
|
@ -26,7 +26,7 @@ RoomInfoListItem::RoomInfoListItem(RoomInfo info, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, info_(info)
|
, info_(info)
|
||||||
, is_pressed_(false)
|
, is_pressed_(false)
|
||||||
, max_height_(65)
|
, max_height_(60)
|
||||||
{
|
{
|
||||||
normal_style_ =
|
normal_style_ =
|
||||||
"QWidget { background-color: #5d6565; color: #ebebeb;"
|
"QWidget { background-color: #5d6565; color: #ebebeb;"
|
||||||
|
@ -62,19 +62,18 @@ RoomInfoListItem::RoomInfoListItem(RoomInfo info, QWidget *parent)
|
||||||
|
|
||||||
roomAvatar_ = new Avatar(avatarWidget_);
|
roomAvatar_ = new Avatar(avatarWidget_);
|
||||||
roomAvatar_->setLetter(QChar(info_.name()[0]));
|
roomAvatar_->setLetter(QChar(info_.name()[0]));
|
||||||
|
roomAvatar_->setSize(max_height_ - 20);
|
||||||
avatarLayout_->addWidget(roomAvatar_);
|
avatarLayout_->addWidget(roomAvatar_);
|
||||||
|
|
||||||
roomName_ = new QLabel(textWidget_);
|
roomName_ = new QLabel(info_.name(), textWidget_);
|
||||||
roomName_->setText(info_.name());
|
roomName_->setMaximumSize(parent->width() - 10, 20);
|
||||||
roomName_->setMaximumSize(230, max_height_ / 2);
|
roomName_->setStyleSheet("font-weight: 500; font-size: 14px;");
|
||||||
roomName_->setStyleSheet("font-weight: 500; font-size: 11.5pt");
|
roomName_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
roomName_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
|
||||||
|
|
||||||
roomTopic_ = new QLabel(textWidget_);
|
roomTopic_ = new QLabel(info_.topic(), textWidget_);
|
||||||
roomTopic_->setText(info_.topic());
|
roomTopic_->setMaximumSize(parent->width() - 10, 20);
|
||||||
roomTopic_->setMaximumSize(230, max_height_ / 2);
|
roomTopic_->setStyleSheet("color: #c9c9c9; font-size: 12px");
|
||||||
roomTopic_->setStyleSheet("color: #c9c9c9; font-size: 10pt");
|
roomTopic_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
roomTopic_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
|
||||||
|
|
||||||
textLayout_->addWidget(roomName_);
|
textLayout_->addWidget(roomName_);
|
||||||
textLayout_->addWidget(roomTopic_);
|
textLayout_->addWidget(roomTopic_);
|
||||||
|
@ -82,8 +81,8 @@ RoomInfoListItem::RoomInfoListItem(RoomInfo info, QWidget *parent)
|
||||||
topLayout_->addWidget(avatarWidget_);
|
topLayout_->addWidget(avatarWidget_);
|
||||||
topLayout_->addWidget(textWidget_);
|
topLayout_->addWidget(textWidget_);
|
||||||
|
|
||||||
setElidedText(roomName_, info_.name(), 220);
|
setElidedText(roomName_, info_.name(), parent->width() - 10);
|
||||||
setElidedText(roomTopic_, info_.topic(), 220);
|
setElidedText(roomTopic_, info_.topic(), parent->width() - 10);
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRoundedRect(rect(), 0, 0);
|
path.addRoundedRect(rect(), 0, 0);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
#include "RoomList.h"
|
#include "RoomList.h"
|
||||||
|
@ -65,6 +66,10 @@ RoomInfo RoomList::extractRoomInfo(const State &room_state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sanitize info for print.
|
||||||
|
info.setTopic(info.topic().replace(QRegularExpression("[\\s\\n\\r]+"), " "));
|
||||||
|
info.setName(info.name().replace(QRegularExpression("[\\s\\n\\r]+"), " "));
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue