multiplayer: minor UI fixes

Just two minor fixes:
1. Font color is black in dark theme. It is now only black for pings.
2. If a user is called `abc`, you can ping them by `@abc_`. Now a ping only takes effect when there are spaces around it.
This commit is contained in:
zhupengfei 2019-01-13 22:21:04 +08:00
parent 4f23d5d69e
commit 5f0dcd52ae
No known key found for this signature in database
GPG Key ID: DD129E108BD09378

View File

@ -42,8 +42,12 @@ public:
cur_nickname = QString::fromStdString(room->GetNickname()); cur_nickname = QString::fromStdString(room->GetNickname());
cur_username = QString::fromStdString(room->GetUsername()); cur_username = QString::fromStdString(room->GetUsername());
} }
if (message.contains(QString("@").append(cur_nickname)) ||
(!cur_username.isEmpty() && message.contains(QString("@").append(cur_username)))) { // Handle pings at the beginning and end of message
QString fixed_message = QString(" %1 ").arg(message);
if (fixed_message.contains(QString(" @%1 ").arg(cur_nickname)) ||
(!cur_username.isEmpty() &&
fixed_message.contains(QString(" @%1 ").arg(cur_username)))) {
contains_ping = true; contains_ping = true;
} else { } else {
@ -65,15 +69,18 @@ public:
name = QString("%1 (%2)").arg(nickname, username); name = QString("%1 (%2)").arg(nickname, username);
} }
QString style; QString style, text_color;
if (ContainsPing()) { if (ContainsPing()) {
// Add a background color to these messages // Add a background color to these messages
style = QString("background-color: %1").arg(ping_color); style = QString("background-color: %1").arg(ping_color);
// Add a font color
text_color = "color='#000000'";
} }
return QString("[%1] <font color='%2'>&lt;%3&gt;</font> <font style='%4' " return QString("[%1] <font color='%2'>&lt;%3&gt;</font> <font style='%4' "
"color='#000000'>%5</font>") "%5>%6</font>")
.arg(timestamp, color, name.toHtmlEscaped(), style, message.toHtmlEscaped()); .arg(timestamp, color, name.toHtmlEscaped(), style, text_color,
message.toHtmlEscaped());
} }
private: private: