mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
added room topic
This commit is contained in:
parent
35aa0126ac
commit
f3596aed55
4 changed files with 68 additions and 23 deletions
|
@ -12,8 +12,8 @@ ApplicationWindow {
|
||||||
|
|
||||||
x: MainWindow.x + (MainWindow.width / 2) - (width / 2)
|
x: MainWindow.x + (MainWindow.width / 2) - (width / 2)
|
||||||
y: MainWindow.y + (MainWindow.height / 2) - (height / 2)
|
y: MainWindow.y + (MainWindow.height / 2) - (height / 2)
|
||||||
minimumWidth: 340
|
minimumWidth: 400
|
||||||
minimumHeight: 600
|
minimumHeight: 650
|
||||||
palette: colors
|
palette: colors
|
||||||
color: colors.window
|
color: colors.window
|
||||||
modality: Qt.WindowModal
|
modality: Qt.WindowModal
|
||||||
|
@ -24,9 +24,12 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
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
|
anchors.margins: 10
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
|
@ -101,6 +104,32 @@ ApplicationWindow {
|
||||||
visible: roomSettings.canChangeNameAndTopic
|
visible: roomSettings.canChangeNameAndTopic
|
||||||
onClicked: roomSettings.openEditModal()
|
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 {
|
MatrixText {
|
||||||
text: "SETTINGS"
|
text: "SETTINGS"
|
||||||
|
|
|
@ -15,7 +15,7 @@ Rectangle {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: TimelineManager.openRoomSettings()
|
onClicked: TimelineManager.timeline.openRoomSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
|
|
|
@ -75,9 +75,10 @@ EditModal::EditModal(const QString &roomId, QWidget *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EditModal::topicEventSent()
|
EditModal::topicEventSent(const QString &topic)
|
||||||
{
|
{
|
||||||
errorField_->hide();
|
errorField_->hide();
|
||||||
|
emit topicChanged(topic);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,14 +142,14 @@ EditModal::applyClicked()
|
||||||
http::client()->send_state_event(
|
http::client()->send_state_event(
|
||||||
roomId_.toStdString(),
|
roomId_.toStdString(),
|
||||||
body,
|
body,
|
||||||
[proxy](const mtx::responses::EventId &, mtx::http::RequestErr err) {
|
[proxy, newTopic](const mtx::responses::EventId &, mtx::http::RequestErr err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
emit proxy->error(
|
emit proxy->error(
|
||||||
QString::fromStdString(err->matrix_error.error));
|
QString::fromStdString(err->matrix_error.error));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit proxy->topicEventSent();
|
emit proxy->topicEventSent(newTopic);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +223,13 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
|
||||||
QString
|
QString
|
||||||
RoomSettings::roomName() const
|
RoomSettings::roomName() const
|
||||||
{
|
{
|
||||||
return QString(info_.name.c_str());
|
return QString::fromStdString(info_.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
RoomSettings::roomTopic() const
|
||||||
|
{
|
||||||
|
return QString::fromStdString(info_.topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
@ -382,6 +389,11 @@ RoomSettings::openEditModal()
|
||||||
info_.name = newName.toStdString();
|
info_.name = newName.toStdString();
|
||||||
emit roomNameChanged();
|
emit roomNameChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(modal, &EditModal::topicChanged, this, [this](const QString &newTopic) {
|
||||||
|
info_.topic = newTopic.toStdString();
|
||||||
|
emit roomTopicChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ThreadProxy : public QObject
|
||||||
signals:
|
signals:
|
||||||
void error(const QString &msg);
|
void error(const QString &msg);
|
||||||
void nameEventSent(const QString &);
|
void nameEventSent(const QString &);
|
||||||
void topicEventSent();
|
void topicEventSent(const QString &);
|
||||||
void stopLoading();
|
void stopLoading();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,9 +35,10 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged(const QString &roomName);
|
void nameChanged(const QString &roomName);
|
||||||
|
void topicChanged(const QString &topic);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void topicEventSent();
|
void topicEventSent(const QString &topic);
|
||||||
void nameEventSent(const QString &name);
|
void nameEventSent(const QString &name);
|
||||||
void error(const QString &msg);
|
void error(const QString &msg);
|
||||||
|
|
||||||
|
@ -60,25 +61,27 @@ private:
|
||||||
class RoomSettings : public QObject
|
class RoomSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
|
|
||||||
Q_PROPERTY(QString roomId READ roomId CONSTANT)
|
Q_PROPERTY(QString roomId READ roomId CONSTANT)
|
||||||
Q_PROPERTY(QString roomVersion READ roomVersion 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(QString roomAvatarUrl READ roomAvatarUrl NOTIFY avatarUrlChanged)
|
||||||
Q_PROPERTY(int memberCount READ memberCount CONSTANT)
|
Q_PROPERTY(int memberCount READ memberCount CONSTANT)
|
||||||
Q_PROPERTY(int notifications READ notifications NOTIFY notificationsChanged)
|
Q_PROPERTY(int notifications READ notifications NOTIFY notificationsChanged)
|
||||||
Q_PROPERTY(int accessJoinRules READ accessJoinRules NOTIFY accessJoinRulesChanged)
|
Q_PROPERTY(int accessJoinRules READ accessJoinRules NOTIFY accessJoinRulesChanged)
|
||||||
Q_PROPERTY(bool isLoading READ isLoading NOTIFY loadingChanged)
|
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 canChangeJoinRules READ canChangeJoinRules CONSTANT)
|
||||||
Q_PROPERTY(bool canChangeNameAndTopic READ canChangeNameAndTopic 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 isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged)
|
||||||
Q_PROPERTY(bool respondsToKeyRequests READ respondsToKeyRequests NOTIFY keyRequestsChanged)
|
Q_PROPERTY(bool respondsToKeyRequests READ respondsToKeyRequests NOTIFY keyRequestsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RoomSettings(QString roomid, QObject *parent = nullptr);
|
RoomSettings(QString roomid, QObject *parent = nullptr);
|
||||||
|
|
||||||
QString roomName() const;
|
|
||||||
QString roomId() const;
|
QString roomId() const;
|
||||||
|
QString roomName() const;
|
||||||
|
QString roomTopic() const;
|
||||||
QString roomVersion() const;
|
QString roomVersion() const;
|
||||||
QString roomAvatarUrl();
|
QString roomAvatarUrl();
|
||||||
int memberCount() const;
|
int memberCount() const;
|
||||||
|
@ -94,26 +97,27 @@ public:
|
||||||
bool canChangeAvatar() const;
|
bool canChangeAvatar() const;
|
||||||
bool isEncryptionEnabled() 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 enableEncryption();
|
||||||
Q_INVOKABLE void updateAvatar();
|
Q_INVOKABLE void updateAvatar();
|
||||||
Q_INVOKABLE void openEditModal();
|
Q_INVOKABLE void openEditModal();
|
||||||
|
Q_INVOKABLE void changeAccessRules(int index);
|
||||||
|
Q_INVOKABLE void changeNotifications(int currentIndex);
|
||||||
|
Q_INVOKABLE void changeKeyRequestsPreference(bool isOn);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void loadingChanged();
|
||||||
|
void roomNameChanged();
|
||||||
|
void roomTopicChanged();
|
||||||
|
void avatarUrlChanged();
|
||||||
|
void encryptionChanged();
|
||||||
|
void keyRequestsChanged();
|
||||||
void notificationsChanged();
|
void notificationsChanged();
|
||||||
void accessJoinRulesChanged();
|
void accessJoinRulesChanged();
|
||||||
void keyRequestsChanged();
|
|
||||||
void encryptionChanged();
|
|
||||||
void avatarUrlChanged();
|
|
||||||
void roomNameChanged();
|
|
||||||
void loadingChanged();
|
|
||||||
void displayError(const QString &errorMessage);
|
void displayError(const QString &errorMessage);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void avatarChanged();
|
|
||||||
void stopLoading();
|
void stopLoading();
|
||||||
|
void avatarChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void retrieveRoomInfo();
|
void retrieveRoomInfo();
|
||||||
|
|
Loading…
Reference in a new issue