94 } |
94 } |
95 |
95 |
96 return firstIsShorter; |
96 return firstIsShorter; |
97 } |
97 } |
98 |
98 |
99 const char* HWChatWidget::STYLE = "a {color:white;} a.nick {text-decoration: none;}"; |
99 const char* HWChatWidget::STYLE = |
|
100 "\ |
|
101 a { color:#c8c8ff; }\ |
|
102 .nick { text-decoration: none; }\ |
|
103 .UserChat .nick { color:#ffec20; }\ |
|
104 .FriendChat { color: #08e008; }\ |
|
105 .FriendChat .nick { color: #20ff20; }\ |
|
106 .UserJoin { color: #c0c0c0; }\ |
|
107 .UserJoin .nick { color: #d0d0d0; }\ |
|
108 .FriendJoin { color: #c0e0c0; }\ |
|
109 .FriendJoin .nick { color: #d0f0d0; }\ |
|
110 .UserAction { color: #ff80ff; }\ |
|
111 .UserAction .nick { color: #ffa0ff; }\ |
|
112 .FriendAction { color: #ff00ff; }\ |
|
113 .FriendAction .nick { color: #ff30ff; }\ |
|
114 "; |
100 |
115 |
101 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) : |
116 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) : |
102 QWidget(parent), |
117 QWidget(parent), |
103 mainLayout(this) |
118 mainLayout(this) |
104 { |
119 { |
330 // "link" nick, but before that encode it in base64 to make sure it can't intefere with html/url syntax |
345 // "link" nick, but before that encode it in base64 to make sure it can't intefere with html/url syntax |
331 // the nick is put as querystring as putting it as host would convert it to it's lower case variant |
346 // the nick is put as querystring as putting it as host would convert it to it's lower case variant |
332 if(!nick.isEmpty()) |
347 if(!nick.isEmpty()) |
333 formattedStr.replace("|nick|",QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg(QString(nick.toUtf8().toBase64())).arg(nick)); |
348 formattedStr.replace("|nick|",QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg(QString(nick.toUtf8().toBase64())).arg(nick)); |
334 |
349 |
335 QString color(""); |
350 QString cssClass("UserChat"); |
336 |
351 |
337 // check first character for color code and set color properly |
352 // check first character for color code and set color properly |
338 switch (str[0].toAscii()) { |
353 switch (str[0].toAscii()) { |
339 case 3: |
354 case 3: |
340 color = QString("#c0c0c0"); |
355 cssClass = (isFriend ? "FriendJoin" : "UserJoin"); |
341 break; |
356 break; |
342 case 2: |
357 case 2: |
343 color = QString(isFriend ? "#00ff00" : "#ff00ff"); |
358 cssClass = (isFriend ? "FriendAction" : "UserAction"); |
344 break; |
359 break; |
345 default: |
360 default: |
346 if (isFriend) |
361 if (isFriend) |
347 color = QString("#00c000"); |
362 cssClass = "FriendChat"; |
348 } |
363 } |
349 |
364 |
350 if (!color.isEmpty()) |
365 formattedStr = QString("<span class=\"%2\">%1</span>").arg(formattedStr).arg(cssClass); |
351 formattedStr = QString("<font color=\"%2\">%1</font>").arg(formattedStr).arg(color); |
|
352 |
366 |
353 chatStrings.append(formattedStr); |
367 chatStrings.append(formattedStr); |
354 |
368 |
355 chatText->setHtml(chatStrings.join("<br>")); |
369 chatText->setHtml(chatStrings.join("<br>")); |
356 |
370 |