From d6eb319df23ce7e4ddf484d9e21620db61d8ad0f Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Wed, 30 Jan 2008 14:34:16 +0000 Subject: [PATCH] hacked (it's really not pretty) the chatwidget to make http:// links klickable and open your default browser --- src/qtui/chatwidget.cpp | 36 ++++++++++++++++++++++++++++++++++-- version.inc | 2 +- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/qtui/chatwidget.cpp b/src/qtui/chatwidget.cpp index ced9b6b1..722f502a 100644 --- a/src/qtui/chatwidget.cpp +++ b/src/qtui/chatwidget.cpp @@ -335,10 +335,42 @@ void ChatWidget::mousePressEvent(QMouseEvent *event) { } } -void ChatWidget::mouseDoubleClickEvent(QMouseEvent * /*event*/) { - +void ChatWidget::mouseDoubleClickEvent(QMouseEvent *event) { + // dirty and fast hack to make http:// urls klickable + if(lines.isEmpty()) + return; + QPoint pos = event->pos() + QPoint(0, verticalScrollBar()->value()); + int x = pos.x(); + int y = pos.y(); + int l = yToLineIdx(y); + if(lines.count() <= l) + return; + + ChatLine *line = lines[l]; + QString text = line->text(); + int cursorAt = qMax(0, line->posToCursor(QPointF(x, y - ycoords[l])) - 1); + + int start = 0; + if(cursorAt > 0) { + for(int i = cursorAt; i > 0; i--) { + if(text[i] == ' ') { + start = i + 1; + break; + } + } + } + int end = text.indexOf(" ", start); + int len = -1; + if(end != -1) { + len = end - start; + } + QString word = text.mid(start, len); + if(word.startsWith("http://")) { + QDesktopServices::openUrl(QUrl(word)); + } + } void ChatWidget::mouseReleaseEvent(QMouseEvent *event) { diff --git a/version.inc b/version.inc index f6ffdee4..84344dfc 100644 --- a/version.inc +++ b/version.inc @@ -5,7 +5,7 @@ quasselVersion = "0.2.0-pre"; quasselDate = "2008-01-30"; - quasselBuild = 411; + quasselBuild = 413; //! Minimum client build number the core needs clientBuildNeeded = 358; -- 2.20.1