diff options
Diffstat (limited to 'Swift/QtUI')
| -rw-r--r-- | Swift/QtUI/QtChatView.cpp | 6 | ||||
| -rw-r--r-- | Swift/QtUI/QtChatView.h | 2 | ||||
| -rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 2 | ||||
| -rw-r--r-- | Swift/QtUI/SConscript | 1 |
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 @@ -1,10 +1,11 @@ #include "QtChatView.h" #include <QtDebug> #include <QFile> +#include <QDesktopServices> #include <QVBoxLayout> #include <QWebView> #include <QWebFrame> #include <QKeyEvent> #include <QStackedWidget> @@ -15,12 +16,13 @@ QtChatView::QtChatView(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout(this); mainLayout->setSpacing(0); 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); stack->addWidget(webView_); stack->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); stack->setLineWidth(2); @@ -85,7 +87,11 @@ bool QtChatView::isScrolledToBottom() const { } 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 @@ -5,12 +5,13 @@ #include <QWidget> #include "ChatSnippet.h" class QWebView; class QWebPage; +class QUrl; namespace Swift { class QtChatView : public QWidget { Q_OBJECT public: QtChatView(QWidget* parent); @@ -18,12 +19,13 @@ namespace Swift { void addMessage(const ChatSnippet& snippet); bool isScrolledToBottom() const; public slots: void copySelectionToClipboard(); void scrollToBottom(); + void handleLinkClicked(const QUrl&); private: QWebView* webView_; QWebPage* webPage_; QString previousContinuationElementID_; }; 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 @@ -1,10 +1,11 @@ #include "QtChatWindow.h" #include "QtSwiftUtil.h" #include "Roster/QtTreeWidget.h" #include "Roster/QtTreeWidgetFactory.h" +#include "SwifTools/Linkify.h" #include "QtChatView.h" #include "MessageSnippet.h" #include "SystemMessageSnippet.h" #include "QtTextEdit.h" #include <QApplication> @@ -152,12 +153,13 @@ void QtChatWindow::addMessage(const String &message, const String &senderName, b if (label) { htmlString = QString("<span style=\"border: thin dashed grey; padding-left: .5em; padding-right: .5em; color: %1; background-color: %2; font-size: 90%; margin-right: .5em; \">").arg(Qt::escape(P2QSTRING(label->getForegroundColor()))).arg(Qt::escape(P2QSTRING(label->getBackgroundColor()))); htmlString += QString("%3</span> ").arg(Qt::escape(P2QSTRING(label->getDisplayMarking()))); } 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))); QString qAvatarPath = avatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(P2QSTRING(avatarPath)).toEncoded(); messageLog_->addMessage(MessageSnippet(htmlString, Qt::escape(P2QSTRING(senderName)), QDateTime::currentDateTime(), qAvatarPath, senderIsSelf, appendToPrevious)); diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index ee1c762..d30f3b9 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -18,12 +18,13 @@ def generateDefaultTheme(env, target, source) : 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"]) myenv.MergeFlags(env["BOOST_FLAGS"]) myenv.MergeFlags(env["SQLITE_FLAGS"]) myenv.MergeFlags(env["ZLIB_FLAGS"]) |
Swift