summary refs log tree commit diff
path: root/src/ui/RoomSettings.h
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-06-24 01:04:54 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-06-24 01:04:54 +0200
commitfa653bc078ca80508b5de27ac02c77980dda4c45 (patch)
tree6e46f203e41eb592870e4ab9a8409ec0db1af04f /src/ui/RoomSettings.h
parentBump arm job count (diff)
downloadnheko-fa653bc078ca80508b5de27ac02c77980dda4c45.tar.xz
Allow viewing and changing the history visibility
Diffstat (limited to 'src/ui/RoomSettings.h')
-rw-r--r--src/ui/RoomSettings.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ui/RoomSettings.h b/src/ui/RoomSettings.h
index f8d0857c..cf3ac032 100644
--- a/src/ui/RoomSettings.h
+++ b/src/ui/RoomSettings.h
@@ -6,6 +6,7 @@
 
 #include <QAbstractListModel>
 #include <QObject>
+#include <QQmlEngine>
 #include <QSet>
 #include <QString>
 
@@ -13,6 +14,7 @@
 
 #include <mtx/events/event_type.hpp>
 #include <mtx/events/guest_access.hpp>
+#include <mtx/events/history_visibility.hpp>
 
 #include "CacheStructs.h"
 
@@ -26,6 +28,7 @@ signals:
     void error(const QString &msg);
     void nameEventSent(const QString &);
     void topicEventSent(const QString &);
+    void eventSent();
     void stopLoading();
 };
 
@@ -78,6 +81,8 @@ class RoomSettings final : public QObject
     Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY avatarUrlChanged)
     Q_PROPERTY(int memberCount READ memberCount CONSTANT)
     Q_PROPERTY(int notifications READ notifications NOTIFY notificationsChanged)
+    Q_PROPERTY(Visibility historyVisibility READ historyVisibility WRITE changeHistoryVisibility
+                 NOTIFY historyVisibilityChanged)
     Q_PROPERTY(bool privateAccess READ privateAccess NOTIFY accessJoinRulesChanged)
     Q_PROPERTY(bool guestAccess READ guestAccess NOTIFY accessJoinRulesChanged)
     Q_PROPERTY(bool knockingEnabled READ knockingEnabled NOTIFY accessJoinRulesChanged)
@@ -87,6 +92,7 @@ class RoomSettings final : public QObject
     Q_PROPERTY(bool canChangeJoinRules READ canChangeJoinRules CONSTANT)
     Q_PROPERTY(bool canChangeName READ canChangeName CONSTANT)
     Q_PROPERTY(bool canChangeTopic READ canChangeTopic CONSTANT)
+    Q_PROPERTY(bool canChangeHistoryVisibility READ canChangeHistoryVisibility CONSTANT)
     Q_PROPERTY(bool isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged)
     Q_PROPERTY(bool supportsKnocking READ supportsKnocking CONSTANT)
     Q_PROPERTY(bool supportsRestricted READ supportsRestricted CONSTANT)
@@ -98,6 +104,16 @@ class RoomSettings final : public QObject
       bool allowedRoomsModified READ allowedRoomsModified NOTIFY allowedRoomsModifiedChanged)
 
 public:
+    // match mtx::events::state::Visibility
+    enum Visibility
+    {
+        WorldReadable,
+        Shared,
+        Invited,
+        Joined,
+    };
+    Q_ENUM(Visibility)
+
     RoomSettings(QString roomid, QObject *parent = nullptr);
 
     QString roomId() const;
@@ -122,6 +138,7 @@ public:
     bool canChangeTopic() const;
     //! Whether the user has enough power level to send m.room.avatar event.
     bool canChangeAvatar() const;
+    bool canChangeHistoryVisibility() const;
     bool isEncryptionEnabled() const;
     bool supportsKnocking() const;
     bool supportsRestricted() const;
@@ -130,6 +147,9 @@ public:
     void setAllowedRooms(QStringList rooms);
     bool allowedRoomsModified() const { return allowedRoomsModified_; }
 
+    Visibility historyVisibility() const;
+    Q_INVOKABLE void changeHistoryVisibility(Visibility visibility);
+
     Q_INVOKABLE void enableEncryption();
     Q_INVOKABLE void updateAvatar();
     Q_INVOKABLE void changeAccessRules(bool private_,
@@ -153,6 +173,7 @@ signals:
     void allowedRoomsChanged();
     void displayError(const QString &errorMessage);
     void allowedRoomsModifiedChanged();
+    void historyVisibilityChanged();
 
 public slots:
     void stopLoading();
@@ -173,7 +194,8 @@ private:
     int notifications_ = 0;
 
     mtx::events::state::JoinRules accessRules_;
-    mtx::events::state::AccessState guestRules_ = mtx::events::state::AccessState::Forbidden;
+    mtx::events::state::Visibility historyVisibility_ = mtx::events::state::Visibility::Shared;
+    mtx::events::state::AccessState guestRules_       = mtx::events::state::AccessState::Forbidden;
 
     RoomSettingsAllowedRoomsModel *allowedRoomsModel;
 };