# HG changeset patch # User sheepluva # Date 1296544501 -3600 # Node ID 8163c9aaad0cc3be843d900734443b32f3fc9ecf # Parent 7a94005874c9d30018d8ba301c1054471a4947bd automatically convert hedgewars.org urls to actual links (in order to make support in the lobby/rooms easier diff -r 7a94005874c9 -r 8163c9aaad0c QTfrontend/chatwidget.cpp --- 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, "\\3"); // "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 diff -r 7a94005874c9 -r 8163c9aaad0c QTfrontend/chatwidget.h --- a/QTfrontend/chatwidget.h Tue Feb 01 07:52:50 2011 +0100 +++ b/QTfrontend/chatwidget.h Tue Feb 01 08:15:01 2011 +0100 @@ -23,6 +23,7 @@ #include #include #include +#include #include "SDLs.h" @@ -66,6 +67,7 @@ void saveList(QStringList & list, const QString & file); void updateNickItem(QListWidgetItem *item); void updateNickItems(); + static const QRegExp URLREGEXP; public slots: void onChatString(const QString& str);