diff options
-rw-r--r-- | src/dialogs/CreateRoom.cpp | 7 | ||||
-rw-r--r-- | src/dialogs/RoomSettings.cpp | 24 | ||||
-rw-r--r-- | src/ui/ToggleButton.cpp | 1 |
3 files changed, 17 insertions, 15 deletions
diff --git a/src/dialogs/CreateRoom.cpp b/src/dialogs/CreateRoom.cpp index be5b4638..b5dc5247 100644 --- a/src/dialogs/CreateRoom.cpp +++ b/src/dialogs/CreateRoom.cpp @@ -80,7 +80,8 @@ CreateRoom::CreateRoom(QWidget *parent) directToggle_ = new Toggle(this); directToggle_->setActiveColor(QColor("#38A3D8")); directToggle_->setInactiveColor(QColor("gray")); - directToggle_->setState(true); + directToggle_->setState(false); + directToggle_->setChecked(false); auto directLayout = new QHBoxLayout; directLayout->setContentsMargins(0, 10, 0, 10); @@ -133,8 +134,8 @@ CreateRoom::CreateRoom(QWidget *parent) } }); - connect(directToggle_, &Toggle::toggled, this, [this](bool isDisabled) { - request_.is_direct = !isDisabled; + connect(directToggle_, &Toggle::toggled, this, [this](bool isEnabled) { + request_.is_direct = isEnabled; }); } diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp index 5b7dc59a..30da0eac 100644 --- a/src/dialogs/RoomSettings.cpp +++ b/src/dialogs/RoomSettings.cpp @@ -406,7 +406,7 @@ 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) + if (!isOn) return; QMessageBox msgBox; @@ -421,14 +421,14 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) switch (ret) { case QMessageBox::Ok: { - encryptionToggle_->setState(false); - encryptionToggle_->setEnabled(false); + encryptionToggle_->setState(true); + encryptionToggle_->setEnabled(true); enableEncryption(); break; } default: { - encryptionToggle_->setState(true); - encryptionToggle_->setEnabled(true); + encryptionToggle_->setState(false); + encryptionToggle_->setEnabled(false); break; } } @@ -447,7 +447,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) " E2E implementation until device verification is completed.")); keyRequestsToggle_ = new Toggle(this); connect(keyRequestsToggle_, &Toggle::toggled, this, [this](bool isOn) { - utils::setKeyRequestsPreference(room_id_, !isOn); + utils::setKeyRequestsPreference(room_id_, isOn); }); auto keyRequestsLayout = new QHBoxLayout; @@ -458,12 +458,12 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) // Disable encryption button. if (usesEncryption_) { - encryptionToggle_->setState(false); - encryptionToggle_->setEnabled(false); + encryptionToggle_->setState(true); + encryptionToggle_->setEnabled(true); - 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,8 @@ 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); + encryptionToggle_->setEnabled(false); emit ChatPage::instance()->showNotification(msg); }); diff --git a/src/ui/ToggleButton.cpp b/src/ui/ToggleButton.cpp index 252232a1..40ea82ac 100644 --- a/src/ui/ToggleButton.cpp +++ b/src/ui/ToggleButton.cpp @@ -22,6 +22,7 @@ Toggle::Toggle(QWidget *parent) void Toggle::setState(bool isEnabled) { + setChecked(isEnabled); thumb_->setShift(isEnabled ? Position::Left : Position::Right); setupProperties(); } |