1
0
forked from blue/squawk

some visual tweaks, moving on message delivery statuses

This commit is contained in:
Blue 2020-02-04 18:14:51 +03:00
parent a4136ff9fe
commit ed56cca2e7
7 changed files with 62 additions and 20 deletions

View File

@ -107,6 +107,10 @@ static const std::deque<QString> subscriptionStateNames = {"None", "From", "To",
static const std::deque<QString> affiliationNames = {"Unspecified", "Outcast", "Nobody", "Member", "Admin", "Owner"};
static const std::deque<QString> roleNames = {"Unspecified", "Nobody", "Visitor", "Participant", "Moderator"};
static const std::deque<QString> messageStateNames = {"Pending", "Sent", "Delivered", "Error"};
static const std::deque<QString> messageStateThemeIcons = {"state-offline", "state-sync", "state-ok", "state-error"};
QString generateUUID();
static const std::vector<QColor> colorPalette = {

View File

@ -298,6 +298,18 @@
<source>Other</source>
<translation>Другой</translation>
</message>
<message>
<source>Pending</source>
<translation>В процессе</translation>
</message>
<message>
<source>Sent</source>
<translation>Отправлено</translation>
</message>
<message>
<source>Delivered</source>
<translation>Доставлено</translation>
</message>
</context>
<context>
<name>JoinConference</name>

View File

@ -36,10 +36,12 @@ const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])("
const QRegularExpression imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
Message::Message(const Shared::Message& source, bool outgoing, const QString& p_sender, const QString& avatarPath, QWidget* parent):
QHBoxLayout(parent),
QWidget(parent),
msg(source),
body(new QWidget()),
statusBar(new QWidget()),
bodyLayout(new QVBoxLayout(body)),
layout(new QHBoxLayout(this)),
date(new QLabel(msg.getTime().toLocalTime().toString())),
sender(new QLabel(p_sender)),
text(new QLabel()),
@ -54,15 +56,17 @@ Message::Message(const Shared::Message& source, bool outgoing, const QString& p_
hasFile(false),
commentAdded(false)
{
setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(10, 5, 10, 5);
body->setBackgroundRole(QPalette::AlternateBase);
body->setAutoFillBackground(true);
QString bd = msg.getBody();
//bd.replace(imgReg, "<img src=\"\\1\"/>");
bd.replace(urlReg, "<a href=\"\\1\">\\1</a>");
bd.replace("\n", "<br>");
//bd.replace("\n", "<br>");
text->setTextFormat(Qt::RichText);
text->setText(bd);;
text->setText("<p style=\"white-space: pre-wrap;\">" + bd + "</p>");;
text->setTextInteractionFlags(text->textInteractionFlags() | Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
text->setWordWrap(true);
text->setOpenExternalLinks(true);
@ -81,7 +85,6 @@ Message::Message(const Shared::Message& source, bool outgoing, const QString& p_
bodyLayout->addWidget(sender);
bodyLayout->addWidget(text);
bodyLayout->addWidget(date);
shadow->setBlurRadius(10);
shadow->setXOffset(1);
@ -90,22 +93,33 @@ Message::Message(const Shared::Message& source, bool outgoing, const QString& p_
body->setGraphicsEffect(shadow);
avatar->setMaximumHeight(60);
avatar->setMaximumWidth(60);
QVBoxLayout* aLay = new QVBoxLayout();
aLay->addWidget(avatar);
aLay->addStretch();
statusBar->setContentsMargins(0, 0, 0, 0);
QHBoxLayout* statusLay = new QHBoxLayout();
statusLay->setContentsMargins(0, 0, 0, 0);
statusBar->setLayout(statusLay);
if (outgoing) {
sender->setAlignment(Qt::AlignRight);
date->setAlignment(Qt::AlignRight);
addStretch();
addWidget(body);
addItem(aLay);
QIcon q(Shared::icon(Shared::messageStateThemeIcons[static_cast<uint8_t>(source.getState())]));
QLabel* statusIcon = new QLabel();
statusIcon->setToolTip(QCoreApplication::translate("Global", Shared::messageStateNames[static_cast<uint8_t>(source.getState())].toLatin1()));
statusIcon->setPixmap(q.pixmap(12, 12));
statusLay->addWidget(statusIcon);
statusLay->addWidget(date);
layout->addStretch();
layout->addWidget(body);
layout->addWidget(avatar);
} else {
addItem(aLay);
addWidget(body);
addStretch();
layout->addWidget(avatar);
layout->addWidget(body);
layout->addStretch();
statusLay->addWidget(date);
}
bodyLayout->addWidget(statusBar);
layout->setAlignment(avatar, Qt::AlignTop);
}
Message::~Message()

View File

@ -37,7 +37,7 @@
/**
* @todo write docs
*/
class Message : public QHBoxLayout
class Message : public QWidget
{
Q_OBJECT
public:
@ -62,7 +62,9 @@ signals:
private:
Shared::Message msg;
QWidget* body;
QWidget* statusBar;
QVBoxLayout* bodyLayout;
QHBoxLayout* layout;
QLabel* date;
QLabel* sender;
QLabel* text;

View File

@ -38,7 +38,10 @@ MessageLine::MessageLine(bool p_room, QWidget* parent):
busyShown(false),
progress()
{
setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(0, 0, 0, 0);
setBackgroundRole(QPalette::Base);
layout->setSpacing(0);
layout->addStretch();
}
@ -145,9 +148,9 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg, bool forc
if (res == end) {
layout->addLayout(message);
layout->addWidget(message);
} else {
layout->insertLayout(index, message);
layout->insertWidget(index + 1, message);
}
if (msg.hasOutOfBandUrl()) {

View File

@ -46,7 +46,8 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
scroll(down),
manualSliderChange(false),
requestingHistory(false),
everShown(false)
everShown(false),
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1)
{
m_ui->setupUi(this);
@ -77,8 +78,12 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
QScrollBar* vs = m_ui->scrollArea->verticalScrollBar();
m_ui->scrollArea->setWidget(line);
vs->installEventFilter(&vis);
if (!tsb) {
vs->setBackgroundRole(QPalette::Base);
vs->setAutoFillBackground(true);
}
connect(vs, &QScrollBar::valueChanged, this, &Conversation::onSliderValueChanged);
m_ui->scrollArea->installEventFilter(&scrollResizeCatcher);
m_ui->filesPanel->installEventFilter(&attachResizeCatcher);
@ -313,8 +318,9 @@ void Conversation::onScrollResize()
if (everShown) {
int size = m_ui->scrollArea->width();
QScrollBar* bar = m_ui->scrollArea->verticalScrollBar();
if (bar->isVisible()) {
if (bar->isVisible() && !tsb) {
size -= bar->width();
}
line->setMaximumWidth(size);
}

View File

@ -135,6 +135,7 @@ protected:
bool manualSliderChange;
bool requestingHistory;
bool everShown;
bool tsb; //transient scroll bars
};
#endif // CONVERSATION_H