X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftopiclabel.cpp;h=2bcd740bb7cb87747bd90a9eac1c58d6ed255f66;hp=1e1e1da42fc4062f5d85a2940e1d07da5e0744c8;hb=55049803e1f4215cedaa30935eae4ca2aa5835d2;hpb=92789e6323ca73383a7954d834ecfc093234f5e2 diff --git a/src/qtui/topiclabel.cpp b/src/qtui/topiclabel.cpp index 1e1e1da4..2bcd740b 100644 --- a/src/qtui/topiclabel.cpp +++ b/src/qtui/topiclabel.cpp @@ -31,6 +31,7 @@ #include #include "qtui.h" +#include "qtuistyle.h" #include "message.h" TopicLabel::TopicLabel(QWidget *parent) @@ -48,17 +49,17 @@ void TopicLabel::paintEvent(QPaintEvent *event) { Q_UNUSED(event); textPartOffset.clear(); - + QPainter painter(this); painter.setBackgroundMode(Qt::OpaqueMode); - // FIXME re-enable topic painting - /* + // FIXME use QTextLayout instead + QRect drawRect = rect().adjusted(offset, 0, 0, 0); QRect brect; QString textPart; - foreach(QTextLayout::FormatRange fr, styledContents.formatList) { - textPart = styledContents.plainText.mid(fr.start, fr.length); + foreach(QTextLayout::FormatRange fr, formatList) { + textPart = plainText.mid(fr.start, fr.length); textPartOffset << drawRect.left(); painter.setFont(fr.format.font()); painter.setPen(QPen(fr.format.foreground(), 0)); @@ -67,7 +68,6 @@ void TopicLabel::paintEvent(QPaintEvent *event) { drawRect.setLeft(brect.right()); } textWidth = brect.right(); - */ } void TopicLabel::setText(const QString &text) { @@ -78,19 +78,19 @@ void TopicLabel::setText(const QString &text) { offset = 0; update(); - /* FIXME SPUTDEV reenable - styledContents = QtUi::style()->styleString(Message::mircToInternal(text)); + UiStyle::StyledString styledContents = QtUi::style()->styleString(QtUi::style()->mircToInternal(text), UiStyle::PlainMsg); + plainText = styledContents.plainText; + formatList = QtUi::style()->toTextLayoutList(styledContents.formatList, plainText.length(), 0); int height = 1; - foreach(QTextLayout::FormatRange fr, styledContents.formatList) { + foreach(QTextLayout::FormatRange fr, formatList) { height = qMax(height, QFontMetrics(fr.format.font()).height()); } // ensure the label is editable (height != 1) if there is no text to show if(text.isEmpty()) height = QFontMetrics(qApp->font()).height(); - + // setFixedHeight(height); - */ // show topic in tooltip } @@ -127,7 +127,6 @@ void TopicLabel::mouseReleaseEvent(QMouseEvent *event) { } void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) { - /* FIXME SPUTDEV reenable event->accept(); if(textPartOffset.isEmpty()) return; @@ -144,11 +143,11 @@ void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) { int textOffset = textPartOffset[textPart]; // we've Identified the needed text part \o/ - QString text = styledContents.plainText.mid(styledContents.formatList[textPart].start, styledContents.formatList[textPart].length); + QString text = plainText.mid(formatList[textPart].start, formatList[textPart].length); // now we have to find the the left and right word delimiters of the clicked word - QFontMetrics fontMetric(styledContents.formatList[textPart].format.font()); - + QFontMetrics fontMetric(formatList[textPart].format.font()); + int start = 0; int spacePos = text.indexOf(" "); x -= offset; // offset needs to go here as it's already in the textOffset @@ -171,6 +170,4 @@ void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) { if(regex.indexIn(word) != -1) { QDesktopServices::openUrl(QUrl(word)); } - */ - }