From 5f0dcd52aef71739972a17777a336abd8b401a8c Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Sun, 13 Jan 2019 22:21:04 +0800 Subject: [PATCH] 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. --- src/citra_qt/multiplayer/chat_room.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/citra_qt/multiplayer/chat_room.cpp b/src/citra_qt/multiplayer/chat_room.cpp index 47eb2da2cf..440d9ce82e 100644 --- a/src/citra_qt/multiplayer/chat_room.cpp +++ b/src/citra_qt/multiplayer/chat_room.cpp @@ -42,8 +42,12 @@ public: cur_nickname = QString::fromStdString(room->GetNickname()); 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; } else { @@ -65,15 +69,18 @@ public: name = QString("%1 (%2)").arg(nickname, username); } - QString style; + QString style, text_color; if (ContainsPing()) { // Add a background color to these messages style = QString("background-color: %1").arg(ping_color); + // Add a font color + text_color = "color='#000000'"; } return QString("[%1] <%3> %5") - .arg(timestamp, color, name.toHtmlEscaped(), style, message.toHtmlEscaped()); + "%5>%6") + .arg(timestamp, color, name.toHtmlEscaped(), style, text_color, + message.toHtmlEscaped()); } private: