X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fqtui%2Fchatwidget.cpp;h=3a04383f14516252068a229a8ee2728d3198e071;hb=923ab935b9e2936d2512ef9344811e9bb2f436f3;hp=ced9b6b11a26cf832150dbe881f89a7a13af43c3;hpb=e7696b65e76e50137b8bab0ec3e43ce66a94f190;p=quassel.git diff --git a/src/qtui/chatwidget.cpp b/src/qtui/chatwidget.cpp index ced9b6b1..3a04383f 100644 --- a/src/qtui/chatwidget.cpp +++ b/src/qtui/chatwidget.cpp @@ -85,6 +85,10 @@ QSize ChatWidget::minimumSizeHint() const { return QSize(20, 20); } +QSize ChatWidget::sizeHint() const { + return QSize(400, 100); +} + // QSize ChatWidget::sizeHint() const { // //qDebug() << size(); // return size(); @@ -335,10 +339,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) {