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());
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 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();
void bufferRenamed(BufferId bufferId, const QString &newName);
void buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2);
+ void markBufferAsRead(BufferId id);
+
private slots:
void setSyncedToCore();
void setDisconnectedFromCore();
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);
+ void bufferMarkedAsRead(BufferId buffer);
protected slots:
bool setLastSeenMsg(BufferId buffer, const MsgId &msgId);
virtual void requestPurgeBufferIds();
+ virtual inline void requestMarkBufferAsRead(BufferId buffer) { markBufferAsRead(buffer); }
+
void storeDirtyIds();
protected:
if(event->type() == QEvent::WindowActivate) {
BufferId buffer = Client::bufferModel()->currentBuffer();
if(buffer.isValid())
- QtUi::closeNotifications(buffer);
+ Client::instance()->markBufferAsRead(buffer);
}
return QMainWindow::event(event);
}
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())
- QtUi::closeNotifications(buffer);
+ Client::instance()->markBufferAsRead(buffer);
}
void MainWin::clientNetworkCreated(NetworkId id) {
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() {
activateMainWidget();
}
+
+void QtUi::bufferMarkedAsRead(BufferId bufferId) {
+ if(bufferId.isValid()) {
+ closeNotifications(bufferId);
+ }
+}
static void unregisterNotificationBackend(AbstractNotificationBackend *);
static void unregisterAllNotificationBackends();
static const QList<AbstractNotificationBackend *> ¬ificationBackends();
- 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();
+ 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);
+ void bufferMarkedAsRead(BufferId);
protected:
virtual void minimizeRestore(bool show);