|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
#include "dialogs/RoomSettings.h" |
|
|
|
|
#include <QApplication> |
|
|
|
|
#include <QComboBox> |
|
|
|
|
#include <QEvent> |
|
|
|
@ -15,8 +16,6 @@ |
|
|
|
|
#include <QStandardPaths> |
|
|
|
|
#include <QStyleOption> |
|
|
|
|
#include <QVBoxLayout> |
|
|
|
|
|
|
|
|
|
#include "dialogs/RoomSettings.h" |
|
|
|
|
#include <mtx/responses/common.hpp> |
|
|
|
|
#include <mtx/responses/media.hpp> |
|
|
|
|
|
|
|
|
@ -405,8 +404,31 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) |
|
|
|
|
|
|
|
|
|
auto encryptionLabel = new QLabel(tr("Encryption"), this); |
|
|
|
|
encryptionToggle_ = new Toggle(this); |
|
|
|
|
connect(encryptionToggle_, &Toggle::toggled, this, [this](bool isOn) { |
|
|
|
|
if (isOn) |
|
|
|
|
|
|
|
|
|
auto encryptionOptionLayout = new QHBoxLayout; |
|
|
|
|
encryptionOptionLayout->setMargin(0); |
|
|
|
|
encryptionOptionLayout->addWidget(encryptionLabel, Qt::AlignBottom | Qt::AlignLeft); |
|
|
|
|
encryptionOptionLayout->addWidget(encryptionToggle_, 0, Qt::AlignBottom | Qt::AlignRight); |
|
|
|
|
|
|
|
|
|
auto keyRequestsLabel = new QLabel(tr("Respond to key requests"), this); |
|
|
|
|
keyRequestsLabel->setToolTipDuration(6000); |
|
|
|
|
keyRequestsLabel->setToolTip( |
|
|
|
|
tr("Whether or not the client should respond automatically with the session keys\n" |
|
|
|
|
" upon request. Use with caution, this is a temporary measure to test the\n" |
|
|
|
|
" E2E implementation until device verification is completed.")); |
|
|
|
|
keyRequestsToggle_ = new Toggle(this); |
|
|
|
|
connect(keyRequestsToggle_, &Toggle::toggled, this, [this](bool isOn) { |
|
|
|
|
utils::setKeyRequestsPreference(room_id_, isOn); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
auto keyRequestsLayout = new QHBoxLayout; |
|
|
|
|
keyRequestsLayout->setMargin(0); |
|
|
|
|
keyRequestsLayout->setSpacing(0); |
|
|
|
|
keyRequestsLayout->addWidget(keyRequestsLabel, Qt::AlignBottom | Qt::AlignLeft); |
|
|
|
|
keyRequestsLayout->addWidget(keyRequestsToggle_, 0, Qt::AlignBottom | Qt::AlignRight); |
|
|
|
|
|
|
|
|
|
connect(encryptionToggle_, &Toggle::toggled, this, [this, keyRequestsLabel](bool isOn) { |
|
|
|
|
if (!isOn || usesEncryption_) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
QMessageBox msgBox; |
|
|
|
@ -421,49 +443,27 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) |
|
|
|
|
|
|
|
|
|
switch (ret) { |
|
|
|
|
case QMessageBox::Ok: { |
|
|
|
|
encryptionToggle_->setState(false); |
|
|
|
|
encryptionToggle_->setState(true); |
|
|
|
|
encryptionToggle_->setEnabled(false); |
|
|
|
|
enableEncryption(); |
|
|
|
|
keyRequestsToggle_->show(); |
|
|
|
|
keyRequestsLabel->show(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: { |
|
|
|
|
encryptionToggle_->setState(true); |
|
|
|
|
encryptionToggle_->setEnabled(true); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
auto encryptionOptionLayout = new QHBoxLayout; |
|
|
|
|
encryptionOptionLayout->setMargin(0); |
|
|
|
|
encryptionOptionLayout->addWidget(encryptionLabel, Qt::AlignBottom | Qt::AlignLeft); |
|
|
|
|
encryptionOptionLayout->addWidget(encryptionToggle_, 0, Qt::AlignBottom | Qt::AlignRight); |
|
|
|
|
|
|
|
|
|
auto keyRequestsLabel = new QLabel(tr("Respond to key requests"), this); |
|
|
|
|
keyRequestsLabel->setToolTipDuration(6000); |
|
|
|
|
keyRequestsLabel->setToolTip( |
|
|
|
|
tr("Whether or not the client should respond automatically with the session keys\n" |
|
|
|
|
" upon request. Use with caution, this is a temporary measure to test the\n" |
|
|
|
|
" E2E implementation until device verification is completed.")); |
|
|
|
|
keyRequestsToggle_ = new Toggle(this); |
|
|
|
|
connect(keyRequestsToggle_, &Toggle::toggled, this, [this](bool isOn) { |
|
|
|
|
utils::setKeyRequestsPreference(room_id_, !isOn); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
auto keyRequestsLayout = new QHBoxLayout; |
|
|
|
|
keyRequestsLayout->setMargin(0); |
|
|
|
|
keyRequestsLayout->setSpacing(0); |
|
|
|
|
keyRequestsLayout->addWidget(keyRequestsLabel, Qt::AlignBottom | Qt::AlignLeft); |
|
|
|
|
keyRequestsLayout->addWidget(keyRequestsToggle_, 0, Qt::AlignBottom | Qt::AlignRight); |
|
|
|
|
|
|
|
|
|
// Disable encryption button.
|
|
|
|
|
if (usesEncryption_) { |
|
|
|
|
encryptionToggle_->setState(false); |
|
|
|
|
encryptionToggle_->setState(true); |
|
|
|
|
encryptionToggle_->setEnabled(false); |
|
|
|
|
|
|
|
|
|
keyRequestsToggle_->setState(!utils::respondsToKeyRequests(room_id_)); |
|
|
|
|
keyRequestsToggle_->setState(utils::respondsToKeyRequests(room_id_)); |
|
|
|
|
} else { |
|
|
|
|
encryptionToggle_->setState(true); |
|
|
|
|
encryptionToggle_->setState(false); |
|
|
|
|
|
|
|
|
|
keyRequestsLabel->hide(); |
|
|
|
|
keyRequestsToggle_->hide(); |
|
|
|
@ -543,8 +543,10 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) |
|
|
|
|
layout->addStretch(1); |
|
|
|
|
|
|
|
|
|
connect(this, &RoomSettings::enableEncryptionError, this, [this](const QString &msg) { |
|
|
|
|
encryptionToggle_->setState(true); |
|
|
|
|
encryptionToggle_->setEnabled(true); |
|
|
|
|
encryptionToggle_->setState(false); |
|
|
|
|
keyRequestsToggle_->setState(false); |
|
|
|
|
keyRequestsToggle_->setEnabled(false); |
|
|
|
|
keyRequestsToggle_->hide(); |
|
|
|
|
|
|
|
|
|
emit ChatPage::instance()->showNotification(msg); |
|
|
|
|
}); |
|
|
|
|