From: Manuel Nickschas Date: Thu, 10 Sep 2009 19:23:50 +0000 (+0200) Subject: Close notifications on buffer switch rather than activation change X-Git-Tag: 0.5-rc2~68 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=14a1ee538d01e41dc55a6e733a7804930aa9fff8 Close notifications on buffer switch rather than activation change We now properly close only the notifications that refer to the current buffer if you switch to it or activate the window. Before, we closed all active notifications when the window got activated (and only then). --- diff --git a/src/client/buffermodel.h b/src/client/buffermodel.h index 9a94fbe4..d863dc95 100644 --- a/src/client/buffermodel.h +++ b/src/client/buffermodel.h @@ -25,10 +25,10 @@ #include #include "network.h" +#include "networkmodel.h" #include "types.h" #include "selectionmodelsynchronizer.h" -class NetworkModel; class QAbstractItemView; class BufferModel : public QSortFilterProxyModel { @@ -46,6 +46,7 @@ public: void synchronizeView(QAbstractItemView *view); inline QModelIndex currentIndex() { return standardSelectionModel()->currentIndex(); } + inline BufferId currentBuffer() { return currentIndex().data(NetworkModel::BufferIdRole).value(); } public slots: void setCurrentIndex(const QModelIndex &newCurrent); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 04314688..1f6d17e0 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -184,6 +184,8 @@ void MainWin::init() { QtUi::registerNotificationBackend(new KNotificationBackend(this)); #endif /* HAVE_KDE */ + connect(bufferWidget(), SIGNAL(currentChanged(BufferId)), SLOT(currentBufferChanged(BufferId))); + setDisconnectedState(); // Disable menus and stuff #ifdef HAVE_KDE @@ -868,8 +870,11 @@ void MainWin::showShortcutsDlg() { /********************************************************************************************************/ bool MainWin::event(QEvent *event) { - if(event->type() == QEvent::WindowActivate) - QtUi::closeNotifications(); + if(event->type() == QEvent::WindowActivate) { + BufferId buffer = Client::bufferModel()->currentBuffer(); + if(buffer.isValid()) + QtUi::closeNotifications(buffer); + } return QMainWindow::event(event); } @@ -977,7 +982,7 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) { BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value(); BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId); - if(hasFocus && bufId == _bufferWidget->currentBuffer()) + if(hasFocus && bufId == Client::bufferModel()->currentBuffer()) continue; if((flags & Message::Highlight || bufType == BufferInfo::QueryBuffer) @@ -1003,6 +1008,11 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) { } } +void MainWin::currentBufferChanged(BufferId buffer) { + if(buffer.isValid()) + QtUi::closeNotifications(buffer); +} + void MainWin::clientNetworkCreated(NetworkId id) { const Network *net = Client::network(id); QAction *act = new QAction(net->networkName(), this); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 63c0ca06..361467aa 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -73,6 +73,8 @@ class MainWin void addBufferView(ClientBufferViewConfig *config); BufferView *allBuffersView() const; + BufferWidget *bufferWidget() const { return _bufferWidget; } + inline SystemTray *systemTray() const; bool event(QEvent *event); @@ -111,6 +113,7 @@ class MainWin void addBufferView(int bufferViewConfigId); void awayLogDestroyed(); void removeBufferView(int bufferViewConfigId); + void currentBufferChanged(BufferId); void messagesInserted(const QModelIndex &parent, int start, int end); void showAboutDlg(); void showChannelList(NetworkId netId = NetworkId());