Close notifications on other connected clients as well
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 13 Apr 2010 21:18:22 +0000 (23:18 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 13 Apr 2010 21:22:04 +0000 (23:22 +0200)
Client now emits a bufferMarkedAsRead() signal that is used for triggering
the closing of notifications. This is synced between clients.

This requires both uptodate clients and core and will spam your log with warnings
if one is too old (but continue to work like it used to). "Too old" means "does not
contain this commit", i.e. a 0.6.0 client will work fine with a git master core and
the other way round, but earlier versions won't.

src/client/client.cpp
src/client/client.h
src/common/buffersyncer.h
src/core/corebuffersyncer.h
src/qtui/mainwin.cpp
src/qtui/qtui.cpp
src/qtui/qtui.h

index 07b3c26..c5d4e50 100644 (file)
@@ -321,6 +321,7 @@ void Client::setSyncedToCore() {
   connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
   connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), this, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
   connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), _messageModel, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
   connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
   connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), this, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
   connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), _messageModel, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
+  connect(bufferSyncer(), SIGNAL(bufferMarkedAsRead(BufferId)), SIGNAL(bufferMarkedAsRead(BufferId)));
   connect(networkModel(), SIGNAL(setLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &)));
   signalProxy()->synchronize(bufferSyncer());
 
   connect(networkModel(), SIGNAL(setLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &)));
   signalProxy()->synchronize(bufferSyncer());
 
@@ -532,6 +533,11 @@ void Client::buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2) {
   networkModel()->removeBuffer(bufferId2);
 }
 
   networkModel()->removeBuffer(bufferId2);
 }
 
+void Client::markBufferAsRead(BufferId id) {
+  if(id.isValid())
+    bufferSyncer()->requestMarkBufferAsRead(id);
+}
+
 void Client::logMessage(QtMsgType type, const char *msg) {
   fprintf(stderr, "%s\n", msg);
   fflush(stderr);
 void Client::logMessage(QtMsgType type, const char *msg) {
   fprintf(stderr, "%s\n", msg);
   fflush(stderr);
index e401f46..30ef2d9 100644 (file)
@@ -171,6 +171,13 @@ signals:
 
   void logUpdated(const QString &msg);
 
 
   void logUpdated(const QString &msg);
 
+  //! Emitted when a buffer has been marked as read
+  /** This is currently triggered by setting lastSeenMsg, either local or remote,
+   *  or by bringing the window to front.
+   *  \param id The buffer that has been marked as read
+   */
+  void bufferMarkedAsRead(BufferId id);
+
 public slots:
   void disconnectFromCore();
 
 public slots:
   void disconnectFromCore();
 
@@ -178,6 +185,8 @@ public slots:
   void bufferRenamed(BufferId bufferId, const QString &newName);
   void buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2);
 
   void bufferRenamed(BufferId bufferId, const QString &newName);
   void buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2);
 
+  void markBufferAsRead(BufferId id);
+
 private slots:
   void setSyncedToCore();
   void setDisconnectedFromCore();
 private slots:
   void setSyncedToCore();
   void setDisconnectedFromCore();
index 5519828..3de31db 100644 (file)
@@ -58,12 +58,16 @@ public slots:
 
   virtual inline void requestPurgeBufferIds() { REQUEST(NO_ARG); }
 
 
   virtual inline void requestPurgeBufferIds() { REQUEST(NO_ARG); }
 
+  virtual inline void requestMarkBufferAsRead(BufferId buffer) { REQUEST(ARG(buffer)) emit bufferMarkedAsRead(buffer); }
+  virtual inline void markBufferAsRead(BufferId buffer) { SYNC(ARG(buffer)) emit bufferMarkedAsRead(buffer); }
+
 signals:
   void lastSeenMsgSet(BufferId buffer, const MsgId &msgId);
   void markerLineSet(BufferId buffer, const MsgId &msgId);
   void bufferRemoved(BufferId buffer);
   void bufferRenamed(BufferId buffer, QString newName);
   void buffersPermanentlyMerged(BufferId buffer1, BufferId buffer2);
 signals:
   void lastSeenMsgSet(BufferId buffer, const MsgId &msgId);
   void markerLineSet(BufferId buffer, const MsgId &msgId);
   void bufferRemoved(BufferId buffer);
   void bufferRenamed(BufferId buffer, QString newName);
   void buffersPermanentlyMerged(BufferId buffer1, BufferId buffer2);
+  void bufferMarkedAsRead(BufferId buffer);
 
 protected slots:
   bool setLastSeenMsg(BufferId buffer, const MsgId &msgId);
 
 protected slots:
   bool setLastSeenMsg(BufferId buffer, const MsgId &msgId);
index 89694bf..cb58b0a 100644 (file)
@@ -47,6 +47,8 @@ public slots:
 
   virtual void requestPurgeBufferIds();
 
 
   virtual void requestPurgeBufferIds();
 
+  virtual inline void requestMarkBufferAsRead(BufferId buffer) { markBufferAsRead(buffer); }
+
   void storeDirtyIds();
 
 protected:
   void storeDirtyIds();
 
 protected:
index b35cad8..e1d961c 100644 (file)
@@ -996,7 +996,7 @@ bool MainWin::event(QEvent *event) {
   if(event->type() == QEvent::WindowActivate) {
     BufferId buffer = Client::bufferModel()->currentBuffer();
     if(buffer.isValid())
   if(event->type() == QEvent::WindowActivate) {
     BufferId buffer = Client::bufferModel()->currentBuffer();
     if(buffer.isValid())
-      QtUi::closeNotifications(buffer);
+      Client::instance()->markBufferAsRead(buffer);
   }
   return QMainWindow::event(event);
 }
   }
   return QMainWindow::event(event);
 }
@@ -1067,14 +1067,14 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
       else
         type = AbstractNotificationBackend::HighlightFocused;
 
       else
         type = AbstractNotificationBackend::HighlightFocused;
 
-      QtUi::invokeNotification(bufId, type, sender, contents);
+      QtUi::instance()->invokeNotification(bufId, type, sender, contents);
     }
   }
 }
 
 void MainWin::currentBufferChanged(BufferId buffer) {
   if(buffer.isValid())
     }
   }
 }
 
 void MainWin::currentBufferChanged(BufferId buffer) {
   if(buffer.isValid())
-    QtUi::closeNotifications(buffer);
+    Client::instance()->markBufferAsRead(buffer);
 }
 
 void MainWin::clientNetworkCreated(NetworkId id) {
 }
 
 void MainWin::clientNetworkCreated(NetworkId id) {
index f3bb9a6..8844848 100644 (file)
@@ -62,6 +62,7 @@ QtUi::QtUi() : GraphicalUi() {
 
   connect(_mainWin, SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &)));
   connect(_mainWin, SIGNAL(disconnectFromCore()), this, SIGNAL(disconnectFromCore()));
 
   connect(_mainWin, SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &)));
   connect(_mainWin, SIGNAL(disconnectFromCore()), this, SIGNAL(disconnectFromCore()));
+  connect(Client::instance(), SIGNAL(bufferMarkedAsRead(BufferId)), SLOT(closeNotifications(BufferId)));
 }
 
 QtUi::~QtUi() {
 }
 
 QtUi::~QtUi() {
@@ -200,3 +201,9 @@ void QtUi::notificationActivated(uint notificationId) {
 
   activateMainWidget();
 }
 
   activateMainWidget();
 }
+
+void QtUi::bufferMarkedAsRead(BufferId bufferId) {
+  if(bufferId.isValid()) {
+    closeNotifications(bufferId);
+  }
+}
index 44c4741..437cc15 100644 (file)
@@ -56,18 +56,20 @@ public:
   static void unregisterNotificationBackend(AbstractNotificationBackend *);
   static void unregisterAllNotificationBackends();
   static const QList<AbstractNotificationBackend *> &notificationBackends();
   static void unregisterNotificationBackend(AbstractNotificationBackend *);
   static void unregisterAllNotificationBackends();
   static const QList<AbstractNotificationBackend *> &notificationBackends();
-  static uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
-  static void closeNotification(uint notificationId);
-  static void closeNotifications(BufferId bufferId = BufferId());
   static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
 
 public slots:
   virtual void init();
 
   static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
 
 public slots:
   virtual void init();
 
+  uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
+  void closeNotification(uint notificationId);
+  void closeNotifications(BufferId bufferId = BufferId());
+
 protected slots:
   void connectedToCore();
   void disconnectedFromCore();
   void notificationActivated(uint notificationId);
 protected slots:
   void connectedToCore();
   void disconnectedFromCore();
   void notificationActivated(uint notificationId);
+  void bufferMarkedAsRead(BufferId);
 
 protected:
   virtual void minimizeRestore(bool show);
 
 protected:
   virtual void minimizeRestore(bool show);