From 852edb4affbe89c7b2772fe30392dfdec27b2b94 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 22 Jul 2023 14:52:34 -0400 Subject: Add mark as read entry to the roomlist right-click menu --- src/timeline/TimelineModel.cpp | 17 +++++++++++++++-- src/timeline/TimelineModel.h | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') 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 @@ -1283,14 +1283,21 @@ 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')) { @@ -1561,6 +1568,12 @@ TimelineModel::markEventsAsRead(const std::vector &event_ids) } } +void +TimelineModel::markRoomAsRead() +{ + setCurrentIndex(0, true); +} + void TimelineModel::updateLastReadId(const QString ¤tRoomId) { 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 &event_ids); + void markRoomAsRead(); void updateLastReadId(const QString ¤tRoomId); void lastReadIdOnWindowFocus(); void checkAfterFetch(); -- cgit 1.4.1