summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-11 17:56:40 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-11 17:56:40 +0200
commitd6b61fbb149ed50e591b85d9814dc537ce98cc4b (patch)
tree09b2087b3cba423f67a349d335c7aee86963a2a6 /include
parentRemove unused variables (diff)
downloadnheko-d6b61fbb149ed50e591b85d9814dc537ce98cc4b.tar.xz
Add context menu option to mark events individually as read
fixes #261
Diffstat (limited to 'include')
-rw-r--r--include/ChatPage.h6
-rw-r--r--include/UserSettingsPage.h9
-rw-r--r--include/timeline/TimelineItem.h11
-rw-r--r--include/timeline/TimelineView.h3
4 files changed, 28 insertions, 1 deletions
diff --git a/include/ChatPage.h b/include/ChatPage.h
index c9085848..c753aa97 100644
--- a/include/ChatPage.h
+++ b/include/ChatPage.h
@@ -68,6 +68,12 @@ public:
         QString currentRoom() const { return current_room_; }
 
         static ChatPage *instance() { return instance_; }
+        void readEvent(const QString &room_id, const QString &event_id)
+        {
+                client_->readEvent(room_id, event_id);
+        }
+
+        QSharedPointer<UserSettings> userSettings() { return userSettings_; }
 
 signals:
         void contentLoaded();
diff --git a/include/UserSettingsPage.h b/include/UserSettingsPage.h
index 73f4b5e1..a58020ce 100644
--- a/include/UserSettingsPage.h
+++ b/include/UserSettingsPage.h
@@ -61,6 +61,12 @@ public:
                 save();
         };
 
+        void setReadReceipts(bool state)
+        {
+                isReadReceiptsEnabled_ = state;
+                save();
+        }
+
         void setTypingNotifications(bool state)
         {
                 isTypingNotificationsEnabled_ = state;
@@ -72,6 +78,7 @@ public:
         bool isOrderingEnabled() const { return isOrderingEnabled_; }
         bool isGroupViewEnabled() const { return isGroupViewEnabled_; }
         bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
+        bool isReadReceiptsEnabled() const { return isReadReceiptsEnabled_; }
 
 signals:
         void groupViewStateChanged(bool state);
@@ -82,6 +89,7 @@ private:
         bool isOrderingEnabled_;
         bool isGroupViewEnabled_;
         bool isTypingNotificationsEnabled_;
+        bool isReadReceiptsEnabled_;
 };
 
 class HorizontalLine : public QFrame
@@ -123,6 +131,7 @@ private:
         Toggle *roomOrderToggle_;
         Toggle *groupViewToggle_;
         Toggle *typingNotifications_;
+        Toggle *readReceipts_;
 
         QComboBox *themeCombo_;
 
diff --git a/include/timeline/TimelineItem.h b/include/timeline/TimelineItem.h
index a80a42c0..69bb89e2 100644
--- a/include/timeline/TimelineItem.h
+++ b/include/timeline/TimelineItem.h
@@ -26,6 +26,7 @@
 #include <QStyleOption>
 
 #include "AvatarProvider.h"
+#include "ChatPage.h"
 #include "RoomInfoListItem.h"
 #include "TimelineViewManager.h"
 #include "Utils.h"
@@ -85,6 +86,12 @@ public:
         QString eventId() const { return event_id_; }
         void setEventId(const QString &event_id) { event_id_ = event_id; }
         void markReceived();
+        void setRoomId(const QString &room_id) { room_id_ = room_id; }
+        void sendReadReceipt() const
+        {
+                if (!event_id_.isEmpty())
+                        ChatPage::instance()->readEvent(room_id_, event_id_);
+        }
 
 protected:
         void paintEvent(QPaintEvent *event) override;
@@ -114,11 +121,13 @@ private:
 
         QString replaceEmoji(const QString &body);
         QString event_id_;
+        QString room_id_;
 
         DescInfo descriptionMsg_;
 
-        QMenu *receiptsMenu_;
+        QMenu *contextMenu_;
         QAction *showReadReceipts_;
+        QAction *markAsRead_;
 
         QHBoxLayout *topLayout_;
         //! The message and the timestamp/checkmark.
diff --git a/include/timeline/TimelineView.h b/include/timeline/TimelineView.h
index 7a492de5..2876cc60 100644
--- a/include/timeline/TimelineView.h
+++ b/include/timeline/TimelineView.h
@@ -252,6 +252,7 @@ TimelineView::addUserMessage(const QString &url,
 
         TimelineItem *view_item =
           new TimelineItem(widget, local_user_, with_sender, scroll_widget_);
+        view_item->setRoomId(room_id_);
 
         addTimelineItem(view_item);
 
@@ -272,6 +273,7 @@ TimelineItem *
 TimelineView::createTimelineItem(const Event &event, bool withSender)
 {
         TimelineItem *item = new TimelineItem(event, withSender, scroll_widget_);
+        item->setRoomId(room_id_);
         return item;
 }
 
@@ -281,6 +283,7 @@ TimelineView::createTimelineItem(const Event &event, bool withSender)
 {
         auto eventWidget = new Widget(client_, event);
         auto item        = new TimelineItem(eventWidget, event, withSender, scroll_widget_);
+        item->setRoomId(room_id_);
 
         return item;
 }