From: Marcus Eggenberger Date: Mon, 11 Jun 2007 14:09:25 +0000 (+0000) Subject: Implemented a basic notification system to show activity in the networkviews X-Git-Tag: 0.1.0~216 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=6f8bb3747b3b7a4cc07a3bb9717e1222850adcfa Implemented a basic notification system to show activity in the networkviews --- diff --git a/gui/mainwin.cpp b/gui/mainwin.cpp index d90abf91..ce57a997 100644 --- a/gui/mainwin.cpp +++ b/gui/mainwin.cpp @@ -172,6 +172,7 @@ void MainWin::setupViews() { void MainWin::registerNetView(NetworkView *view) { connect(this, SIGNAL(bufferSelected(Buffer *)), view, SLOT(selectBuffer(Buffer *))); connect(this, SIGNAL(bufferUpdated(Buffer *)), view, SLOT(bufferUpdated(Buffer *))); + connect(this, SIGNAL(bufferActivity(uint, Buffer *)), view, SLOT(bufferActivity(uint, Buffer *))); connect(this, SIGNAL(bufferDestroyed(Buffer *)), view, SLOT(bufferDestroyed(Buffer *))); connect(view, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *))); view->setBuffers(buffers.values()); @@ -305,6 +306,16 @@ void MainWin::recvMessage(Message msg) { } */ Buffer *b = getBuffer(msg.buffer); + + uint level = NetworkView::OtherActivity; + if(msg.type == Message::Plain or msg.type == Message::Notice){ + level |= NetworkView::NewMessage; + } + if(msg.flags & Message::Highlight){ + level |= NetworkView::Highlight; + } + + emit bufferActivity(level, b); //b->displayMsg(msg); b->appendChatLine(new ChatLine(msg)); } diff --git a/gui/mainwin.h b/gui/mainwin.h index 06a12fee..8d9aeea8 100644 --- a/gui/mainwin.h +++ b/gui/mainwin.h @@ -59,6 +59,7 @@ class MainWin : public QMainWindow { void sendInput(BufferId, QString message); void bufferSelected(Buffer *); void bufferUpdated(Buffer *); + void bufferActivity(uint, Buffer *); void bufferDestroyed(Buffer *); void backlogReceived(Buffer *, QList); void requestBacklog(BufferId, QVariant, QVariant); diff --git a/gui/networkview.cpp b/gui/networkview.cpp index 86a83767..6664758e 100644 --- a/gui/networkview.cpp +++ b/gui/networkview.cpp @@ -114,6 +114,31 @@ void NetworkView::bufferUpdated(Buffer *b) { } } +void NetworkView::bufferActivity(uint level, Buffer *b) { + QColor c; + if(bufitems.contains(b) and b != currentBuffer) { + if(level & Highlight) { + c = QColor(Qt::red); + } else if(level & NewMessage) { + c = QColor(Qt::darkYellow); + } else if(level & OtherActivity) { + c = QColor(Qt::darkGreen); + } + bufitems[b]->setForeground(0, c); + } +} + +void NetworkView::clearActivity(Buffer *b) { + QColor c; + // it should be sane not to check if b is in bufitems since we just checked before calling this function + if(b->isActive()) { + c = QColor(Qt::black); + } else { + c = QColor(Qt::gray); + } + bufitems[b]->setForeground(0, c); +} + bool NetworkView::shouldShow(Buffer *b) { // bool f = false; if((mode & NoActive) && b->isActive()) return false; @@ -155,6 +180,7 @@ void NetworkView::selectBuffer(Buffer *b) { foreach(QTreeWidgetItem *i, sel) { if(i != item) i->setSelected(false); } if(item) { item->setSelected(true); + clearActivity(b); currentBuffer = b; } else { currentBuffer = 0; diff --git a/gui/networkview.h b/gui/networkview.h index f6842b68..a85da6c9 100644 --- a/gui/networkview.h +++ b/gui/networkview.h @@ -58,7 +58,12 @@ class NetworkView : public QDockWidget { SomeNets = 0x04, AllNets = 0x08, NoChannels = 0x10, NoQueries = 0x20, NoServers = 0x40 }; - + + enum ActivityLevel { + NoActivity = 0x00, OtherActivity = 0x01, + NewMessage = 0x02, Highlight = 0x40 + }; + NetworkView(QString name, int mode, QStringList nets = QStringList(), QWidget *parent = 0); void setMode(int mode, QStringList nets = QStringList()); void setName(QString name); @@ -66,6 +71,7 @@ class NetworkView : public QDockWidget { public slots: void bufferUpdated(Buffer *); + void bufferActivity(uint, Buffer *); void bufferDestroyed(Buffer *); void setBuffers(QList); void selectBuffer(Buffer *); @@ -90,6 +96,7 @@ class NetworkView : public QDockWidget { QTreeWidget *tree; bool shouldShow(Buffer *); + void clearActivity(Buffer *); };