Improve room setting

* Port away from OverlaySheet
* Use Kirigami.CategorizedSettings
* Add join rules (read only for now)
This commit is contained in:
Carl Schwan
2021-10-16 23:00:50 +02:00
parent 6b8358874a
commit 890860df92
13 changed files with 369 additions and 218 deletions

View File

@@ -36,6 +36,7 @@ add_executable(neochat
spellcheckhighlighter.cpp
blurhash.cpp
blurhashimageprovider.cpp
joinrulesevent.cpp
../res.qrc
)

16
src/joinrulesevent.cpp Normal file
View File

@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 2019 Kitsune Ral <Kitsune-Ral@users.sf.net>
// SPDX-License-Identifier: LGPL-2.1-or-later
#include "joinrulesevent.h"
using namespace Quotient;
QString JoinRulesEvent::joinRule() const
{
return fromJson<QString>(contentJson()["join_rule"_ls]);
}
QJsonArray JoinRulesEvent::allow() const
{
return contentJson()["allow"_ls].toArray();
}

29
src/joinrulesevent.h Normal file
View File

@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
#include <events/stateevent.h>
#include <quotient_common.h>
namespace Quotient
{
class JoinRulesEvent : public StateEventBase
{
public:
DEFINE_EVENT_TYPEID("m.room.join_rules", JoinRulesEvent)
explicit JoinRulesEvent()
: StateEventBase(typeId(), matrixTypeId())
{
}
explicit JoinRulesEvent(const QJsonObject &obj)
: StateEventBase(typeId(), obj)
{
}
QString joinRule() const;
QJsonArray allow() const;
};
REGISTER_EVENT_TYPE(JoinRulesEvent)
} // namespace Quotient

View File

@@ -44,6 +44,7 @@
#include "devicesmodel.h"
#include "emojimodel.h"
#include "filetypesingleton.h"
#include "joinrulesevent.h"
#include "login.h"
#include "matriximageprovider.h"
#include "messageeventmodel.h"

View File

@@ -735,6 +735,11 @@ void NeoChatRoom::deleteMessagesByUser(const QString &user)
doDeleteMessagesByUser(user);
}
QString NeoChatRoom::joinRule() const
{
return getCurrentState<JoinRulesEvent>()->joinRule();
}
QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user)
{
QStringList events;

View File

@@ -3,6 +3,7 @@
#pragma once
#include "joinrulesevent.h"
#include <events/encryptionevent.h>
#include <events/redactionevent.h>
#include <events/roomavatarevent.h>
@@ -33,6 +34,7 @@ class NeoChatRoom : public Room
Q_PROPERTY(bool readMarkerLoaded READ readMarkerLoaded NOTIFY readMarkerLoadedChanged)
Q_PROPERTY(QDateTime lastActiveTime READ lastActiveTime NOTIFY lastActiveTimeChanged)
Q_PROPERTY(bool isInvite READ isInvite NOTIFY isInviteChanged)
Q_PROPERTY(QString joinRule READ joinRule CONSTANT)
Q_PROPERTY(QString htmlSafeDisplayName READ htmlSafeDisplayName NOTIFY displayNameChanged)
public:
@@ -66,6 +68,8 @@ public:
bool isEventHighlighted(const Quotient::RoomEvent *e) const;
[[nodiscard]] QString joinRule() const;
[[nodiscard]] bool hasFileUploading() const
{
return m_hasFileUploading;