QTfrontend/chatwidget.cpp
changeset 4899 8163c9aaad0c
parent 4898 7a94005874c9
child 4917 8ff92bdc9f98
--- a/QTfrontend/chatwidget.cpp	Tue Feb 01 07:52:50 2011 +0100
+++ b/QTfrontend/chatwidget.cpp	Tue Feb 01 08:15:01 2011 +0100
@@ -325,6 +325,8 @@
     onChatString("", str);
 }
 
+const QRegExp HWChatWidget::URLREGEXP = QRegExp("(http://)?(www\\.)?(hedgewars\\.org(/[^ ]*)?)");
+
 void HWChatWidget::onChatString(const QString& nick, const QString& str)
 {
     bool isFriend = false;
@@ -341,6 +343,8 @@
         chatStrings.removeFirst();
 
     QString formattedStr = Qt::escape(str.mid(1));
+    // make hedgewars.org urls actual links
+    formattedStr = formattedStr.replace(URLREGEXP, "<a href=\"http://\\3\">\\3</a>");
 
     // "link" nick, but before that encode it in base64 to make sure it can't intefere with html/url syntax
     // the nick is put as querystring as putting it as host would convert it to it's lower case variant