summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-15 13:03:05 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-15 13:33:17 (GMT)
commitbd4e48adb3f23f80abc8441bf359166fbe9b621c (patch)
tree9141e6e7c68e28e14961491459d5996a1d957067 /Swift
parent22973faaced00f3307efbb8b8fc4e914de7023e8 (diff)
downloadswift-bd4e48adb3f23f80abc8441bf359166fbe9b621c.zip
swift-bd4e48adb3f23f80abc8441bf359166fbe9b621c.tar.bz2
Linkify URLs.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtChatView.cpp6
-rw-r--r--Swift/QtUI/QtChatView.h2
-rw-r--r--Swift/QtUI/QtChatWindow.cpp2
-rw-r--r--Swift/QtUI/SConscript1
4 files changed, 11 insertions, 0 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 0a02591..12f6beb 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -2,6 +2,7 @@
#include <QtDebug>
#include <QFile>
+#include <QDesktopServices>
#include <QVBoxLayout>
#include <QWebView>
#include <QWebFrame>
@@ -18,6 +19,7 @@ QtChatView::QtChatView(QWidget* parent) : QWidget(parent) {
mainLayout->setContentsMargins(0,0,0,0);
webView_ = new QWebView(this);
webView_->setFocusPolicy(Qt::NoFocus);
+ connect(webView_, SIGNAL(linkClicked(const QUrl&)), SLOT(handleLinkClicked(const QUrl&)));
#ifdef Q_WS_X11
/* To give a border on Linux, where it looks bad without */
QStackedWidget* stack = new QStackedWidget(this);
@@ -88,4 +90,8 @@ void QtChatView::scrollToBottom() {
webPage_->mainFrame()->setScrollBarValue(Qt::Vertical, webPage_->mainFrame()->scrollBarMaximum(Qt::Vertical));
}
+void QtChatView::handleLinkClicked(const QUrl& url) {
+ QDesktopServices::openUrl(url);
+}
+
}
diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h
index 2a50129..7340e00 100644
--- a/Swift/QtUI/QtChatView.h
+++ b/Swift/QtUI/QtChatView.h
@@ -8,6 +8,7 @@
class QWebView;
class QWebPage;
+class QUrl;
namespace Swift {
class QtChatView : public QWidget {
@@ -21,6 +22,7 @@ namespace Swift {
public slots:
void copySelectionToClipboard();
void scrollToBottom();
+ void handleLinkClicked(const QUrl&);
private:
QWebView* webView_;
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index fc8dc1e..bebebe8 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -2,6 +2,7 @@
#include "QtSwiftUtil.h"
#include "Roster/QtTreeWidget.h"
#include "Roster/QtTreeWidgetFactory.h"
+#include "SwifTools/Linkify.h"
#include "QtChatView.h"
#include "MessageSnippet.h"
#include "SystemMessageSnippet.h"
@@ -155,6 +156,7 @@ void QtChatWindow::addMessage(const String &message, const String &senderName, b
}
QString messageHTML(Qt::escape(P2QSTRING(message)));
messageHTML.replace("\n","<br/>");
+ messageHTML = P2QSTRING(Linkify::linkify(Q2PSTRING(messageHTML)));
htmlString += messageHTML;
bool appendToPrevious = !previousMessageWasSystem_ && ((senderIsSelf && previousMessageWasSelf_) || (!senderIsSelf && !previousMessageWasSelf_ && previousSenderName_ == P2QSTRING(senderName)));
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index ee1c762..d30f3b9 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -21,6 +21,7 @@ Import("env")
myenv = env.Clone()
myenv.MergeFlags(env["SWIFT_CONTROLLERS_FLAGS"])
+myenv.MergeFlags(env["SWIFTOOLS_FLAGS"])
myenv.MergeFlags(env["SWIFTEN_FLAGS"])
myenv.MergeFlags(env["CPPUNIT_FLAGS"])
myenv.MergeFlags(env["LIBIDN_FLAGS"])