summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2023-07-28 14:50:13 +0000
committerGitHub <noreply@github.com>2023-07-28 14:50:13 +0000
commitb2b8945f22ce83540a16cfd8494b2adc1cfc1587 (patch)
tree0d12c242e48c182f3d93ccb02a59bc06180d8aa3 /src
parentUpdate coeurl for fmt10 compatibility (diff)
parentAdd mark as read entry to the roomlist right-click menu (diff)
downloadnheko-b2b8945f22ce83540a16cfd8494b2adc1cfc1587.tar.xz
Merge pull request #1532 from Nheko-Reborn/issue1512
Add mark room as read option
Diffstat (limited to 'src')
-rw-r--r--src/timeline/TimelineModel.cpp17
-rw-r--r--src/timeline/TimelineModel.h2
2 files changed, 17 insertions, 2 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 752aedb0..fddd5700 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -1284,13 +1284,20 @@ TimelineModel::updateLastMessage()
 void
 TimelineModel::setCurrentIndex(int index)
 {
+    setCurrentIndex(index, false);
+}
+
+void
+TimelineModel::setCurrentIndex(int index, bool ignoreInactiveState)
+{
     auto oldIndex = idToIndex(currentId);
     currentId     = indexToId(index);
     if (index != oldIndex)
         emit currentIndexChanged(index);
 
-    if (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() ||
-        MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow())
+    if (!ignoreInactiveState &&
+        (!QGuiApplication::focusWindow() || !QGuiApplication::focusWindow()->isActive() ||
+         MainWindow::instance()->windowForRoom(roomId()) != QGuiApplication::focusWindow()))
         return;
 
     if (!currentId.startsWith('m')) {
@@ -1562,6 +1569,12 @@ TimelineModel::markEventsAsRead(const std::vector<QString> &event_ids)
 }
 
 void
+TimelineModel::markRoomAsRead()
+{
+    setCurrentIndex(0, true);
+}
+
+void
 TimelineModel::updateLastReadId(const QString &currentRoomId)
 {
     if (currentRoomId == room_id_) {
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index fd1a4396..64941920 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -386,9 +386,11 @@ public:
 
 public slots:
     void setCurrentIndex(int index);
+    void setCurrentIndex(int index, bool ignoreInactiveState);
     int currentIndex() const { return idToIndex(currentId); }
     void eventShown();
     void markEventsAsRead(const std::vector<QString> &event_ids);
+    void markRoomAsRead();
     void updateLastReadId(const QString &currentRoomId);
     void lastReadIdOnWindowFocus();
     void checkAfterFetch();