diff options
author | twahm <39034410+twahm@users.noreply.github.com> | 2018-05-12 17:31:58 -0500 |
---|---|---|
committer | mujx <mujx@users.noreply.github.com> | 2018-05-13 01:31:58 +0300 |
commit | 4bd43780d9497daa5e1af7f7a450d25c18377819 (patch) | |
tree | 95ef5443c02fb7f40a4c3d6bd5c42b7ccb980cb8 /src/dialogs | |
parent | Use the correct avatar size for HiDPI displays (diff) | |
download | nheko-4bd43780d9497daa5e1af7f7a450d25c18377819.tar.xz |
Add read support for room access options (#324)
- Join rules - Guest access
Diffstat (limited to 'src/dialogs')
-rw-r--r-- | src/dialogs/RoomSettings.cpp | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp index b85971b0..9bf4cf26 100644 --- a/src/dialogs/RoomSettings.cpp +++ b/src/dialogs/RoomSettings.cpp @@ -38,8 +38,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) setMaximumWidth(385); try { - auto res = cache::client()->getRoomInfo({room_id_.toStdString()}); - info_ = res[room_id_]; + info_ = cache::client()->singleRoomInfo(room_id_.toStdString()); setAvatar(QImage::fromData(cache::client()->image(info_.avatar_url))); } catch (const lmdb::error &e) { @@ -75,13 +74,67 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) notifOptionLayout_->addWidget(notifLabel); notifOptionLayout_->addWidget(notifCombo, 0, Qt::AlignBottom | Qt::AlignRight); + auto accessOptionLayout = new QHBoxLayout(); + accessOptionLayout->setMargin(5); + auto accessLabel = new QLabel(tr("Room access"), this); + accessCombo = new QComboBox(this); + accessCombo->addItem(tr("Anyone and guests")); + accessCombo->addItem(tr("Anyone")); + accessCombo->addItem(tr("Invited users")); + accessCombo->setDisabled(true); + accessLabel->setStyleSheet("font-size: 15px;"); + + if(info_.join_rule == JoinRule::Public) + { + if(info_.guest_access) + { + accessCombo->setCurrentIndex(0); + } + else + { + accessCombo->setCurrentIndex(1); + } + } + else + { + accessCombo->setCurrentIndex(2); + } + + accessOptionLayout->addWidget(accessLabel); + accessOptionLayout->addWidget(accessCombo); + layout->addWidget(new TopSection(info_, avatarImg_, this)); layout->addLayout(notifOptionLayout_); layout->addLayout(notifOptionLayout_); + layout->addLayout(accessOptionLayout); layout->addLayout(btnLayout); connect(cancelBtn_, &FlatButton::clicked, this, &RoomSettings::closing); - connect(saveBtn_, &FlatButton::clicked, this, [this]() { emit closing(); }); + connect(saveBtn_, &FlatButton::clicked, this, &RoomSettings::save_and_close); +} + +void +RoomSettings::save_and_close() { + // TODO: Save access changes to the room + if (accessCombo->currentIndex()<2) { + if(info_.join_rule != JoinRule::Public) { + // Make join_rule Public + } + if(accessCombo->currentIndex()==0) { + if(!info_.guest_access) { + // Make guest_access CanJoin + } + } + } + else { + if(info_.join_rule != JoinRule::Invite) { + // Make join_rule invite + } + if(info_.guest_access) { + // Make guest_access forbidden + } + } + closing(); } void |