X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=c40fd34b96b687fba09b544763c9dbf4580a6226;hb=e10200137c6829b7a0bab2968394d99f3c796290;hp=e255d002c614111f7818e5a456d2e889497758ca;hpb=12fa4e53761a68904512089d5ac368480439be35;p=quassel.git diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index e255d002..c40fd34b 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -426,7 +426,8 @@ qreal ContentsChatItem::setGeometryByWidth(qreal w) { WrapColumnFinder finder(this); while(finder.nextWrapColumn(w) > 0) lines++; - qreal h = lines * fontMetrics()->lineSpacing(); + qreal spacing = qMax(fontMetrics()->lineSpacing(), fontMetrics()->height()); // cope with negative leading() + qreal h = lines * spacing; delete _data; _data = 0; @@ -443,6 +444,7 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const { if(!wrapList.count()) return; // empty chatitem qreal h = 0; + qreal spacing = qMax(fontMetrics()->lineSpacing(), fontMetrics()->height()); // cope with negative leading() WrapColumnFinder finder(this); layout->beginLayout(); forever { @@ -460,7 +462,7 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const { // Sometimes, setNumColumns will create a line that's too long (cf. Qt bug 238249) // We verify this and try setting the width again, making it shorter each time until the lengths match. // Dead fugly, but seems to work… - for(int i = line.textLength()-1; line.textLength() > num; i--) { + for(int i = line.textLength()-1; i >= 0 && line.textLength() > num; i--) { line.setNumColumns(i); } if(num != line.textLength()) { @@ -469,7 +471,7 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const { } line.setPosition(QPointF(0, h)); - h += fontMetrics()->lineSpacing(); + h += spacing; } layout->endLayout(); } @@ -636,9 +638,10 @@ void ContentsChatItem::showWebPreview(const Clickable &click) { QPointF topLeft = scenePos() + QPointF(x, y); QRectF urlRect = QRectF(topLeft.x(), topLeft.y(), width, height); - QString url = data(ChatLineModel::DisplayRole).toString().mid(click.start(), click.length()); - if(!url.contains("://")) - url = "http://" + url; + QString urlstr = data(ChatLineModel::DisplayRole).toString().mid(click.start(), click.length()); + if(!urlstr.contains("://")) + urlstr= "http://" + urlstr; + QUrl url = QUrl::fromEncoded(urlstr.toUtf8(), QUrl::TolerantMode); chatScene()->loadWebPreview(this, url, urlRect); #endif }