added room topic

This commit is contained in:
Jedi18 2021-02-13 19:08:52 +05:30
parent 35aa0126ac
commit f3596aed55
4 changed files with 68 additions and 23 deletions

View file

@ -12,8 +12,8 @@ ApplicationWindow {
x: MainWindow.x + (MainWindow.width / 2) - (width / 2)
y: MainWindow.y + (MainWindow.height / 2) - (height / 2)
minimumWidth: 340
minimumHeight: 600
minimumWidth: 400
minimumHeight: 650
palette: colors
color: colors.window
modality: Qt.WindowModal
@ -24,9 +24,12 @@ ApplicationWindow {
}
ColumnLayout {
id: contentLayout
id: contentLayout1
anchors.fill: parent
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: undefined
anchors.margins: 10
spacing: 10
@ -101,6 +104,32 @@ ApplicationWindow {
visible: roomSettings.canChangeNameAndTopic
onClicked: roomSettings.openEditModal()
}
}
ScrollView {
id: topicScroll
anchors.left: parent.left
anchors.right: parent.right
anchors.top: contentLayout1.bottom
anchors.bottom: undefined
anchors.margins: 10
height: 100
TextArea {
text: roomSettings.roomTopic
background: null
}
}
ColumnLayout {
id: contentLayout2
anchors.left: parent.left
anchors.right: parent.right
anchors.top: topicScroll.bottom
anchors.bottom: parent.bottom
anchors.margins: 10
spacing: 10
MatrixText {
text: "SETTINGS"

View file

@ -15,7 +15,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
onClicked: TimelineManager.openRoomSettings()
onClicked: TimelineManager.timeline.openRoomSettings()
}
GridLayout {

View file

@ -75,9 +75,10 @@ EditModal::EditModal(const QString &roomId, QWidget *parent)
}
void
EditModal::topicEventSent()
EditModal::topicEventSent(const QString &topic)
{
errorField_->hide();
emit topicChanged(topic);
close();
}
@ -141,14 +142,14 @@ EditModal::applyClicked()
http::client()->send_state_event(
roomId_.toStdString(),
body,
[proxy](const mtx::responses::EventId &, mtx::http::RequestErr err) {
[proxy, newTopic](const mtx::responses::EventId &, mtx::http::RequestErr err) {
if (err) {
emit proxy->error(
QString::fromStdString(err->matrix_error.error));
return;
}
emit proxy->topicEventSent();
emit proxy->topicEventSent(newTopic);
});
}
}
@ -222,7 +223,13 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
QString
RoomSettings::roomName() const
{
return QString(info_.name.c_str());
return QString::fromStdString(info_.name);
}
QString
RoomSettings::roomTopic() const
{
return QString::fromStdString(info_.topic);
}
QString
@ -382,6 +389,11 @@ RoomSettings::openEditModal()
info_.name = newName.toStdString();
emit roomNameChanged();
});
connect(modal, &EditModal::topicChanged, this, [this](const QString &newTopic) {
info_.topic = newTopic.toStdString();
emit roomTopicChanged();
});
}
void

View file

@ -20,7 +20,7 @@ class ThreadProxy : public QObject
signals:
void error(const QString &msg);
void nameEventSent(const QString &);
void topicEventSent();
void topicEventSent(const QString &);
void stopLoading();
};
@ -35,9 +35,10 @@ public:
signals:
void nameChanged(const QString &roomName);
void topicChanged(const QString &topic);
private slots:
void topicEventSent();
void topicEventSent(const QString &topic);
void nameEventSent(const QString &name);
void error(const QString &msg);
@ -60,25 +61,27 @@ private:
class RoomSettings : public QObject
{
Q_OBJECT
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
Q_PROPERTY(QString roomId READ roomId CONSTANT)
Q_PROPERTY(QString roomVersion READ roomVersion CONSTANT)
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
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(int accessJoinRules READ accessJoinRules NOTIFY accessJoinRulesChanged)
Q_PROPERTY(bool isLoading READ isLoading NOTIFY loadingChanged)
Q_PROPERTY(bool canChangeAvatar READ canChangeAvatar CONSTANT)
Q_PROPERTY(bool canChangeJoinRules READ canChangeJoinRules CONSTANT)
Q_PROPERTY(bool canChangeNameAndTopic READ canChangeNameAndTopic CONSTANT)
Q_PROPERTY(bool canChangeAvatar READ canChangeAvatar CONSTANT)
Q_PROPERTY(bool isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged)
Q_PROPERTY(bool respondsToKeyRequests READ respondsToKeyRequests NOTIFY keyRequestsChanged)
public:
RoomSettings(QString roomid, QObject *parent = nullptr);
QString roomName() const;
QString roomId() const;
QString roomName() const;
QString roomTopic() const;
QString roomVersion() const;
QString roomAvatarUrl();
int memberCount() const;
@ -94,26 +97,27 @@ public:
bool canChangeAvatar() const;
bool isEncryptionEnabled() const;
Q_INVOKABLE void changeNotifications(int currentIndex);
Q_INVOKABLE void changeAccessRules(int index);
Q_INVOKABLE void changeKeyRequestsPreference(bool isOn);
Q_INVOKABLE void enableEncryption();
Q_INVOKABLE void updateAvatar();
Q_INVOKABLE void openEditModal();
Q_INVOKABLE void changeAccessRules(int index);
Q_INVOKABLE void changeNotifications(int currentIndex);
Q_INVOKABLE void changeKeyRequestsPreference(bool isOn);
signals:
void loadingChanged();
void roomNameChanged();
void roomTopicChanged();
void avatarUrlChanged();
void encryptionChanged();
void keyRequestsChanged();
void notificationsChanged();
void accessJoinRulesChanged();
void keyRequestsChanged();
void encryptionChanged();
void avatarUrlChanged();
void roomNameChanged();
void loadingChanged();
void displayError(const QString &errorMessage);
public slots:
void avatarChanged();
void stopLoading();
void avatarChanged();
private:
void retrieveRoomInfo();