equal
deleted
inserted
replaced
323 void HWChatWidget::onChatString(const QString& str) |
323 void HWChatWidget::onChatString(const QString& str) |
324 { |
324 { |
325 onChatString("", str); |
325 onChatString("", str); |
326 } |
326 } |
327 |
327 |
|
328 const QRegExp HWChatWidget::URLREGEXP = QRegExp("(http://)?(www\\.)?(hedgewars\\.org(/[^ ]*)?)"); |
|
329 |
328 void HWChatWidget::onChatString(const QString& nick, const QString& str) |
330 void HWChatWidget::onChatString(const QString& nick, const QString& str) |
329 { |
331 { |
330 bool isFriend = false; |
332 bool isFriend = false; |
331 |
333 |
332 if (!nick.isEmpty()) { |
334 if (!nick.isEmpty()) { |
339 |
341 |
340 if (chatStrings.size() > 250) |
342 if (chatStrings.size() > 250) |
341 chatStrings.removeFirst(); |
343 chatStrings.removeFirst(); |
342 |
344 |
343 QString formattedStr = Qt::escape(str.mid(1)); |
345 QString formattedStr = Qt::escape(str.mid(1)); |
|
346 // make hedgewars.org urls actual links |
|
347 formattedStr = formattedStr.replace(URLREGEXP, "<a href=\"http://\\3\">\\3</a>"); |
344 |
348 |
345 // "link" nick, but before that encode it in base64 to make sure it can't intefere with html/url syntax |
349 // "link" nick, but before that encode it in base64 to make sure it can't intefere with html/url syntax |
346 // the nick is put as querystring as putting it as host would convert it to it's lower case variant |
350 // the nick is put as querystring as putting it as host would convert it to it's lower case variant |
347 if(!nick.isEmpty()) |
351 if(!nick.isEmpty()) |
348 formattedStr.replace("|nick|",QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg(QString(nick.toUtf8().toBase64())).arg(nick)); |
352 formattedStr.replace("|nick|",QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg(QString(nick.toUtf8().toBase64())).arg(nick)); |