void SenderChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(option); Q_UNUSED(widget);
- //painter->setClipRect(boundingRect()); // no idea why QGraphicsItem clipping won't work
+ painter->setClipRect(boundingRect()); // no idea why QGraphicsItem clipping won't work
qreal layoutWidth = layout()->minimumWidth();
qreal offset = 0;
if(chatScene()->senderCutoffMode() == ChatScene::CutoffLeft)
if(layoutWidth > width()) {
// Draw a nice gradient for longer items
// Qt's text drawing with a gradient brush sucks, so we use an alpha-channeled pixmap instead
- QPixmap pixmap(QSize(layout()->boundingRect().width(), layout()->boundingRect().height()));
+ QPixmap pixmap(layout()->boundingRect().toRect().size());
pixmap.fill(Qt::transparent);
QPainter pixPainter(&pixmap);
layout()->draw(&pixPainter, QPointF(qMax(offset, (qreal)0), 0), QVector<QTextLayout::FormatRange>() << selectFmt);
QList<ContentsChatItem::Clickable> ContentsChatItem::findClickables() const {
// For matching URLs
static QString urlEnd("(?:>|[,.;:\"]*\\s|\\b|$)");
- static QString urlChars("(?:[,.;:]*[\\w\\-~@/?&=+$()!%#])");
+ static QString urlChars("(?:[,.;:]*[\\w\\-~@/?&=+$()!%#*|{}\\[\\]])");
static QRegExp regExp[] = {
// URL
case Clickable::Url:
if(!str.contains("://"))
str = "http://" + str;
- QDesktopServices::openUrl(str);
+ QDesktopServices::openUrl(QUrl::fromEncoded(str.toAscii()));
break;
case Clickable::Channel:
// TODO join or whatever...
}
void ContentsChatItem::showWebPreview(const Clickable &click) {
-#ifdef HAVE_WEBKIT
+#ifndef HAVE_WEBKIT
+ Q_UNUSED(click);
+#else
QTextLine line = layout()->lineForTextPosition(click.start);
qreal x = line.cursorToX(click.start);
qreal width = line.cursorToX(click.start + click.length) - x;