From: Manuel Nickschas Date: Sat, 9 Feb 2008 21:01:51 +0000 (+0000) Subject: Mark highlighted messages with a subtly different background color. X-Git-Tag: 0.2.0-alpha1~87 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=cab361607b686847ee0df2e605f8f05598b65f99 Mark highlighted messages with a subtly different background color. --- diff --git a/src/common/message.h b/src/common/message.h index 0c9c3d36..77fde33f 100644 --- a/src/common/message.h +++ b/src/common/message.h @@ -50,7 +50,8 @@ public: enum Flags { None = 0, - Self = 1 + Self = 1, + Highlight = 2 }; Q_DECLARE_FLAGS(MessageFlags, Flags) diff --git a/src/qtui/chatline-old.cpp b/src/qtui/chatline-old.cpp index 33b4d9ac..c26da15a 100644 --- a/src/qtui/chatline-old.cpp +++ b/src/qtui/chatline-old.cpp @@ -19,6 +19,8 @@ ***************************************************************************/ #include "chatline-old.h" +#include "client.h" +#include "network.h" #include "qtui.h" //! Construct a ChatLine object from a message. @@ -31,6 +33,7 @@ ChatLine::ChatLine(Message m) { //bufferName = m.buffer.buffer(); msg = m; selectionMode = None; + isHighlight = false; formatMsg(msg); } @@ -39,6 +42,12 @@ ChatLine::~ChatLine() { } void ChatLine::formatMsg(Message msg) { + const Network *net = Client::network(msg.bufferInfo().networkId()); + if(net) { + QRegExp nickRegExp("^(.*\\W)?"+net->myNick()+"(\\W.*)?$"); + if((msg.type() == Message::Plain || msg.type() == Message::Notice || msg.type() == Message::Action) && nickRegExp.exactMatch(msg.text())) + isHighlight = true; + } QTextOption tsOption, senderOption, textOption; styledTimeStamp = QtUi::style()->styleString(msg.formattedTimestamp()); styledSender = QtUi::style()->styleString(msg.formattedSender()); @@ -314,8 +323,15 @@ void ChatLine::draw(QPainter *p, const QPointF &pos) { p->setPen(Qt::NoPen); p->setBrush(pal.brush(QPalette::Highlight)); p->drawRect(QRectF(pos, QSizeF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText() + textWidth, height()))); - } else if(selectionMode == Partial) { + } else { + if(isHighlight) { + p->setPen(Qt::NoPen); + p->setBrush(pal.brush(QPalette::AlternateBase)); + p->drawRect(QRectF(pos, QSizeF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText() + textWidth, height()))); + } + if(selectionMode == Partial) { + } } /* p->setClipRect(QRectF(pos, QSizeF(tsWidth, height()))); tsLayout.draw(p, pos, tsFormat); diff --git a/src/qtui/chatline-old.h b/src/qtui/chatline-old.h index d37bc6a9..c243c954 100644 --- a/src/qtui/chatline-old.h +++ b/src/qtui/chatline-old.h @@ -99,6 +99,7 @@ class ChatLine : public QObject, public AbstractUiMsg { QList lineLayouts; int minHeight; + bool isHighlight; SelectionMode selectionMode; int selectionStart, selectionEnd; void formatMsg(Message);